EDIT
I'm porting my app to Arabic locale. I have some getString() with parameters like:
getString(R.string.distance, distance)
where <string name="distance">%1d km</string>
The requirement is that in Arabic I should show it like this: "2.3 كم".
If I set as the locale for Saudi Arabia (country = "sa") or UAE (country = "ae") the number are shown in Eastern-Arabic but my client wants them in Western-Arabic.
The solution here is to use Egypt as a country in the locale but this is not possible for me.
I tried:
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void setAppContextLocale(Locale savedLocale) {
Locale.Builder builder = new Locale.Builder();
builder.setLocale(savedLocale).setExtension(Locale.UNICODE_LOCALE_EXTENSION, "nu-latn");
Locale locale = builder.build();
Configuration config = new Configuration();
config.locale = locale;
config.setLayoutDirection(new Locale(savedLocale.getLanguage()));
mAppContext.getResources().updateConfiguration(config, mContext.getResources().getDisplayMetrics());
}
as suggested in this question but after that the country is ignored so both SA and AE locales use the strings in the default file.