本文整理汇总了Java中java.util.Locale.getScript方法的典型用法代码示例。如果您正苦于以下问题:Java Locale.getScript方法的具体用法?Java Locale.getScript怎么用?Java Locale.getScript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Locale
的用法示例。
在下文中一共展示了Locale.getScript方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toBundleName
import java.util.Locale; //导入方法依赖的package包/类
@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();
}
示例2: calculateFilenamesForLanguageTag
import java.util.Locale; //导入方法依赖的package包/类
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;
}
示例3: maximizeAndGetScript
import java.util.Locale; //导入方法依赖的package包/类
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();
}
}