APISonar


java.util.Locale.getISOLanguages

> java > util > Locale > getISOLanguages
java APIs util APIs Locale APIs getISOLanguages APIs

Example 1
public void test_getISOLanguages() {
		// Test for method java.lang.String []
		// java.util.Locale.getISOLanguages()
		// Assumes always at least 131 ISOlanguages...
		String[] isoLang = Locale.getISOLanguages();
		assertTrue(isoLang.length >= 131);
	}
Example 2
public void testLanguageIsValid() {
        final String language = DEFAULT_LOCALE.getLanguage();
        if (!language.isEmpty()) {
            assertThat("Invalid language",
                Arrays.asList(Locale.getISOLanguages()), hasItem(language));
        }
    }
Example 3
public static String requestToResponseLangCode(String req) {
        if (locale_map == null) {
            String[] languages = Locale.getISOLanguages();
            locale_map = new HashMap<>(languages.length);
            for (String language : languages) {
                Locale locale = new Locale(language);
                locale_map.put(locale.getISO3Language(), locale);
            }
        }
        return locale_map.get(req).getLanguage();
    }
Example 4
private static Map<String,String> make_ISO639_map() {
    Map<String,String> map = new HashMap<>();
    for (String lang : Locale.getISOLanguages()) {
      Locale locale = new Locale(lang);
      map.put(locale.getISO3Language(), locale.getLanguage());
    }
    return map;
  }
Example 5
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!");
    }
Example 6
public static void checkLanguageCode(String code) {
    List<String> languageCodes  = new ArrayList<>();
    languageCodes.addAll(Arrays.asList(Locale.getISOLanguages()));
    languageCodes.add("x-unspecified");

    if (!languageCodes.contains(code)) {
      throw new TerminateToolException(1, "Unknown language code " + code + ", " +
          "must be an ISO 639 code!");
    }
  }