response-i18next получение ошибки Ошибка попытки импорта - PullRequest
0 голосов
/ 17 июня 2020

Я пытался использовать https://react.i18next.com/ Для локализации и получаю сообщение об ошибке: Ошибка при попытке импорта: «initReactI18next» не экспортируется из «response-i18next».

Это мой i18n. js файл:

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

import Backend from 'i18next-http-backend';
import LanguageDetector from 'i18next-browser-languagedetector';
// not like to use this?
// have a look at the Quick start guide 
// for passing in lng and translations on init

i18n
  // load translation using http -> see /public/locales (i.e. https://github.com/i18next/react-i18next/tree/master/example/react/public/locales)
  // learn more: https://github.com/i18next/i18next-http-backend
  .use(Backend)
  // detect user language
  // learn more: https://github.com/i18next/i18next-browser-languageDetector
  .use(LanguageDetector)
  // pass the i18n instance to react-i18next.
  .use(initReactI18next)
  // init i18next
  // for all options read: https://www.i18next.com/overview/configuration-options
  .init({
    fallbackLng: 'en',
    debug: true,

    interpolation: {
      escapeValue: false, // not needed for react as it escapes by default
    }
  });


export default i18n;

Мой пакет. json

{"name": "heatmann", "version": "0.1.0", "private": true,
"dependencies": {"ax ios": "^ 0.19.0", "i18next": "^ 19.4.5", "i18next-browser-languagedetector": "^ 4.3 .0 "," i18next-http-backend ":" ^ 1.0.15 "," i18next-xhr-backend ":" ^ 3.2.2 "," prop-types ":" ^ 15.7.2 "," proptypes " : "^ 1.1.0", "react": "^ 16.12.0", "react-alice-carousel": "^ 1.17.2", "react-dom": "^ 16.12.0", "react- i18next ":" ^ 9.0.10 "," react-loader-spinner ":" ^ 3.1.5 "," react-native-gesture-handler ":" ^ 1.5.2 "," react-navigation ":" ^ 4.0.10 "," response-navigation-stack ":" ^ 1.10.3 "," react-router-dom ":" ^ 5.1.2 "," react-scripts ":" ^ 3.3.0 "}," scripts ": {" start ":" start-scripts start "," build ":" react-scripts build "," test ":" response-scripts test "," eject ":" response-scripts eject "} , "eslintConfig": {"extends": "react-app"}, "browserslist": {"production": ["> 0,2%", "not dead", "not op_mini all"], "development": [ "последняя 1 chrome версия", "последняя 1 firefox версия", "последняя 1 версия сафари"]}, "devDependencies": {"@ babel / plugin-offer-export-default-from": "^ 7.8 .3 "," css -загрузчик ":" ^ 3.4.2 "}}

1 Ответ

0 голосов
/ 18 июня 2020

Пакет удален. json записи с i18next. Удалена вся папка node_modules Переустановлена ​​npm install npm install response-i18next i18next --save // ​​когда нужно определить язык пользователя и загрузить перевод npm установить i18next-http-backend i18next-browser-languagedetector --save

Это решило мою проблему.

...