In order to add a translation, follow these steps
- Add a new file under src/i18n/locales/<locale_name>.js where ‘locale_name’ must be the locale code for the language you would like to add. For example if you want to add a translation for german the file name should be ‘de.js’
- Copy the contents of ‘en.js’ file in the newly created file from previous step and translate the string values to the respective language.
- In order for the user to be able to pick the language in his profile, open ‘src/screens/profile/ProfileForm.js’ and add a new entry to the ‘languages’ array similar to the existing ones. For our ‘de’ example, the new entry would be { name: “de”, value: “de” }.
- For every language that your app supports, open the relevant locale file (under ‘locales’ folder) and add a new translation entry that resembles the new language. Example: open ‘en.js’ and add the following key, value pair de: “German”
- Finally open src/i18n/i18n.js and add your new supported language eg
I18n.translations = {
en,
de
};