ikevin8me
ikevin8me

Reputation: 4313

Localization of text in Android

What is the solution or best practice to display localized text strings in Android?

For example:

The English version text: "You have 1 message" and "You have 3 messages".

Note that the word "message" or "messages" is determined by the integer number.

If this were to be localized in another message, the insertion of the integer number could be at the beginning or the end of the sentence, not necessary in the middle of the sentence.

Further, for languages like Japanese it could better to use the full-width " 3 " to display the number as part of the sentence.

That means, even if I manage all localization text in a strings file, I would still need some kind of logic to calculate the final displayed text.

What is the best practice?

Any library I could use?

Upvotes: 1

Views: 236

Answers (1)

adrai
adrai

Reputation: 3168

I would recommend looking into a i18n lib that has a mature ecosystem, i.e. i18next There is some android lib too: i.e. i18next-android

It has good support for multiple plural forms too: i18next-android#multiple-plural-forms

Further you should not only consider that you have to instrument your code (i18n) to get your app/website translated. You should think about the process too - how will you solve continuous localization, how you keep track of progress, etc...

For a translation management+ system you might eg. have a look at locize it plays well with all json based i18n frameworks and in the core has a very simpe api... and provides a lot more than traditional systems.

Upvotes: 2

Related Questions