本文整理汇总了Java中java.util.Locale.getISOLanguages方法的典型用法代码示例。如果您正苦于以下问题:Java Locale.getISOLanguages方法的具体用法?Java Locale.getISOLanguages怎么用?Java Locale.getISOLanguages使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Locale
的用法示例。
在下文中一共展示了Locale.getISOLanguages方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isLocaleSupported
import java.util.Locale; //导入方法依赖的package包/类
private static void isLocaleSupported(String member, String value)
throws ValidationException {
if (value == null || value.trim().length() == 0) {
return;
}
boolean invalidLocale = true;
String[] locales = Locale.getISOLanguages();// .getAvailableLocales();
for (String locale : locales) {
if (locale.equals(value)) {
invalidLocale = false;
break;
}
}
if (invalidLocale) {
ValidationException vf = new ValidationException(
ReasonEnum.INVALID_LOCALE, member, new Object[] { value });
logValidationFailure(vf);
throw vf;
}
}
示例2: Test4126880
import java.util.Locale; //导入方法依赖的package包/类
/**
* @bug 4126880
*/
void Test4126880() {
String[] test;
test = Locale.getISOCountries();
test[0] = "SUCKER!!!";
test = Locale.getISOCountries();
if (test[0].equals("SUCKER!!!"))
errln("Changed internal country code list!");
test = Locale.getISOLanguages();
test[0] = "HAHAHAHA!!!";
test = Locale.getISOLanguages();
if (test[0].equals("HAHAHAHA!!!")) // Fixed typo
errln("Changes internal language code list!");
}
示例3: main
import java.util.Locale; //导入方法依赖的package包/类
public static void main (String[] args) throws Exception {
Locale es = new Locale ("es");
String[] isoLangs = es.getISOLanguages ();
String error = "";
for (int i = 0; i < isoLangs.length; i++) {
Locale current = new Locale (isoLangs[i]);
String localeString = current.getDisplayLanguage (es);
String startLetter = localeString.substring (0,1);
if (!startLetter.toLowerCase (es).equals (startLetter)){
error = error + "\n\t"+ isoLangs[i] + " " + localeString;
}
}
if (error.length () > 0){
throw new Exception ("\nFollowing language names starts with upper-case letter: "
+ error + "\nLower-case expected!");
}
}
示例4: Test4126880
import java.util.Locale; //导入方法依赖的package包/类
/**
* @bug 4126880
*/
void Test4126880() {
String[] test;
test = Locale.getISOCountries();
test[0] = "SUCKER!!!";
test = Locale.getISOCountries();
if (test[0].equals("SUCKER!!!")) {
errln("Changed internal country code list!");
}
test = Locale.getISOLanguages();
test[0] = "HAHAHAHA!!!";
test = Locale.getISOLanguages();
if (test[0].equals("HAHAHAHA!!!")) { // Fixed typo
errln("Changes internal language code list!");
}
}
示例5: getLanguageList
import java.util.Locale; //导入方法依赖的package包/类
protected String[] getLanguageList() {
if (languageList == null) {
String[] langs = Locale.getISOLanguages();
ArrayList<String> sortedLangs = new ArrayList<String>();
for (int i = 0; i < langs.length; i++) {
String lang =
(new Locale(langs[i])).getDisplayLanguage(Locale.getDefault());
languages.put(lang, langs[i]);
sortedLangs.add(lang);
}
Collections.sort(sortedLangs, Collator.getInstance(Locale.getDefault()));
languageList = sortedLangs.toArray(new String[sortedLangs.size()]);
}
return languageList;
}
示例6: checkLocale
import java.util.Locale; //导入方法依赖的package包/类
private boolean checkLocale(String languageISOCode) {
String[] locales = Locale.getISOLanguages();
for (String l : locales) {
if (l.equalsIgnoreCase(languageISOCode)) {
return true;
}
}
return false;
}
示例7: isLocaleValid
import java.util.Locale; //导入方法依赖的package包/类
public static boolean isLocaleValid(String languageISOCode) {
String[] locales = Locale.getISOLanguages();
for (String l : locales) {
if (l.equalsIgnoreCase(languageISOCode)) {
return true;
}
}
return false;
}