taler
[Top][All Lists]
Advanced

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

Re: [Taler] i18n


From: Christian Grothoff
Subject: Re: [Taler] i18n
Date: Tue, 26 Jan 2016 17:52:47 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Icedove/38.5.0

Florian,

I don't know if you saw this, but GNU Gettext supports extraction using
xgettext:

https://www.gnu.org/software/gettext/manual/html_node/JavaScript.html

Just FYI.

-Christian

On 01/26/2016 04:26 PM, Florian Dold wrote:
> Hi!
> 
> Gabor pointed me to some resources for JavaScript internationalization
> (i18n), I'll summarize how the situation looks to me here.
> 
> In general, there are two distinct flavors of i18 approaches:
> 
> 1. resource-based:  Most of today's larger (web) applications seem to
> use this.  The programmer never writes string constants directly, but
> always refers to a resource, like:
> 
> showDialog(getTranslation(MessageResources.Welcome, args))
> 
> This is more tedious for the programmer, but allows to use the
> MessageFormat [1] translation standard, which allows all kinds of fancy
> things (complex queries, support for gender, ...).
> 
> Enterprise-y frameworks like AngularJS follow this style as well [2].
> 
> 
> 2. gettext-style:  Programmers just write all strings that should be
> translated in their favorite language and mark then, usually via this
> underscore macro.  Some helper program then extracts the translatable
> string.
> 
> JavaScript has enough libraries to *read* .po/.mo files, but barely any
> support for extracting these strings from source.
> 
> However, it would be trivial(ish) to just use an off-the-shelf JS parser
> (esprima [3] is very good for that) to extract marked strings,
> preferably tagged template literals like:
> 
> i18n`This is a translated message.  Hello ${user}.`
> 
> Alternatively, we'd just have to hack together our own message catalogue
> for gettext by grepping the source code in the beginning.
> 
> 
> Does anybody have more experience with i18n in JavaScript projects?
> 
> Do we want to do gettext or resource-based translations?
> 
> Personally as a developer I'd prefer gettext-style, but in the end I
> wouldn't mind either too much.
> 
> - Florian
> 
> 
> [1] http://userguide.icu-project.org/formatparse/messages
> [2] https://docs.angularjs.org/guide/i18n
> [3] http://esprima.org/
> [4] https://github.com/gmarty/xgettext
> 

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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