简体   繁体   English

react-intl 变成 formatJs,如何在 react-native 中重新添加本地数据

[英]react-intl become formatJs , how re-addlocaledata in react-native

I use react-intl for internationalization and in a component i get and set the locale-data like that:我使用 react-intl 进行国际化,并在一个组件中获取并设置这样的语言环境数据:

import fr from 'react-intl/locale-data/fr';
import en from 'react-intl/locale-data/en';
...  
addLocaleData([...fr, ...en]);

But the library to migrate to formatJs and I don't see how to do the same with the new syntax or if I need to install something else.但是要迁移到 formatJs 的库,我看不到如何使用新语法或是否需要安装其他东西。
If someone has an idea??如果有人有想法?

This should fix your issue: https://formatjs.io/docs/react-intl/upgrade-guide-3x#migrate-to-using-native-intl-apis For react-native you'd need a bunch of polyfills from https://formatjs.io/docs/polyfills :这应该可以解决您的问题: https://formatjs.io/docs/react-intl/upgrade-guide-3x#migrate-to-using-native-intl-apis对于 react-native,您需要一堆来自 Z5BBA56C5050DDC8 的polyfill: //formatjs.io/docs/polyfills :

  • Intl.getCanonicalLocales
  • Intl.PluralRules
  • Intl.NumberFormat
  • Intl.DateTimeFormat
  • Intl.RelativeTimeFormat

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM