1

Different languages structure sentences differently. In english we say White house, while other languages use a different structure where the noun is first, and the adjective second.

When I am creating a string I concatenate a color variable with a string constant using template literals.

`${color} House`

The adjective is alway before the noun.

If it was just a constant string White house the translation would be straight forward in the lang.json file. How do you accurately translate a string where it is composed of variables in a specific order; or in a set spot in the string, due to other languages structuring their sentences in a different order?

4

1 回答 1

1

Actually do not use template strings let the i18n framework do the job - most major i18n frameworks come with an interpolation feature, like eg. in i18next:

string resource myKey: {{color}} house -> i18next.t('myKey', { color: 'white' })

https://www.i18next.com/interpolation.html

于 2017-09-08T10:17:11.000 回答