Skip to content

Instantly share code, notes, and snippets.

@hirataya
Last active December 11, 2018 05:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hirataya/e1d8cdb813f0cbd6d09debe838808043 to your computer and use it in GitHub Desktop.
Save hirataya/e1d8cdb813f0cbd6d09debe838808043 to your computer and use it in GitHub Desktop.
React + i18next
import React from "react";
import i18n from "path/to/i18n.js";
const HelloWorld = () => {
return(<p>{ i18n.t("hello") }</p>);
}
export default HelloWorld;
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