0

我正在尝试使用 i18next 进行本地化,它可以很好地将英语文本翻译成阿拉伯语{t("title")} ==> مرحبا。但是,当我尝试将语言更改为英语时, const { t, i18n } = useTranslation() i18n.changeLanguage('en') 它并没有改变。如何解决这个问题。

我在服务器 vscode terimanl 收到了那个错误react-i18next:: You will need to pass in an i18next instance by using initReactI18next

4

1 回答 1

0

我在 nextjs Docs 找到了解决方案。似乎在 nextjs 更改语言环境与 reactjs 不同,调用i18n.changeLanguage('en'). 而是使用。

<Link href="/fr/another" locale="en">
  <a>To /fr/another</a>
</Link>

将完成这项工作。更多信息:https ://nextjs.org/docs/advanced-features/i18n-routing

于 2021-09-02T14:26:43.333 回答