react-intl 变成 formatJs ,如何在 react-native 中重新添加 localedata
react-intl become formatJs , how re-addlocaledata in react-native
我使用 react-intl 进行国际化,在一个组件中我获取并设置了语言环境数据
像那样:
import fr from 'react-intl/locale-data/fr';
import en from 'react-intl/locale-data/en';
...
addLocaleData([...fr, ...en]);
但是要迁移到 formatJs 的库,我不知道如何使用新语法做同样的事情,或者我是否需要安装其他东西。
如果有人有想法??
这应该可以解决您的问题:https://formatjs.io/docs/react-intl/upgrade-guide-3x#migrate-to-using-native-intl-apis
对于 react-native,你需要一堆来自 https://formatjs.io/docs/polyfills:
的 polyfill
Intl.getCanonicalLocales
Intl.PluralRules
Intl.NumberFormat
Intl.DateTimeFormat
Intl.RelativeTimeFormat
我使用 react-intl 进行国际化,在一个组件中我获取并设置了语言环境数据 像那样:
import fr from 'react-intl/locale-data/fr';
import en from 'react-intl/locale-data/en';
...
addLocaleData([...fr, ...en]);
但是要迁移到 formatJs 的库,我不知道如何使用新语法做同样的事情,或者我是否需要安装其他东西。
如果有人有想法??
这应该可以解决您的问题:https://formatjs.io/docs/react-intl/upgrade-guide-3x#migrate-to-using-native-intl-apis 对于 react-native,你需要一堆来自 https://formatjs.io/docs/polyfills:
的 polyfillIntl.getCanonicalLocales
Intl.PluralRules
Intl.NumberFormat
Intl.DateTimeFormat
Intl.RelativeTimeFormat