當前位置: 首頁>>代碼示例>>Java>>正文


Java Locale.getISOLanguages方法代碼示例

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

}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:23,代碼來源:BLValidator.java

示例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!");
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:19,代碼來源:LocaleTest.java

示例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!");
    }

}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:21,代碼來源:Bug6275682.java

示例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!");
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:21,代碼來源:LocaleTest.java

示例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;
}
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:16,代碼來源:LocaleConfigurer.java

示例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;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:10,代碼來源:OperatorServiceLocalBean.java

示例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;
}
 
開發者ID:servicecatalog,項目名稱:oscm,代碼行數:10,代碼來源:LocaleUtils.java


注:本文中的java.util.Locale.getISOLanguages方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。