diff --git a/apps/react/src/app/i18n/i18n.ts b/apps/react/src/app/i18n/i18n.ts index e8122a898..ff9bf012c 100644 --- a/apps/react/src/app/i18n/i18n.ts +++ b/apps/react/src/app/i18n/i18n.ts @@ -1,5 +1,6 @@ import i18n from 'i18next' import { initReactI18next } from 'react-i18next' +import { translations } from './translations' // Language detection logic const getInitialLanguage = (): string => { @@ -43,17 +44,14 @@ const flattenTranslations = (obj: any, prefix = ''): any => { } const lng = getInitialLanguage() -const supportedLanguages = ['ru', 'en', 'es', 'fr', 'it', 'ja', 'ko', 'de', 'zh'] -// Build resources object by fetching all language files +// Build resources object with static translations const resources: Record = {} - -// Pre-populate with empty resources to avoid warnings -for (const lang of supportedLanguages) { - resources[lang] = { translation: {} } +for (const [lang, translationData] of Object.entries(translations)) { + resources[lang] = { translation: flattenTranslations(translationData as any) } } -// Initialize i18next with empty resources +// Initialize i18next with bundled translations i18n .use(initReactI18next) .init({ @@ -70,26 +68,4 @@ i18n }, }) -// Load and add translations asynchronously -const loadAllTranslations = async () => { - for (const lang of supportedLanguages) { - try { - const response = await fetch(`/assets/i18n/${lang}.json`) - if (response.ok) { - const data = await response.json() - const flattened = flattenTranslations(data) - // Use addResourceBundle to add the translations AFTER initialization - i18n.addResourceBundle(lang, 'translation', flattened, true, true) - } - } catch (error) { - console.error(`[i18n] Error loading ${lang}:`, error) - } - } -} - -loadAllTranslations().then(() => { - // Change language after all translations are loaded - i18n.changeLanguage(lng) -}) - export default i18n