chore(i18n): use default i18n provider, define LanguageManager component to handle direction and lng

This commit is contained in:
Sajad Mirjalili
2025-07-15 12:18:42 +03:30
parent f14bd00ed8
commit 141a827d22
20 changed files with 95 additions and 153 deletions

22
src/config/i18n.ts Normal file
View 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;