I have a React Native project that was using i18n-js older version (3.8.0), so I decided upgrade this package on my project.
This is the new code:
src/i18n/src/locale/index.ts
import {I18n} from 'i18n-js';
import en from './en-US';
import pt from './pt-BR';
const translations = {en, 'pt-BR': pt};
type TranslationsTypes = keyof typeof translations;
const i18n = new I18n(translations);
export default i18n;
export const translate = (key: string) => i18n.t(key);
And this is a sample how I use:
import {translate} from 'i18n/src/locale';
<Text style={{color: '#DDDDDD', marginLeft: 5}}>
{translate('text_1')}
</Text>
But when I start my React Native project, I get this warning:
Require cycle: node_modules/i18n-js/dist/import/helpers/index.js -> node_modules/i18n-js/dist/import/helpers/formatNumber.js -> node_modules/i18n-js/dist/import/helpers/index.js
Require cycles are allowed, but can result in uninitialized values. Consider refactoring to remove the need for a cycle.
Is this a i18n-js package problem, or did I something wrong?
Thanks