public static String getLanguageCode(String displayLanguage) { List<LanguageCode> codes = LanguageCode.findByName(displayLanguage); return (!codes.isEmpty()) ? codes.get(0).name() : null; }
return findByName(pattern);
return findByName(pattern);
/** * Configures a language specific configuration for parsing wikipedia pages. * @return WikiConfig */ public WikiConfig getWikiconfig(Language this) { WikiConfig config = DefaultConfigEnWp.generate(); if (this != Language._test) { // We need to capitalize the language name otherwise the locale lib cannot find it. String langName = this.name().substring(0, 1).toUpperCase() + this.name().substring(1); try { List<LanguageCode> langCodes = LanguageCode.findByName(langName); if (!langCodes.isEmpty()) { String langCode = langCodes.get(0).name(); return LanguageConfigGenerator.generateWikiConfig(langCode); } } catch (IOException | ParserConfigurationException | SAXException e) { System.out.println( String.format("Failed to create WikiConfig for language for %s, using default instead", langName) ); } } return config; } }