dev
dev

Reputation: 461

android language folder for two different language

I have two languages in my app. English and urdu. I have created two folder for strings.xml.
1.values( Default for English)
2.values-ar (for urdu)

Now when I set Locale for english it is working fine in phone and tablet. But when I set locale to urdu and then in phone it is showing urdu text but in tablet it is showing english.

Please explain why this is happening. As per my understanding application should pick string on the base of locale set.

Here they haven't specified anything about phone and tablet

Thanks.

Upvotes: 1

Views: 901

Answers (2)

Anggrayudi H
Anggrayudi H

Reputation: 15165

Try to define the localization with this code:

Locale locale = new Locale("ar_UR");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, 
        getBaseContext().getResources().getDisplayMetrics());

Your resource folder (values-ar) is not wrong, you just need to define the code above. If "ar_UR" wont work, try to find the localization code in Google. The format is:

ar = country code (lowercase text)

_ = separator from this two code

UR = language code (UPPERCASE text)

Upvotes: 0

Seven
Seven

Reputation: 375

ar is for Arabic language.

Try using values-ur for urdu

Upvotes: 1

Related Questions