[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug #60027] Supporting template interpolation and tags in JavaScript

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


                 Summary: Supporting template interpolation and tags in
                 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



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

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}"


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:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]