Last active
April 26, 2022 06:31
-
-
Save anlisha-maharjan/a87c0a8e72abd46d8aab0bc0f3fa7647 to your computer and use it in GitHub Desktop.
Setup i18n.js configuration for languages "en" & "no".
This file contains hidden or 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 i18n from "i18next"; | |
| import { initReactI18next } from "react-i18next"; | |
| import HttpApi from "i18next-http-backend"; | |
| import LanguageDetector from "i18next-browser-languagedetector"; | |
| const fallbackLng = ["en"]; | |
| const availableLanguages = ["en", "no"]; | |
| i18n | |
| .use(HttpApi) // load translations using http (default public/locals/en/translations) | |
| .use(LanguageDetector) // detect user language | |
| .use(initReactI18next) // pass the i18n instance to react-i18next. | |
| .init({ | |
| fallbackLng, // fallback language is english. | |
| preload: ["en", "no"], | |
| detection: { | |
| checkWhitelist: true, // options for language detection | |
| }, | |
| supportedLngs: availableLanguages, | |
| react: { | |
| useSuspense: false, | |
| }, | |
| debug: false, | |
| whitelist: availableLanguages, | |
| }); | |
| export default i18n; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment