React Native 多翻译

React Native Multi-Transtation

在我的项目中,我需要让用户select一种想要的语言,从而将项目中的所有文本更改为他要求的语言。

我很想知道 React Native 中是否有推荐的库可以完成这项工作。

有很多类似的库,称为 i18n~ 等,我可以建议 react-i18next it's very simple in configuration and usage, especially with useTranslation hook and they have a good react-native example here. You obviously need to add translation files to you project with language translations that you will support. You can use this with some libraries that allow you to save data to persistent-store, as AsyncStorage or EncryptedStorage 以便将用户语言偏好全局保存到整个应用程序。