Branch: master
Find file Copy path
bf7816b Feb 6, 2019
1 contributor

Users who have contributed to this file

47 lines (33 sloc) 1.36 KB

i18next instance

The instance is an initialized i18next instance. In the following code snippet, we add a backend to load translations from server and a language detector for detecting user language.

You can learn more about i18next and plugins on the i18next website.

import i18n from 'i18next';
import XHR from 'i18next-xhr-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
import { initReactI18next } from 'react-i18next';

  .use(initReactI18next) // bind react-i18next to the instance
    fallbackLng: 'en',
    debug: true,

    interpolation: {
      escapeValue: false, // not needed for react!!

    // react i18next special options (optional)
    react: {
      bindI18n: 'languageChanged loaded'

export default i18n;

All additional options for react in init options:

options default description
bindI18n 'languageChanged' which events trigger a rerender, can be set to false or string of events separated by " "
transEmptyNodeValue '' how to treat failed lookups in Trans component

For more initialization options have look at the docs.