Internationalization
Internationalization
Adding a new language
import { I18nManager } from 'react-native';
import AsyncStorage from '@react-native-community/async-storage';
import I18n from 'react-native-i18n';
import fr from './locales/fr';
import en from './locales/en';
import de from './locales/de'; // add importation of de file created
I18n.fallbacks = true;
AsyncStorage.getItem('@userlangue', (err, result) => {
if(result) {
if(result === 'en') {
I18n.locale = 'en';
} else if(result === 'fr') {
I18n.locale = 'fr';
} else if(result === 'de') { // add a new condition for your new language
I18n.locale = 'de';
}
}
else {
I18n.locale = 'fr';
}
});
I18n.translations = {
fr,
en,
de, // don't forget to call
};
I18nManager.allowRTL(I18n.locale in I18n.translations);
I18n.start = I18nManager.isRTL ? 'right' : 'left';
I18n.end = I18nManager.isRTL ? 'left' : 'right';
export default I18n;
Using Translated Strings
Last updated
Was this helpful?