React-native-i18n: Translation not updating navigationOptions when changing language

Created on 29 Aug 2018  路  4Comments  路  Source: AlexanderZaytsev/react-native-i18n

navigationOptions can not update language,why?
Who has the same problem?
title锛孉lways show English

static navigationOptions = {
title:I18n.t('title'),
};

Most helpful comment

If you use

navigationOptions: {
  title: i18n.t('home')
}

it will not update when change language, but if you create function instead of return object

navigationOptions: () => ({
  title: i18n.t('home')
})

it will update

All 4 comments

You try import and change language in Root Component, and then child component update a language.

Ok, I would recomend to do something like this:

<Button onClick={ () => {
    ...
    this.props.navigation.setParams({ refresh: true });
    }
/>


tl;dr: It doesn't seem to have a big difference, if you pass same value all the time.

If you use

navigationOptions: {
  title: i18n.t('home')
}

it will not update when change language, but if you create function instead of return object

navigationOptions: () => ({
  title: i18n.t('home')
})

it will update

If you use

navigationOptions: {
  title: i18n.t('home')
}

it will not update when change language, but if you create function instead of return object

navigationOptions: () => ({
  title: i18n.t('home')
})

it will update

You are superman. Thanks a lot. :D

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sibelius picture sibelius  路  4Comments

tregismoreira picture tregismoreira  路  7Comments

timgcarlson picture timgcarlson  路  5Comments

wyzzy picture wyzzy  路  5Comments

tonygentilcore picture tonygentilcore  路  4Comments