|
From: | Evan Welsh |
Subject: | [bug #60027] Supporting template interpolation and tags in JavaScript |
Date: | Tue, 9 Feb 2021 01:33:55 -0500 (EST) |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0 |
URL: <https://savannah.gnu.org/bugs/?60027> Summary: Supporting template interpolation and tags in JavaScript Project: GNU gettext Submitted by: ewlsh Submitted on: Tue 09 Feb 2021 06:33:53 AM UTC Category: JavaScript Severity: 3 - Normal Item Group: None Status: None Privacy: Public Assigned to: None Open/Closed: Open Discussion Lock: Any _______________________________________________________ Details: GJS hopes to deprecate its formatting module in favor of template strings. Such a change would require xgettext changes to continue supporting translated strings. We're hoping to discuss whether xgettext would ship support for a potential API if we were to implement it in GJS or alternatively what API xgettext would be interested in shipping. The GJS proposal is currently at https://gitlab.gnome.org/GNOME/gjs/-/issues/374 The goal of the initial proposal is to make it close enough to the existing syntax that it is not overly challenging to parse or implement. ## The API The API could potentially look like: gettext(msgid`A sentence with an ${argument}`) where `msgid` is a template tag which handles the appropriate conversions before passing it to a gettext function. The msgid would be the same string with any top-level expressions replaced by their index: msgid "A sentence with an ${0}" (or) msgid "A sentence with a ${0} and a ${1}" ### Shortcuts A shortcut for gettext could also be included: _`A dog named ${name}` To simplify the very common... _(msgid`A dog named ${name}`) _______________________________________________________ Reply to this item at: <https://savannah.gnu.org/bugs/?60027> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/
[Prev in Thread] | Current Thread | [Next in Thread] |