Files
reactShop/src/i18n/index.js

126 lines
3.1 KiB
JavaScript

import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
// Import all translation files
import translationDE from './locales/de/translation.js';
import translationEN from './locales/en/translation.js';
import translationAR from './locales/ar/translation.js';
import translationBG from './locales/bg/translation.js';
import translationCS from './locales/cs/translation.js';
import translationEL from './locales/el/translation.js';
import translationES from './locales/es/translation.js';
import translationFR from './locales/fr/translation.js';
import translationHR from './locales/hr/translation.js';
import translationHU from './locales/hu/translation.js';
import translationIT from './locales/it/translation.js';
import translationPL from './locales/pl/translation.js';
import translationRO from './locales/ro/translation.js';
import translationRU from './locales/ru/translation.js';
import translationSK from './locales/sk/translation.js';
import translationSL from './locales/sl/translation.js';
import translationSR from './locales/sr/translation.js';
import translationSV from './locales/sv/translation.js';
import translationTR from './locales/tr/translation.js';
import translationUK from './locales/uk/translation.js';
import translationZH from './locales/zh/translation.js';
const resources = {
de: {
translation: translationDE
},
en: {
translation: translationEN
},
ar: {
translation: translationAR
},
bg: {
translation: translationBG
},
cs: {
translation: translationCS
},
el: {
translation: translationEL
},
es: {
translation: translationES
},
fr: {
translation: translationFR
},
hr: {
translation: translationHR
},
hu: {
translation: translationHU
},
it: {
translation: translationIT
},
pl: {
translation: translationPL
},
ro: {
translation: translationRO
},
ru: {
translation: translationRU
},
sk: {
translation: translationSK
},
sl: {
translation: translationSL
},
sr: {
translation: translationSR
},
sv: {
translation: translationSV
},
tr: {
translation: translationTR
},
uk: {
translation: translationUK
},
zh: {
translation: translationZH
}
};
i18n
.use(LanguageDetector)
.use(initReactI18next)
.init({
resources,
fallbackLng: 'de', // German as fallback since it's your primary language
lng: 'de', // Default language
debug: process.env.NODE_ENV === 'development',
// Language detection options
detection: {
// Order of language detection methods
order: ['localStorage', 'navigator', 'htmlTag'],
// Cache the language selection
caches: ['localStorage'],
// Check for language in localStorage
lookupLocalStorage: 'i18nextLng'
},
interpolation: {
escapeValue: false // React already escapes values
},
// Namespace configuration
defaultNS: 'translation',
// React-specific options
react: {
useSuspense: false // Disable suspense for class components compatibility
}
});
export default i18n;