Closed sedubois closed 6 years ago
i18n.t`${i18n.plural({ value, one: `# result found`, other: `# results found`} )} in {ms} ms`
Although I would rather recommend to move in {ms} ms
inside plural, so translator see the whole message in one piece. Both messages result in the same output:
i18n.plural({
value,
one: `# result found in {ms} ms`,
other: `# results found in {ms} ms`
})
Just a note:
You could also use this:
i18n.t`${i18n.plural({ value, one: `# result`, other: `# results`} )} found in {ms} ms`
and still translate it into this:
"{value, plural, one {# résultat trouvé} other {# résultats trouvés}} en {ms} ms"
You don't have to map words in plurals 1:1.
Extreme example, in language without plurals the translation would be:
{value, number} result(s) found in {ms} ms
That's the power of ICU MessageFormat - it doesn't assume anything about source/target languages.
This is really undocumented :( Some examples are in tutorial https://lingui.js.org/tutorials/javascript.html, but that's not enough...
Ah thanks, it's great that the calls can be nested and still result in a single translation key 🙂
i18n.t`${i18n.plural({
value,
one: `# result found`,
other: `# results found`
})} in {ms} ms`;
This is exactly what I need for French:
"{value, plural, one {# résultat trouvé} other {# résultats trouvés}} en {ms} ms"
I'm excited about learning Lingui and wonder how I should use
i18n.t
etc to produce this kind of translation key with lingui extract:The French translation would be
"{value, plural, one {# résultat trouvé} other {# résultats trouvés}} en {ms} ms"
.I didn't find info about this in the plural documentation.