I want to support language change (manually by user). I'm using react-native-i18n for that. I found how to change the displayed language at run time but I didn't find how to update the current view.
Environment:
When I use I18n.locale ='en';
not in function.. just as it is, the text will be in English and when I use I18n.locale ='he';
the text will be in Hebrew.
However I need to change the language at run time. So I want that when I click each button the language will change and will be displayed.
Nothing happened.. I assume I need to reload / re-render / update the view but I didn't find how to.
You can try something like this
<View style={styles.container}>
<Button onPress={this.setLocale()} title={strings('test.b1')}>
</View>
public setLocale() {
this.setState({stateOfLocale: 'en'});
I18n.locale = stateOfLocale;
}
completely working! thank you, plus now I understands better how react native works
Great to hear that!