Java Code Examples for java.util.Locale.getScript()

The following are Jave code examples for showing how to use getScript() of the java.util.Locale class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ChessMaster   File: UTF8Control.java   View Source Code Vote up 6 votes
@Override
public String toBundleName(String baseName, Locale locale) {
	if (locale == Locale.ROOT) return baseName;

	String language = locale.getLanguage();
	String script = locale.getScript();
	String country = locale.getCountry();
	String variant = locale.getVariant();

	if (Objects.equals(language, "") && Objects.equals(country, "") && Objects.equals(variant, "")) return baseName;

	StringBuilder sb = new StringBuilder(baseName);
	if (!baseName.endsWith("/"))
		sb.append('_');
	if (!Objects.equals(script, "")) if (!Objects.equals(variant, ""))
		sb.append(language).append('_').append(script).append('_').append(country).append('_').append(variant);
	else if (!Objects.equals(country, ""))
		sb.append(language).append('_').append(script).append('_').append(country);
	else sb.append(language).append('_').append(script);
	else if (!Objects.equals(variant, ""))
		sb.append(language).append('_').append(country).append('_').append(variant);
	else if (!Objects.equals(country, "")) sb.append(language).append('_').append(country);
	else sb.append(language);
	return sb.toString();

}
 
Example 2
Project: configx   File: ConfigMessageSource.java   View Source Code Vote up 5 votes
protected List<String> calculateFilenamesForLanguageTag(String basename, Locale locale) {
    List<String> result = new ArrayList<String>(3);
    String language = locale.getLanguage();
    String script = locale.getScript();
    String country = locale.getCountry();

    StringBuilder temp = new StringBuilder(basename);

    temp.append('-');
    if (language.length() > 0) {
        temp.append(language);
        result.add(0, temp.toString());
    }

    temp.append('-');
    if (script.length() > 0) {
        temp.append(script);
        result.add(0, temp.toString());
    }

    if (country.length() > 0 && (language.length() > 0 || script.length() > 0)) {
        temp.append('-').append(country);
        result.add(0, temp.toString());
    }

    return result;
}
 
Example 3
Project: boohee_v5.6   File: ICUCompatApi23.java   View Source Code Vote up 5 votes
public static String maximizeAndGetScript(Locale locale) {
    try {
        return ((Locale) sAddLikelySubtagsMethod.invoke(null, new Object[]{locale})).getScript();
    } catch (InvocationTargetException e) {
        Log.w(TAG, e);
        return locale.getScript();
    } catch (IllegalAccessException e2) {
        Log.w(TAG, e2);
        return locale.getScript();
    }
}