I use I18n in my app with a config :
I18n.translations = {
en: en,
fr: fr,
};
if (!__DEV__) {
I18n.fallbacks = true;
}
I18n.defaultLocale = 'en';
I18n.locale = localeLanguageTag as ELanguagesKeys;
Then I export it and use it as usual ...
In a component, I have an object array with some translation key :
const onBordingSteps: ISteps = [
{
label: I18n.t('auth.heading.steps.onboarding.step1.title'),
isCompleted: true,
icon: GGValidation,
iconHeight: 49.36,
iconWidth: 28.48,
},
{
label: I18n.t('auth.heading.steps.onboarding.step2.title'),
isCompleted: false,
.....
];
I use this array directly after its creation in my component
return (
<PreOnboarding
steps={onBordingSteps}
...
But when I import this array from another file, it didn't find the key and I have this error on each items:
Maybe this will help you, because I think it might be an issue with the export method of the keys since they cannot be found
In my implementation I store the keys like this
translate
function (in this way you won't have to import thei18n-js
wherever you use it