The first time I got to localization.

Found a couple of libraries, but wondered - why are they?

For example, create an object:

var languages = { ru:{ menu:"Меню", addfav:"Добавить в избранное", removefav:"Убрать из избранного", choice:"Выбор" }, en:{ menu:"Menu", addfav:"Add to favorites", removefav:"Remove from favorites", choice:"Choice" } }; 

And in the text I will take lines from another object, in which I will update the fields according to the language.

What's my mistake?

  • "Found a couple of libraries" - which libraries? - nick_n_a
  • Localization libraries are needed to display messages in different languages, and it is convenient to encrypt and edit the text of the message in the file (s) of the language. There are features in them, for example, if the translation is absent - the meaning can be taken from the "main" language. It may also be possible to switch the language, it may not be. The main, perhaps, feature is the convenience and availability of integration with the development environment. - nick_n_a
  • Libraries, for example: react-native-l20n, ReactNativeLocalization, i18n. Hmm, from what you listed - like my method is not worse. When filling in the fields of an object, I can also specify a filling from the default language if the value is missing. , - keltkelt

0