Skip to content

Instantly share code, notes, and snippets.

@darde
Last active August 7, 2018 19:20
Show Gist options
  • Save darde/154e6f675e608c4c3b36df73073eba78 to your computer and use it in GitHub Desktop.
Save darde/154e6f675e608c4c3b36df73073eba78 to your computer and use it in GitHub Desktop.
react-i18next-example/src/i18n/index.js
import i18n from 'i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import { pt, en } from './locales';
const options = {
interpolation: {
escapeValue: false, // not needed for react!!
},
debug: true,
// lng: 'en',
resources: {
pt: {
common: pt['pt-BR'],
},
en: {
common: en.en,
},
},
fallbackLng: 'en',
ns: ['common'],
defaultNS: 'common',
react: {
wait: false,
bindI18n: 'languageChanged loaded',
bindStore: 'added removed',
nsMode: 'default'
},
};
i18n
.use(LanguageDetector)
.init(options)
.changeLanguage('en', (err, t) => {
if (err) return console.log('something went wrong loading', err);
});
export default i18n;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment