Configuration

5. Localization

We implemented a simple way to make your app available in multiple translations.

5.1 Change existing texts

If you want to change the wording of some things in the app you can find the necessary files in the folder src/i18n/languages. As you can see there is one JavaScript file for each language. Just open up the languages and change the texts.

5.3 Add a new language

Adding a new language is as simple as editing existing strings. Start by copying a reference language file (for example en.js). Save the file in the same folder and name it as the language identifier of the language you want to add. You can find a list of the short codes here:

➡️ https://gist.github.com/jacobbubu/1836273

You can now change all the strings. After that open the file src/i18n/index.js and import and include the file the same was as the others:

import LocalizedStrings from 'react-native-localization';
import en from './languages/en';
import de from './languages/de';
// 1. IMPORT IT LIKE THIS:
import fr from './languages/fr';



// The first language included below will be the default
const strings = new LocalizedStrings({
  en,
  de,
  // 2. Then add it to this object
  fr,
});

export default strings;

Done!

Tip: In the strings object, the first language you added will be the default language. If you don't support a language it will fall back to english. If you'd like to haver another fallback language, just add it before en, not after.

results matching ""

    No results matching ""