本文整理匯總了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();
}
}