本文整理汇总了Java中com.ibm.icu.util.ULocale.getLanguage方法的典型用法代码示例。如果您正苦于以下问题:Java ULocale.getLanguage方法的具体用法?Java ULocale.getLanguage怎么用?Java ULocale.getLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.ibm.icu.util.ULocale
的用法示例。
在下文中一共展示了ULocale.getLanguage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCodesFromLocale
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private static int[] getCodesFromLocale(ULocale locale) {
// Multi-script languages, equivalent to the LocaleScript data
// that we used to load from locale resource bundles.
String lang = locale.getLanguage();
if(lang.equals("ja")) {
return new int[] { UScript.KATAKANA, UScript.HIRAGANA, UScript.HAN };
}
if(lang.equals("ko")) {
return new int[] { UScript.HANGUL, UScript.HAN };
}
String script = locale.getScript();
if(lang.equals("zh") && script.equals("Hant")) {
return new int[] { UScript.HAN, UScript.BOPOMOFO };
}
// Explicit script code.
if(script.length() != 0) {
int scriptCode = UScript.getCodeFromName(script);
if(scriptCode != UScript.INVALID_CODE) {
if(scriptCode == UScript.SIMPLIFIED_HAN || scriptCode == UScript.TRADITIONAL_HAN) {
scriptCode = UScript.HAN;
}
return new int[] { scriptCode };
}
}
return null;
}
示例2: getCaseLocale
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
static final int getCaseLocale(ULocale locale, int[] locCache) {
int result;
if(locCache!=null && (result=locCache[0])!=LOC_UNKNOWN) {
return result;
}
result=LOC_ROOT;
String language=locale.getLanguage();
if(language.equals("tr") || language.equals("tur") || language.equals("az") || language.equals("aze")) {
result=LOC_TURKISH;
} else if(language.equals("el") || language.equals("ell")) {
result=LOC_GREEK;
} else if(language.equals("lt") || language.equals("lit")) {
result=LOC_LITHUANIAN;
}
if(locCache!=null) {
locCache[0]=result;
}
return result;
}
示例3: getAllowedHourFormats
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
private void getAllowedHourFormats(ULocale uLocale) {
// key can be either region or locale (lang_region)
// ZW{
// allowed{
// "h",
// "H",
// }
// preferred{"h"}
// }
// af_ZA{
// allowed{
// "h",
// "H",
// "hB",
// "hb",
// }
// preferred{"h"}
// }
ULocale max = ULocale.addLikelySubtags(uLocale);
String country = max.getCountry();
if (country.isEmpty()) {
country = "001";
}
String langCountry = max.getLanguage() + "_" + country;
String[] list = LOCALE_TO_ALLOWED_HOUR.get(langCountry);
if (list == null) {
list = LOCALE_TO_ALLOWED_HOUR.get(country);
if (list == null) {
list = LAST_RESORT_ALLOWED_HOUR_FORMAT;
}
}
allowedHourFormats = list;
}
示例4: isValid
import com.ibm.icu.util.ULocale; //导入方法依赖的package包/类
public boolean isValid(ULocale locale, Where where) {
where.set(null, null);
final String language = locale.getLanguage();
final String script = locale.getScript();
final String region = locale.getCountry();
final String variantString = locale.getVariant();
final Set<Character> extensionKeys = locale.getExtensionKeys();
// if (language.isEmpty()) {
// // the only case where this is valid is if there is only an 'x' extension string
// if (!script.isEmpty() || !region.isEmpty() || variantString.isEmpty()
// || extensionKeys.size() != 1 || !extensionKeys.contains('x')) {
// return where.set(Datatype.x, "Null language only with x-...");
// }
// return true; // for x string, wellformedness = valid
// }
if (!isValid(Datatype.language, language, where)) {
// special case x
if (language.equals("x")) {
where.set(null, null); // for x, well-formed == valid
return true;
}
return false;
}
if (!isValid(Datatype.script, script, where)) return false;
if (!isValid(Datatype.region, region, where)) return false;
if (!variantString.isEmpty()) {
for (String variant : SEPARATOR.split(variantString)) {
if (!isValid(Datatype.variant, variant, where)) return false;
}
}
for (Character c : extensionKeys) {
try {
Datatype datatype = Datatype.valueOf(c+"");
switch (datatype) {
case x:
return true; // if it is syntactic (checked by ULocale) it is valid
case t:
case u:
if (!isValidU(locale, datatype, locale.getExtension(c), where)) return false;
break;
}
} catch (Exception e) {
return where.set(Datatype.illegal, c+"");
}
}
return true;
}