A set of language utility functions.
- Source:
Members
-
(private, static, constant, non-null) isoMap_ :Object.<string, string>
-
A map from 3-letter language codes (ISO 639-2) to 2-letter language codes (ISO 639-1) for all languages which have both in the registry.
Type:
- Object.<string, string>
- Source:
-
(static) MatchType :number
-
A match type for fuzzy-matching logic.
Type:
- number
Properties:
Name Type Description EXACTnumber Accepts an exact match. BASE_LANGUAGE_OKAYnumber Accepts a less-specific version of the preferred sublanguage. OTHER_SUB_LANGUAGE_OKAYnumber Accepts a different sublanguage of the preferred base language. MINnumber MAXnumber - Source:
Methods
-
(static) match(fuzz, preference, candidate) → {boolean}
-
Compares two language tags as defined by RFC 5646 and ISO 639. The comparison takes sublanguages into account via the |fuzz| parameter. The caller is expected to normalize the inputs first.
Parameters:
Name Type Description fuzzshaka.util.LanguageUtils.MatchType What kind of match is acceptable. preferencestring The user's preferred language tag. candidatestring An available language tag. - Source:
- See:
-
- shaka.util.LanguageUtils.normalize()
- IETF RFC 5646
- ISO 639
Returns:
- Type
- boolean
-
(static) normalize(lang) → {string}
-
Normalize the language tag. RFC 5646 specifies that language tags are case insensitive and that the shortest representation of the base language should always be used. This will convert the tag to lower-case and map 3-letter codes (ISO 639-2) to 2-letter codes (ISO 639-1) whenever possible.
Parameters:
Name Type Description langstring - Source:
- See:
-
- IETF RFC 5646
- ISO 639
Returns:
- Type
- string