Search in sources :

Example 6 with Language

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;
}
Also used : Language(org.opensextant.data.Language)

Example 7 with Language

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);
    }
}
Also used : Language(org.opensextant.data.Language) Country(org.opensextant.data.Country)

Example 8 with Language

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));
}
Also used : Language(org.opensextant.data.Language)

Example 9 with Language

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));
}
Also used : Language(org.opensextant.data.Language)

Example 10 with Language

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));
}
Also used : Language(org.opensextant.data.Language)

Aggregations

Language (org.opensextant.data.Language)10 Country (org.opensextant.data.Country)2 InputStreamReader (java.io.InputStreamReader)1 Locale (java.util.Locale)1 Optional (org.supercsv.cellprocessor.Optional)1 NotNull (org.supercsv.cellprocessor.constraint.NotNull)1 CellProcessor (org.supercsv.cellprocessor.ift.CellProcessor)1 CsvListReader (org.supercsv.io.CsvListReader)1