From d0a0db5c757239e0cd38e65f0033ad0446bd63cd Mon Sep 17 00:00:00 2001 From: gnezim Date: Mon, 6 Apr 2026 09:58:45 +0300 Subject: [PATCH] revert to http backend for i18n loading; static imports not working properly --- apps/react/src/app/i18n/i18n.ts | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/apps/react/src/app/i18n/i18n.ts b/apps/react/src/app/i18n/i18n.ts index ff9bf012c..70d158bd8 100644 --- a/apps/react/src/app/i18n/i18n.ts +++ b/apps/react/src/app/i18n/i18n.ts @@ -1,6 +1,6 @@ import i18n from 'i18next' +import HttpBackend from 'i18next-http-backend' import { initReactI18next } from 'react-i18next' -import { translations } from './translations' // Language detection logic const getInitialLanguage = (): string => { @@ -29,37 +29,19 @@ const getInitialLanguage = (): string => { return 'ru' } -// Flatten nested JSON structure -const flattenTranslations = (obj: any, prefix = ''): any => { - const result: any = {} - for (const [key, value] of Object.entries(obj)) { - const fullKey = prefix ? `${prefix}.${key}` : key - if (typeof value === 'object' && value !== null && !Array.isArray(value)) { - Object.assign(result, flattenTranslations(value, fullKey)) - } else { - result[fullKey] = value - } - } - return result -} - const lng = getInitialLanguage() -// Build resources object with static translations -const resources: Record = {} -for (const [lang, translationData] of Object.entries(translations)) { - resources[lang] = { translation: flattenTranslations(translationData as any) } -} - -// Initialize i18next with bundled translations i18n + .use(HttpBackend) .use(initReactI18next) .init({ fallbackLng: 'ru', lng, defaultNS: 'translation', ns: ['translation'], - resources, + backend: { + loadPath: '/assets/i18n/{{lng}}.json', + }, interpolation: { escapeValue: false, },