Page MenuHomePhabricator

Translate numeric variables within Translation extension
Closed, ResolvedPublic


Feature request: Make it possible to create a variable with only a number and automatically translate that number. (see Talk:Tech/News/2020/26)

Hopefully a library already exists to do that. Here are the languages I have found so far, even if only for testing:

[1]: Pashto is used in Afghanistan (48%) and Pakistan (18%), "Eastern Arabic numerals remain strongly predominant" in Afghanistan but "In Pakistan, Western Arabic numerals are more extensively used." link

Not base 10:

Papua New Guinea:

Event Timeline

Nikerabbit claimed this task.

It's not perfect, but you can do it like this:

<translate>You have <tvar name=1>{{FORMATNUM:5}}</tvar> apples</translate>

Even better with plural, but the syntax is more complicated:
<translate>You have {{PLURAL:<tvar name=1>{{FORMATNUM:5}}</tvar>|an apple|<tvar name=1>{{FORMATNUM:5}}</tvar> apples}}</translate>

There are a small issues with rendering of untranslated segments in fallback languages, because these magic words do not support {{TRANSLATIONLANGUAGE}}. The variants in do that, but it's not installed on Meta.

Unfortunately the way Tech News works (and until T272102 is resolved), the proposed solution could cause issues not only when the translation unit isn’t translated, but also when it is—when the newsletter is distributed, it may appear in a different language context, with different number formatting rules. This would be resolved by substituting it during the distribution.