【发布时间】:2018-05-17 03:17:10
【问题描述】:
我使用 create-react-app-ts 创建了一个新的 React 应用程序。添加 i18n 的最佳选择是什么?
我查看了 react-intl,但它看起来很重。然后我查看了 linguiJS,它承诺会使其更容易,但我找不到如何将它与 create-react-app 一起使用的示例。此外,我不确定在一个模块中同时包含格式(数字等)、复数和翻译是否是一个好主意...我更喜欢使用单独的库...
请分享您的想法。在 React 应用程序中获得 i18n 的最佳(最简单/最漂亮)方法是什么。
谢谢
【问题讨论】:
-
你看过github.com/i18next/react-i18next了吗?!?与 cra 一起运行,因为对 babel 没有任何更改,需要 webpack...基于 i18next
-
加上格式你可以选择你喜欢的...甚至自定义格式...
-
@jamuhl 您能否提供一个示例/链接如何将 i18next 与 redux 和连接的组件一起使用。我应该使用 HOC 方法吗?
-
您可以同时使用... translate hoc (react.i18next.com/components/translate-hoc.html) 或 i18n 渲染道具 (react.i18next.com/components/i18n-render-prop.html)。有/没有redux没有区别...github.com/i18next/react-i18next/tree/master/example
-
我在你的例子中没有看到任何 redux...!
标签: javascript reactjs internationalization create-react-app