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