Android – how to change the locale to use Latin Serbian (not Cyrillic Serbian)

setLocale("sr", "RS");

setLocale("sr_Latn", "RS");
//and
setLocale("sr_Latn_RS", "RS");

resolvent:

private static Locale serbianLatinLocale(){

    Locale locale = null;
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        for (Locale checkLocale : Locale.getAvailableLocales()) {
            if (checkLocale.getISO3Language().equals("srp") && checkLocale.getCountry().equals("LATN") && checkLocale.getVariant().equals("")) {
                locale = checkLocale;
            }
        }
    } else {
        locale = new Locale.Builder().setLanguage("sr").setRegion("RS").setScript("Latn").build();
    }

    return locale;
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>