react-native-i18n: I18n breaks React-Native Android Apps

Hi Using react-native-i18n in an React-Native Android app breaks it with the following error:

undefined is not an object (evaluating 'RNI18n.locale')

Since Ract-Native Android is now open-sourced and this is currently the defacto i18n component for react-native it would be great if you guys could fix this soon.

Thank you Bernd

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 4
  • Comments: 18 (3 by maintainers)

Most upvoted comments

I needed to add the following into the MainApplication.java under app/src/main/com/your-app/MainApplication.java

    @Override
    protected List<ReactPackage> getPackages() {
      return Arrays.<ReactPackage>asList(
        ...
        new ReactNativeI18n()
      );
    }

and also import the package at the top of the file:

import com.i18n.reactnativei18n.ReactNativeI18n;

I got this working with manual install instructions (https://github.com/AlexanderZaytsev/react-native-i18n#android). Linking with rnpm link react-native-i18n worked only with iOS.

the problem is that these lines are missing in the settings.gradle file include ':react-native-i18n' project(':react-native-i18n').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-i18n/android')

Had same issue. In some reason if the module is installed using rnpm:

rnpm install react-native-i18n

it has problems with RNI19n.locale. After reinstalling module using:

npm install react-native-i18n --save rnpm link react-native-i18n

everyting works. At least on Android emulator