4

I'm migrating relatively large java application to React and need to implement internationalisation in React application. Sure, there are many libraries available for i18n in React, like FormaJS and i18next but I found most of them not answering to my requirements:

  1. All the translation is already done in form of java resource bundles where key and messages look like:

    simpleKey = Hi!
    multiParamterKey = Dear {0}, I have {1} messages for you
    formattingKey = Ticket {0,number,#} has been closed 
    multiLineKey = Dear {0}, \n\
    \n\
    Have a nice day \n\
    otherKey = ...
    

    We don't need pluralisation but want to avoid replacing numeric parameters {0} with named parameters {key1}, if possible, as it could be tricky especially, where format involved (formattingKey). Also I have to use existing keys.

  2. The library should support locale for fallback translation. I.e. if I have German locale set as fallback locale and translating key for English, all the missing keys in _en file/source should be translated using _ge file/source

  3. (Ideally) Library should allow changing fallback and current locale dynamically

  4. (Ideally) Library should allow loading bundles using ajax

I decided against FormatJS mostly because of id does not support fallback locales. It has a concept of default translations which should be provided in the component when used.

I close to decide against i18next as - React integration project seems not very popular - Need to change messages to use named parameters

Can anyone recommend some other libraries?

Mikhail Chibel
  • 1,865
  • 1
  • 22
  • 34

0 Answers0