All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jukusoft.i18n.utils.IsoUtils Maven / Gradle / Ivy

package com.jukusoft.i18n.utils;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Locale;
import java.util.Set;

public class IsoUtils {

    private static final Set ISO_LANGUAGES = new HashSet<>
            (Arrays.asList(Locale.getISOLanguages()));

    private static final Set ISO_COUNTRIES = new HashSet<>
            (Arrays.asList(Locale.getISOCountries()));

    protected IsoUtils() {

    }

    /**
    * check, if language token is valide
     *
     * @param s language token, for example "en"
     *
     * @see Stackoverflow
     *
     * @return true, if token is valid
    */
    public static boolean isValidISOLanguage(String s) {
        return ISO_LANGUAGES.contains(s);
    }

    public static boolean isValidISOCountry(String s) {
        return ISO_COUNTRIES.contains(s);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy