- 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 | Value | Type | Description |
---|---|---|---|
EXACT |
0 | number | Accepts an exact match. |
BASE_LANGUAGE_OKAY |
1 | number | Accepts a less-specific version of the preferred sublanguage. |
OTHER_SUB_LANGUAGE_OKAY |
2 | number | Accepts a different sublanguage of the preferred base language. |
- 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 |
---|---|---|
fuzz |
shaka.util.LanguageUtils.MatchType | What kind of match is acceptable. |
preference |
string | The user's preferred language tag. |
candidate |
string | 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 |
---|---|---|
lang |
string |
- Source:
- See:
-
- IETF RFC 5646
- ISO 639
Returns:
- Type
- string