Class LanguageUtils


  • public class LanguageUtils
    extends Object
    This object contains enums and utilities for working with language tags. Language tags are defined as in [RFC 5646] and the matching criteria as in [RFC 4647]
    • Constructor Detail

      • LanguageUtils

        public LanguageUtils()
    • Method Detail

      • fromString

        public static Locale fromString​(String languageTag)
        Translates simple language tags like "en" or "en-EN" into Locales. NOTE that if you are using Android API >= 21 and Java 7, you can use the more powerful Locale.forLanguageTag(String).
        Parameters:
        languageTag - in complete form (e.g. "en-EN") or in truncated ("en")
        Returns:
        Locale instance
      • mapISO6392BtoISO6392T

        @NonNull
        public static String mapISO6392BtoISO6392T​(@NonNull
                                                   String langCode)
        Locale supports only ISO 639-2/T and not ISO 639-2/B thus failing for languages whose two codes differ, e.g. Chinese (zho/chi) or Czech (ces/cze) only one of the two is supported.

        This method remaps the values. Mapping extracted from: http://www.loc.gov/standards/iso639-2/php/English_list.php