React Native I18n

screenshot of React Native I18n
react-native

React Native I18n

React Native + i18n.js

Overview:

The react-native-i18n library is a deprecated package that integrates I18n.js with React Native, using the user's preferred locale as the default. It is recommended to use the react-native-localize library instead, in conjunction with I18n-js or other internationalization libraries such as react-intl or react-i18next.

Features:

  • Integration with I18n.js: Connects I18n.js with React Native for localization.
  • User Preferred Locale: Uses the user's preferred locale by default.
  • Multiple Location Files: Supports usage with multiple location files.
  • Fallbacks: Supports fallback language options for translations.
  • Device's Locales: Provides a method to retrieve the user's preferred locales.

Installation:

Using yarn:

$ yarn add react-native-i18n

Using npm:

$ npm install react-native-i18n --save

After installing the npm package, link the native modules automatically with the following commands based on your React-Native version:

  • For React-Native >= 0.29: react-native link react-native-i18n
  • For React-Native < 0.29: Install rnpm with npm install -g rnpm and then link with rnpm link

For manual setup on iOS, add RNI18n.xcodeproj to Libraries, libRNI18n.a to Link Binary With Libraries, and include localizations in Xcode project. For Android, specify the package in various Gradle files. Recompile the project with react-native run-android.

Summary:

The react-native-i18n library, now deprecated in favor of react-native-localize, serves as a bridge between I18n.js and React Native, leveraging the user's preferred locale. Installation involves linking native modules automatically or manually for both iOS and Android platforms. Fallbacks and support for multiple location files are key features of the library, enabling developers to handle translations efficiently.

react-native
React Native

React Native is a framework for building mobile applications using React and JavaScript. It enables developers to write once and deploy to multiple platforms, including iOS, Android, and the web, while providing a native app-like experience to users.