amos amos - 17 days ago 6
Android Question

react native, set Android os default lang

I am using react-native

v0.36
, and i am building react-native mobile app targeting iOS & Android.

If users have default language of
RTL
, my app looks bad on android. In order for it to look good on Android, i need the app to be open in
en-us
Language only (
LTR
language), no matter what is the Android default language.

Answer

got it! i needed to force LTR on an RTL OS. so i used "allowRTL"

in the android/app/src/main/java/com/[app name]/MainApplication.java i added "onCreate"

import com.facebook.react.modules.i18nmanager.I18nUtil;

@Override
public void onCreate() {
    super.onCreate();

    // FORCE LTR
    I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
    sharedI18nUtilInstance.allowRTL(getApplicationContext(), false);
    ....
}

look at: https://codedump.io/share/UvXEpMY9phKS/1/rtl-is-forced-in-rtl-devices

Comments