The Serbian language has Latin and Cyrillic alphabets. In Android's Date and Time Picker widgets, the displayed alphabet for Serbian locales seems to be Cyrillic, as seen here.
I wanted to change the locale so that the android widgets are using the Latin Serbian alphabet.
The current language/country code (yielding Cyrillic) are sr
and RS
respectively. Therefore, my setLocale function is called as
setLocale("sr", "RS");
This is the part im not sure about - according to localeplanet.com, the local code for latin serbian is sr_Latn_RS
. However, I tried both
setLocale("sr_Latn", "RS"); //and setLocale("sr_Latn_RS", "RS");
neither of which work (no change occurs, default to english). According to the Android documentation, it looks like setLocale expects two letter codes.
The language codes are two-letter lowercase ISO language codes (such as "en") as defined by ISO 639-1. The country codes are two-letter uppercase ISO country codes (such as "US") as defined by ISO 3166-1. The variant codes are unspecified.
So how do I specify Cyrllic serbian?
2 Answers
Answers 1
Please search for your query before posting a question. It may be answered in some other related form.
i found these two answers suitable to your query android custom date-picker SO and locale from english to french.
Answers 2
Can you please use below one ?
public class MyApplication extends Application { @Override public void onCreate() { super.onCreate(); Resources res = this.getResources(); Configuration conf = res.getConfiguration(); boolean isLatinAlphabet = PreferenceManager.getDefaultSharedPreferences(this); if(conf.locale.getLanguage().equals("sr") && isLatinAlphabet) { conf.locale = new Locale("sr", "YourContryCode"); res.updateConfiguration(conf, res.getDisplayMetrics()); } } }
Note: Replace your YourContryCode
in conf.locale = new Locale("sr", "YourContryCode");
line.
Manifest.xml:
<application android:name=".MyApplication" android:icon="@drawable/ic_launcher" android:label="@string/application_name" android:theme="@style/AppTheme"> ... </application>
Hope this will help you.