Last active
January 11, 2022 18:11
-
-
Save smoralb/d3e31078f663ae7f00d738e3293c396f to your computer and use it in GitHub Desktop.
Basic i18n set up
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 i18n from "i18next"; | |
import { initReactI18next } from "react-i18next" | |
import Backend from 'i18next-http-backend'; | |
import LanguageDetector from 'i18next-browser-languagedetector'; | |
const DETECTION_OPTIONS = { | |
order: ['navigator'] | |
}; | |
i18n | |
.use(Backend) // Automatically detects translation files | |
.use(initReactI18next) | |
.use(LanguageDetector) // Autommatically detects the browser's language | |
.init({ | |
detection: DETECTION_OPTIONS, // Detection options | |
fallbackLng: "en", // If does not find the language of the browser, is going to use english as a default language | |
react: { | |
useSuspense: true | |
} | |
}); | |
export default i18n; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment