【问题标题】:react & i18next, why do i need react-i18nextreact & i18next,为什么我需要 react-i18next
【发布时间】:2017-11-16 15:36:37
【问题描述】:

我是 i18next 的新手,我真的不明白为什么在玩 react 时需要使用 react-i18next。

在我的组件中使用像 moment.js 这样的外部库:const date = moment(this.state.date)

我可以用 i18next 做类似下面的事情吗:

import i18next from 'i18next';

const translated = () => (
 <h1>{i18next.t('title')}</h1>
)

谢谢

【问题讨论】:

  • 仅供参考:可以在此处找到更新的 react-i18next 指南:dev.to/adrai/…

标签: reactjs i18next


【解决方案1】:

确定可以直接使用 i18next。 react-i18next 只是在反应中使用它的一些优化-> 例如。使用 hoc 或 render 属性重新渲染语言更改或命名空间的动态加载。或者允许您将反应组件嵌套到翻译中的 Trans 组件。但是没有魔法,就像 jquery-i18next 或 vue-i18next 没有魔法一样 -> 它只是简化了你的任务。

【讨论】:

    猜你喜欢
    • 2021-08-25
    • 2020-07-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-19
    • 1970-01-01
    • 1970-01-01
    • 2021-01-29
    相关资源
    最近更新 更多