1

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,

Huy Tower
  • 7,769
  • 16
  • 61
  • 86
  • 2
    so, delete `/res/values-zh` and only leave `/res/values`, where you have your strings.xml in English. – Phantômaxx Jun 20 '14 at 09:31
  • `delete /res/values-zh and only leave /res/values` I only have `/res/values` folder. English words in `res/values/strings.xml` – Huy Tower Jun 20 '14 at 09:51
  • 1
    So where are the Chinese words stored? The app will translate only if you have a `/res/values-XY[-ZK]` folder with a strings.xml in it. AT WORST (but it's not a best practice), you can try to copy `/res/values` as `/res/values-zh`. This way, it will look for the Chinese words in that folder's strings.xml and will display the English strings stored in it. But this is just a **hack-ish** workaround. – Phantômaxx Jun 20 '14 at 09:58
  • Ah i mean I change in `System Settings -> Language & Input`, choose `Chinese language`. Therefore, my app will automatically changed followed chose option. – Huy Tower Jun 20 '14 at 10:04
  • Yes, it's meant to work like that. – Phantômaxx Jun 20 '14 at 10:06
  • ` it will look for the Chinese words in that folder's strings.xml and will display the English strings stored in it` I see this life cycle. You are right. So if I stored in `Java file` class. It shoule be translated or not? I saw some words was translated, the others is not. – Huy Tower Jun 20 '14 at 10:10
  • `So if I stored in Java file class. It shoule be translated or not?` It depends on how YOU handle those words. Wouldn't it be better if you let Android decide which is the best word set to use, depending on the system language (or depending on a sored value in your preferences)? – Phantômaxx Jun 20 '14 at 10:14

2 Answers2

1

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,

Huy Tower
  • 7,769
  • 16
  • 61
  • 86
  • Have you got any idea how it was changing the strings to other language even if you don't specify other strings.xml for other values – Akhil Dad May 11 '15 at 09:36
0

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.