@Test public void testGetLanguageLocale() { assertEquals(italian, LanguageUtils.getLanguage(italianLocale)); }
public static Language getLanguage(Locale locale) throws UnknownLanguageException { Language language = systemLanguages.get(locale.getLanguage()); if (language != null) return language; Matcher matcher = ACCEPT_LANGUAGE_HEADER.matcher(locale.getLanguage()); if (matcher.matches()) { locale = new Locale(matcher.group(2), matcher.group(1)); } Locale systemLocale = null; try { for (Locale l : Locale.getAvailableLocales()) { if (l.getISO3Language().equals(locale.getISO3Language())) { systemLocale = l; break; } else if (l.getLanguage().equals(l.getLanguage())) { systemLocale = l; break; } } } catch (MissingResourceException e) { logger.debug("No 3 found for '{}': {}", locale, e.getMessage()); } if (systemLocale != null) { language = new LanguageImpl(locale); systemLanguages.put(locale.getLanguage(), language); return language; } throw new UnknownLanguageException(locale.getLanguage()); }
LanguageUtils { public static Language getLanguage(Locale locale) throws UnknownLanguageException { Language language = systemLanguages.get(locale.getLanguage()); if (language != null) return language; Matcher matcher = ACCEPT_LANGUAGE_HEADER.matcher(locale.getLanguage()); if (matcher.matches()) { locale = new Locale(matcher.group(2), matcher.group(1)); } Locale systemLocale = null; try { for (Locale l : Locale.getAvailableLocales()) { if (l.getISO3Language().equals(locale.getISO3Language())) { systemLocale = l; break; } else if (l.getLanguage().equals(l.getLanguage())) { systemLocale = l; break; } } } catch (MissingResourceException e) { logger.debug("No 3 found for '{}': {}", locale, e.getMessage()); } if (systemLocale != null) { language = new LanguageImpl(locale); systemLanguages.put(locale.getLanguage(), language); return language; } throw new UnknownLanguageException(locale.getLanguage()); } }
LanguageUtils { public static Language getLanguage(Locale locale) throws UnknownLanguageException { Language language = systemLanguages.get(locale.getLanguage()); if (language != null) return language; Matcher matcher = ACCEPT_LANGUAGE_HEADER.matcher(locale.getLanguage()); if (matcher.matches()) { locale = new Locale(matcher.group(2), matcher.group(1)); } Locale systemLocale = null; try { for (Locale l : Locale.getAvailableLocales()) { if (l.getISO3Language().equals(locale.getISO3Language())) { systemLocale = l; break; } else if (l.getLanguage().equals(l.getLanguage())) { systemLocale = l; break; } } } catch (MissingResourceException e) { logger.debug("No 3 found for '{}': {}", locale, e.getMessage()); } if (systemLocale != null) { language = new LanguageImpl(locale); systemLanguages.put(locale.getLanguage(), language); return language; } throw new UnknownLanguageException(locale.getLanguage()); } private  LanguageUtils(); }
LanguageUtils { public static Language getLanguage(Locale locale) throws UnknownLanguageException { Language language = systemLanguages.get(locale.getLanguage()); if (language != null) return language; Matcher matcher = ACCEPT_LANGUAGE_HEADER.matcher(locale.getLanguage()); if (matcher.matches()) { locale = new Locale(matcher.group(2), matcher.group(1)); } Locale systemLocale = null; try { for (Locale l : Locale.getAvailableLocales()) { if (l.getISO3Language().equals(locale.getISO3Language())) { systemLocale = l; break; } else if (l.getLanguage().equals(l.getLanguage())) { systemLocale = l; break; } } } catch (MissingResourceException e) { logger.debug("No 3 found for '{}': {}", locale, e.getMessage()); } if (systemLocale != null) { language = new LanguageImpl(locale); systemLanguages.put(locale.getLanguage(), language); return language; } throw new UnknownLanguageException(locale.getLanguage()); } private  LanguageUtils(); static Language getLanguage(Locale locale); static Language getLanguage(String languageCode); static LocalizableContent<String> addDescriptions(Node configuration,
      String tagName, Language defaultLanguage, LocalizableContent<String> o,
      boolean escape); static LocalizableContent<String> addDescriptions(Node configuration,
      String tagName, Language defaultLanguage, LocalizableContent<String> o,
      boolean escape, XPath xpath); static String getLanguageVariant(String s, Language language); static String[] getLanguageVariants(String s, Language... languages); static String getBaseVersion(String s); static Language extractLanguage(String s); static Language getPreferredLanguage(Set<Language> choices,
      HttpServletRequest request); static Language getPreferredLanguage(Localizable localizable,
      HttpServletRequest request, Site site); static Language getPreferredContentLanguage(Resource<?> resource,
      HttpServletRequest request, Site site); static Language getPreferredLanguage(HttpServletRequest request,
      Site site); static Language getPreferredLanguage(Localizable localizable,
      Language... languages); static Language getPreferredContentLanguage(Resource<?> resource,
      Language... languages); }
LanguageUtils { public static Language getLanguage(Locale locale) throws UnknownLanguageException { Language language = systemLanguages.get(locale.getLanguage()); if (language != null) return language; Matcher matcher = ACCEPT_LANGUAGE_HEADER.matcher(locale.getLanguage()); if (matcher.matches()) { locale = new Locale(matcher.group(2), matcher.group(1)); } Locale systemLocale = null; try { for (Locale l : Locale.getAvailableLocales()) { if (l.getISO3Language().equals(locale.getISO3Language())) { systemLocale = l; break; } else if (l.getLanguage().equals(l.getLanguage())) { systemLocale = l; break; } } } catch (MissingResourceException e) { logger.debug("No 3 found for '{}': {}", locale, e.getMessage()); } if (systemLocale != null) { language = new LanguageImpl(locale); systemLanguages.put(locale.getLanguage(), language); return language; } throw new UnknownLanguageException(locale.getLanguage()); } private  LanguageUtils(); static Language getLanguage(Locale locale); static Language getLanguage(String languageCode); static LocalizableContent<String> addDescriptions(Node configuration,
      String tagName, Language defaultLanguage, LocalizableContent<String> o,
      boolean escape); static LocalizableContent<String> addDescriptions(Node configuration,
      String tagName, Language defaultLanguage, LocalizableContent<String> o,
      boolean escape, XPath xpath); static String getLanguageVariant(String s, Language language); static String[] getLanguageVariants(String s, Language... languages); static String getBaseVersion(String s); static Language extractLanguage(String s); static Language getPreferredLanguage(Set<Language> choices,
      HttpServletRequest request); static Language getPreferredLanguage(Localizable localizable,
      HttpServletRequest request, Site site); static Language getPreferredContentLanguage(Resource<?> resource,
      HttpServletRequest request, Site site); static Language getPreferredLanguage(HttpServletRequest request,
      Site site); static Language getPreferredLanguage(Localizable localizable,
      Language... languages); static Language getPreferredContentLanguage(Resource<?> resource,
      Language... languages);  }