0

При сборке вебпака не находит файл translation.json. До добавления вебпака все работало.

bundle.js:75 i18next::backendConnector: loading namespace translation for language en failed failed loading /locales/en/translation.json; status code: 404

i18n.ts

import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';

import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';

i18n

   .use(Backend)
   .use(LanguageDetector)
   .use(initReactI18next)
   .init({
      fallbackLng: false,
      debug: true,

      interpolation: {
         escapeValue: false,
      }
   });


export default i18n;

путь к файлам с переводами /public/locales/(en/ru)/translation.json

1 ответ 1

0

Попробуйте вот так:

import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';

import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';

i18n

   .use(Backend)
   .use(LanguageDetector)
   .use(initReactI18next)
   .init({
      fallbackLng: false,
      debug: true,

      interpolation: {
         escapeValue: false,
      },
      backend: {
          loadPath: 'locales/{{lng}}/{{ns}}.json'
      },
   });


export default i18n;

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.