chore(i18n): use default i18n provider, define LanguageManager component to handle direction and lng
This commit is contained in:
22
src/config/i18n.ts
Normal file
22
src/config/i18n.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||
import HttpApi from 'i18next-http-backend';
|
||||
|
||||
i18n
|
||||
.use(HttpApi) // Loads translations from your /public/locales folder
|
||||
.use(LanguageDetector) // Detects user language
|
||||
.use(initReactI18next) // Passes i18n down to react-i18next
|
||||
.init({
|
||||
supportedLngs: ['en', 'fa'], // Supported languages
|
||||
fallbackLng: 'fa',
|
||||
detection: {
|
||||
order: ['localStorage', 'cookie', 'navigator'],
|
||||
caches: ['localStorage', 'cookie'],
|
||||
lookupLocalStorage: 'language', // The key to use in localStorage
|
||||
},
|
||||
ns: ['common'], // Add new namespaces here
|
||||
defaultNS: 'common',
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
Reference in New Issue
Block a user