Enable users to switch seamlessly between English and Arabic languages
Adds i18next, LanguageDetector, locales (en.json, ar.json), and LanguageSwitcher component for internationalization. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ff0be73b-afdd-4747-978b-bb8301fb0a82 Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/9777c70b-fc38-4831-8d6b-78dfffe041b0/d552135c-0e60-4fc7-98a2-0e9cddf2b4b3.jpg
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
import i18n from 'i18next';
|
||||
import { initReactI18next } from 'react-i18next';
|
||||
import LanguageDetector from 'i18next-browser-languagedetector';
|
||||
|
||||
// Import translation files
|
||||
import enTranslations from './locales/en.json';
|
||||
import arTranslations from './locales/ar.json';
|
||||
|
||||
i18n
|
||||
.use(LanguageDetector)
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
resources: {
|
||||
en: {
|
||||
translation: enTranslations
|
||||
},
|
||||
ar: {
|
||||
translation: arTranslations
|
||||
}
|
||||
},
|
||||
lng: 'en', // default language
|
||||
fallbackLng: 'en',
|
||||
debug: false,
|
||||
|
||||
interpolation: {
|
||||
escapeValue: false, // React already does escaping
|
||||
},
|
||||
|
||||
detection: {
|
||||
order: ['localStorage', 'navigator', 'htmlTag'],
|
||||
lookupLocalStorage: 'language',
|
||||
caches: ['localStorage'],
|
||||
},
|
||||
});
|
||||
|
||||
export default i18n;
|
||||
Reference in New Issue
Block a user