All the translations files live under the src/translations folder. Translation for each language are placed inside the json files with locale names.
Adding a new language
In order to add a new language you need to do 3 simple steps. Let's imagine you're adding a support for German language :
Create a file called src/translations/de.json and add translations strings there (see below for explanation on translation strings).
Change the src/translations/index.js to be the following
src/translations/index.js
import*asRNLocalizefrom'react-native-localize';importi18nfrom'i18n-js';importenfrom'./en.json';importrufrom'./ru.json';// Import newly added language fileimportdefrom'./de.json';// Add the German translation to the listconsttranslations={en,ru,de};const{languageTag}=RNLocalize.findBestAvailableLanguage(Object.keys(translations),) ||{languageTag:'en'};i18n.locale=languageTag;i18n.fallbacks=true;i18n.translations=translations;exportdefaulti18n;
And now you can use translations in your files.
Using Translated Strings
First of all, let's see, how to define translations string in translation files. Look at the example translation file:
In such file you define your translated strings as a nested JSON.
After you defined your translations, you can use it anywhere in your code like this:
Call to I18t.t('PATH') will return the translated string for the current user language from json file with a path, equal to PATH
// ... All the imports
// Import from your translations index
import I18t from '../translations';
export default function SettingsSection() {
return (
<View>
<Text>{I18t.t('Settings.audio')}</Text>
<Button>{I18t.t('Settings.Common.button.save')}</Button>
</View>
);
}