LanguageUtils { public static Language extractLanguage(String s) { int languagePosition = s.lastIndexOf("_"); if ((languagePosition < 0) || (languagePosition + 1 > s.length())) return null; Language l = null; String languageId = s.substring(languagePosition + 1, languagePosition + 3); l = getLanguage(languageId); return l; } 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);  }
@Test public void testExtractLanguage() { assertEquals(italian, LanguageUtils.extractLanguage("test_it.jsp")); assertTrue(LanguageUtils.extractLanguage("test.jsp") == null); try { assertEquals(italian, LanguageUtils.extractLanguage("test_xyz.jsp")); fail("LanguageSupport was fooled by non existent language xyz"); } catch (UnknownLanguageException e) { } }