chore: setup i18next configuration with 9 language support

This commit is contained in:
gnezim
2026-04-05 20:45:19 +03:00
parent 8ba79f64e8
commit 1ce307d61f
2 changed files with 44 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
import i18n from 'i18next'
import HttpBackend from 'i18next-http-backend'
import { initReactI18next } from 'react-i18next'
// Language detection logic (simplified without additional dependency)
const getInitialLanguage = (): string => {
// Try to get from localStorage
const stored = localStorage.getItem('i18nextLng')
if (stored) return stored
// Try to get from navigator
const nav = navigator.language || (navigator as any).userLanguage
const userLang = nav.split('-')[0]
// Check if user language is supported
const supportedLanguages = ['ru', 'en', 'es', 'fr', 'it', 'ja', 'ko', 'de', 'zh']
if (supportedLanguages.includes(userLang)) {
return userLang
}
// Default to Russian
return 'ru'
}
i18n
.use(HttpBackend)
.use(initReactI18next)
.init({
fallbackLng: 'ru',
lng: getInitialLanguage(),
detection: {
order: ['localStorage', 'navigator'],
caches: ['localStorage'],
},
backend: {
loadPath: '/assets/i18n/{{lng}}.json',
},
interpolation: {
escapeValue: false,
},
})
export default i18n
+1
View File
@@ -1,3 +1,4 @@
import './app/i18n/i18n'
import ReactDOM from 'react-dom/client'
import App from './app/App'
import './styles/index.scss'