Skip to content

dnddone/react-i18n-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

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

import translationEN from './locales/en/translation.json';

const resources = {
  en: {
    translation: translationEN
  }
};

i18n
  /**
   * load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales)
   * learn more: https://github.com/i18next/i18next-xhr-backend
   */
  .use(Backend)

  /**
   * detect user language
   * learn more: https://github.com/i18next/i18next-browser-languageDetector
   */
  .use(LanguageDetector)

  .use(initReactI18next)
  .init({
    resources,
    lng: 'en',
    fallbackLng: 'en',
    debug: true,

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

export default i18n;

Import this config to the application entry point to be bundled.

About

React i18next boilerplate

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published