Last active
December 11, 2018 05:54
-
-
Save hirataya/e1d8cdb813f0cbd6d09debe838808043 to your computer and use it in GitHub Desktop.
React + i18next
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import i18n from "path/to/i18n.js"; | |
const HelloWorld = () => { | |
return(<p>{ i18n.t("hello") }</p>); | |
} | |
export default HelloWorld; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import i18next from "i18next"; | |
import LanguageDetector from "i18next-browser-languagedetector"; | |
import enLocalesTranslationJson from "json5-loader!locales/en"; | |
import jaLocalesTranslationJson from "json5-loader!locales/ja"; | |
i18next.use(LanguageDetector).init({ | |
fallbackLng: "ja", | |
debug: true, | |
resources: { | |
en: {translation: enLocalesTranslationJson}, | |
ja: {translation: jaLocalesTranslationJson}, | |
}, | |
}); | |
export default i18next; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment