Setting Arabic numbering system locale doesn't show Arabic numbers
YES, I did it! After reading Locale
's JavaDoc carefully, I was able to produce the required locale:
Locale arabicLocale = new Locale.Builder().setLanguageTag("ar-SA-u-nu-arab").build();
which is equivalent to:
Locale arabicLocale = new Locale.Builder().setLanguage("ar").setRegion("SA")
.setExtension(Locale.UNICODE_LOCALE_EXTENSION, "nu-arab").build();
Note that I am using something called (Unicode locale/language extension):
UTS#35, "Unicode Locale Data Markup Language" defines optional attributes and keywords to override or refine the default behavior associated with a locale. A keyword is represented by a pair of key and type.
The keywords are mapped to a BCP 47 extension value using the extension key 'u' (UNICODE_LOCALE_EXTENSION).
The extension key for numbers is (nu
) and the value I used is (arab
).
You can see a list of all extension keys here.