React-native-i18n: Cannot read property 'getLanguages' of undefined

Created on 11 Oct 2017  路  4Comments  路  Source: AlexanderZaytsev/react-native-i18n

My code is from the demo

import React, { Component } from 'react';
import {
    Text
} from 'react-native';
import I18n from 'react-native-i18n';

class Demo extends React.Component {
    render() {
    return (
      <Text>{I18n.t('greeting')}</Text>
    );
  }
}

// Enable fallbacks if you want `en-US` and `en-GB` to fallback to `en`
I18n.fallbacks = true;

I18n.translations = {
  en: {
    greeting: 'Hi!'
  },
  fr: {
    greeting: 'Bonjour!'
  }
};

export default Demo;

I am getting
simulator screen shot - iphone 6s - 2017-10-11 at 19 40 40
Thank you in advance! :)

Most helpful comment

@SvetoslavSlavov Is the package correctly linked?

All 4 comments

I think you need to install react-native-i18n as well as ex-react-native-i18n

@SvetoslavSlavov Is the package correctly linked?

I got this error when I forgot to restart the app after installing and linking the package. Solved by running again.

It Worked perfectly for a long time.I'm experiencing g this error suddenly. How to resolve this

Was this page helpful?
0 / 5 - 0 ratings