小编use*_*227的帖子

反应 i18next 抛出翻译器缺少翻译和 useTranslation() 挂钩不起作用

我正在设置react-i18n-next 钩子来翻译我的应用程序,我按照react-i18n-next使用的示例进行操作,但它抛出如下错误:

i18next::translator: missingKey
en-US
translation
Run Code Online (Sandbox Code Playgroud)

应用程序.js

import React, { Component, Suspense } from "react";
import { useTranslation, withTranslation, Trans } from "react-i18next";

// use hoc for class based components
class LegacyWelcomeClass extends Component {
  render() {
    const { t } = this.props;
    return <h2>{t("title")}</h2>;
  }
}
const Welcome = withTranslation()(LegacyWelcomeClass);

// Component using the Trans component
function MyComponent() {
  return <Trans i18nKey="description.part1" />;
}

// page uses the hook
function Page() {
  const { t, i18n } = …
Run Code Online (Sandbox Code Playgroud)

i18next reactjs react-i18next

7
推荐指数
1
解决办法
2万
查看次数

标签 统计

i18next ×1

react-i18next ×1

reactjs ×1