From 98c25b99c9bdc16078ee6552925a2c183a511c6f Mon Sep 17 00:00:00 2001 From: Bruno Costa Date: Tue, 7 Jan 2020 03:09:08 -0300 Subject: [PATCH] fix(i18n): fix file type and import fix #1668 --- src/i18n.js | 45 --------------------------------------------- src/i18n.tsx | 26 ++++++++++++++++++++++++++ src/index.tsx | 2 +- 3 files changed, 27 insertions(+), 46 deletions(-) delete mode 100644 src/i18n.js create mode 100644 src/i18n.tsx diff --git a/src/i18n.js b/src/i18n.js deleted file mode 100644 index ee02f75eb2..0000000000 --- a/src/i18n.js +++ /dev/null @@ -1,45 +0,0 @@ -import i18n from 'i18next' -import Backend from 'i18next-xhr-backend' -import LanguageDetector from 'i18next-browser-languagedetector' -import { initReactI18next } from 'react-i18next' - -import * as en from './example.json'; -i18n - // load translation using xhr -> see /public/languages - // 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) - // pass the i18n instance to react-i18next. - .use(initReactI18next) - // init i18next - // for all options read: https://www.i18next.com/overview/configuration-options - .init({ - // we init with resources - resources: { - en: { - translations: { - "To get started, edit <1>src/App.js and save to reload.": - "To get started, edit <1>src/App.js and save to reload.", - "Welcome to React": "Welcome to React and react-i18next", - welcome: "Hello
World" - } - }, - de: { - translations: { - "To get started, edit <1>src/App.js and save to reload.": - "Starte in dem du, <1>src/App.js editierst und speicherst.", - "Welcome to React": "Willkommen bei React und react-i18next" - } - } - }, - fallbackLng: 'en', - debug: true, - - interpolation: { - escapeValue: false, // not needed for react as it escapes by default - }, - }) - -export default i18n diff --git a/src/i18n.tsx b/src/i18n.tsx new file mode 100644 index 0000000000..d73fdac9b1 --- /dev/null +++ b/src/i18n.tsx @@ -0,0 +1,26 @@ +import i18n from 'i18next'; +import Backend from 'i18next-xhr-backend'; +import LanguageDetector from 'i18next-browser-languagedetector'; +import { initReactI18next } from 'react-i18next'; + +i18n + // load translation using xhr -> see /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) + // pass the i18n instance to react-i18next. + .use(initReactI18next) + // init i18next + // for all options read: https://www.i18next.com/overview/configuration-options + .init({ + fallbackLng: 'en', + debug: true, + + interpolation: { + escapeValue: false, // not needed for react as it escapes by default + }, + }); + +export default i18n; diff --git a/src/index.tsx b/src/index.tsx index 003742a69b..eaa56436ec 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,7 +4,7 @@ import 'bootstrap/dist/css/bootstrap.min.css' import './index.css' import App from './App' import * as serviceWorker from './serviceWorker' -import './i18n' +import './i18n.tsx' ReactDOM.render(, document.getElementById('root'))