ajithes1
ajithes1

Reputation: 427

React Native language change doesn't affect immediately

I'm using react-native-i18n in my project. After changing language to Arabic all text data are automatically aligned to the Right side of the screen properly. But all other components like Icons are aligning only after re-opening the app.

export function langSet(type){
    if(type == "en"){
    I18n.locale = type;
    const currentLocale = I18n.currentLocale();
    }else{
        I18n.locale = type;
        const currentLocale = I18n.currentLocale();
        ReactNative.I18nManager.allowRTL(true);
        ReactNative.I18nManager.forceRTL(true);
    }
}

Upvotes: 1

Views: 2053

Answers (1)

Ibrahim Khan
Ibrahim Khan

Reputation: 21

the language occurs only if u refresh your DOM, for this you should have to make a change state that will make the DOM to refresh, make a dumy state

state = { languageChange : false }

then after shifting language just below that run the state change as

this.setState({ languageChange: !this.state.languageChange ) }

Upvotes: 2

Related Questions