I am looking for some help (and some tools) for advanced localization. I am using a Node backend, so I would prefer tools/libraries in JS.
I currently do some simple string replacement using a properties file that are localized to different languages.
home_en.properties
page.title=My Site
page.header=Hello %s
home_de.properties
page.title=Meine Seite
page.header=Hallo %s
So far so good... but here are a few more advanced examples I am trying to solve:
Multiples
I need to be able to translate multiples correctly, for example:
You have 1 message
vs
You have 2 messages
I do not want to have logic in my code that says
if (i == 1) { // use page.messages.singular }
else { // use page.messages.plural }
because I do not believe that check belongs in my business logic and I know that different languages treat singular/plural differently (i.e. singular includes 0)
Multiple multiples
Some issue as above, but now with multiple combinations of multiples, for example:
You have %d unread messages and %d read messages
or
You have %d unread messages and %d read messages, as well as %d private notifications
Gender
Here is an example I would like to solve:
I love my %s
and possible values are cat, dog, horse
No problem in English, but in German, this would require:
home_de.properties
animals.like.male=Ich liebe meinen %s
animals.like.female=Ich liebe meine %s
animals.like.neutral=Ich liebe mein %s
which would then lead to unnecessary entries for English:
home_en.properties
animals.like.male=I love my %s
animals.like.female=I love my %s
animals.like.neutral=I love my %s
Question
This was all a long winded setup for the following question:
What tools/libraries are out there that would solve advanced string localization like this?