Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent change numbers localization when change android language localization

Tags:

I want to change android application localization Arabic - English.
but when I change language to Arabic it's changed all numbers to Arabic so the app crashed I want to change language to Arabic and prevent change numbers language from English.

 Locale locale = new Locale(AppConfig.Language);
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = "ar";
    getBaseContext().getResources().updateConfiguration(config,
            getBaseContext().getResources().getDisplayMetrics());
    setContentView(R.layout.activity_main);

when I want to use gps get location it's return numbers in arabic how I can prevent it to change numbers language ??

like image 714
Omar Avatar asked Mar 20 '16 07:03

Omar


People also ask

How do I change localization in Android?

You'll find this screen either in the System Settings app: Languages, or System Settings: System: Languages and input. The Language preference screen should contain one entry called “English (Europe)”. Click Add language and add a fallback language.

How do you implement internationalization and localization in an Android application?

In order to localize the strings used in your application , make a new folder under res with name of values-local where local would be the replaced with the region. Once that folder is made, copy the strings. xmlfrom default folder to the folder you have created. And change its contents.


1 Answers

I know this answer is too late but it can help someone in the future. I was struggling with it for some days but I found an easy solution. just set the country as the second parameter.because some countries use Arabic numeral and others use the so-called Hindu Numerals

Locale locale = new Locale(LanguageToLoad,"MA");//For Morocco to use 0123...

or

Locale locale = new Locale(LanguageToLoad,"SA");//For Saudi Arabia to use ٠١٢٣...
like image 126
Jwdsoft Avatar answered Sep 19 '22 15:09

Jwdsoft