Is possible to set only default English language of application in android

3.3k views Asked by At

I only want set only default English language of application in android.

After Supporting Different Languages, I also use values/strings.xml to store characters in that file.

If in English language mode of System Settings, I can show correct words.

If in Chinese language mode of System Settings, The English words was translated to Chinese.

I don't want it translate automatically.

People who know how to set only default English language,

Please help me.

Thanks,

2

There are 2 answers

1
Huy Tower On BEST ANSWER

I can get correct answer now via the codes in below :

public static void setDefaultLanguage(Context context, String lang) {
    Locale locale = new Locale(lang);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    context.getResources().updateConfiguration(config,
            context.getResources().getDisplayMetrics());
}

In that, what is lang value? You should get correct Language System to pass this value to lang parameter.

Thanks,

0
Social_Engineerer On

Are you storing all the strings for both languages in one .xml? If so that is probably your issue…

res/values/strings.xml Contains English text for all the strings that the application uses,

res/values-ja/strings.xml - for japanese, but I am sure you can find one for the language you are looking for! Android looks for the "values-ja" tag.