use of org.opensextant.data.Language in project Xponents by OpenSextant.
the class TextUtils method getLanguage.
/**
* ISO2 and ISO3 char codes for languages are unique.
*
* @param code
* iso2 or iso3 code
* @return the other code.
*/
public static Language getLanguage(String code) {
if (code == null) {
return null;
}
String lookup = code.toLowerCase();
Language l = languageMapISO639.get(lookup);
if (l != null) {
return l;
}
// Keep looking.
if (lookup.contains("_")) {
lookup = lookup.split("_")[0];
l = languageMapISO639.get(lookup);
if (l != null) {
return l;
}
}
return null;
}
use of org.opensextant.data.Language in project Xponents by OpenSextant.
the class GeonamesUtility method addLang.
/**
*
* @param langOrLocale
* lang code
* @param cc
* country code
*/
private void addLang(String langOrLocale, String cc) {
String lid = langOrLocale;
if (lid.length() == 3) {
Language L = TextUtils.getLanguage(langOrLocale);
if (L == null) {
unknownLanguages.add(lid);
}
}
/**
* Special case: First language / country pairs seen, denote those as PRIMARY language.
* As geonames.org lists languages spoken by order of population of speakers.
*
*/
Country C = this.isoCountries.get(cc);
if (C != null) {
C.addLanguage(lid);
}
}
use of org.opensextant.data.Language in project Xponents by OpenSextant.
the class TextUtils method isCJK.
/**
* Utility method to check if lang ID is Chinese, Korean, or Japanese
*
* @param x
* a langcode
* @return whether langcode is a CJK language
*/
public static boolean isCJK(String x) {
Language lang = getLanguage(x);
if (lang == null) {
return false;
}
String id = lang.getISO639_1_Code();
if (isBlank(id)) {
return false;
}
return (id.equals(koreanLang) || id.equals(japaneseLang) || id.equals(chineseLang) || id.equals(chineseTradLang));
}
use of org.opensextant.data.Language in project Xponents by OpenSextant.
the class TextUtils method isChinese.
/**
* Utility method to check if lang ID is Chinese(Traditional or
* Simplified)...
*
* @param x
* a langcode
* @return whether langcode is chinese
*/
public static boolean isChinese(String x) {
Language lang = getLanguage(x);
if (lang == null) {
return false;
}
String id = lang.getISO639_1_Code();
return (id.equals(chineseLang) || id.equals(chineseTradLang));
}
use of org.opensextant.data.Language in project Xponents by OpenSextant.
the class TextUtils method isEnglish.
/**
* Utility method to check if lang ID is English...
*
* @param x
* a langcode
* @return whether langcode is english
*/
public static boolean isEnglish(String x) {
Language lang = getLanguage(x);
if (lang == null) {
return false;
}
String id = lang.getISO639_1_Code();
return (id.equals(englishLang));
}
Aggregations