On Mar 6, 2014, at 15:46 , Axel Rauschmayer <a...@rauschma.de> wrote:

> – Regular expressions: https://gist.github.com/slevithan/4222600
> – Escaping the variable parts of domain-specific languages
> – HTML templates (think Facebook’s React)
> – Internationalization

Not internationalization. The strawman page for template strings 
(quasi-literals back then) included some ideas for how they might be used for 
internationalization and localization, but internationalization generally 
doesn't allow localizable strings to be embedded in source code (specialized 
environments like Closure may be an exception). In addition, message formatting 
has requirements that cannot be addressed with template strings - for example, 
gender support may require additional variables to be provided that are only 
used in some languages, not in others, but template strings don't provide a way 
to pass unused variables:

On Mar 6, 2014, at 18:51 , Domenic Denicola <dome...@domenicdenicola.com> wrote:

> // Localization and formatting
> l10n`Hello ${name}; you are visitor number ${visitor}:n! You have ${money}:c 
> in your account!`

A correct German translation of this would have to take the gender of the 
visitor into consideration:
Male: l10n`Hallo, Herr ${name}; Sie sind Besucher Nummer ${visitor}:n. Sie 
haben ${money}:c auf Ihrem Konto.`
Female: l10n`Hallo, Frau ${name}; Sie sind Besucherin Nummer ${visitor}:n. Sie 
haben ${money}:c auf Ihrem Konto.`

How would you do that with template strings?

Norbert

_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to