Package com.castlabs.utils
Class LanguageUtils
- java.lang.Object
-
- com.castlabs.utils.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 Summary
Constructors Constructor Description LanguageUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Locale
fromString(String languageTag)
Translates simple language tags like "en" or "en-EN" intoLocale
s.static String
mapISO6392BtoISO6392T(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.
-
-
-
Method Detail
-
fromString
public static Locale fromString(String languageTag)
Translates simple language tags like "en" or "en-EN" intoLocale
s. NOTE that if you are using Android API >= 21 and Java 7, you can use the more powerfulLocale.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
-
-