Skip to main content

bcp47_language

Function bcp47_language 

Source
pub fn bcp47_language(iso639_2: &str) -> Option<String>
Available on crate feature std only.
Expand description

Canonicalise an ISO 639-2 language code into a BCP 47 (RFC 5646) primary language subtag, as required by RFC 8216bis EXT-X-MEDIA LANGUAGE.

HLS LANGUAGE must be an RFC 5646 (BCP 47) language tag; in BCP 47 the primary subtag is the ISO 639-1 two-letter code when one exists, otherwise the ISO 639-2/T (== ISO 639-3) three-letter code. ISO 639-2/B bibliographic codes (fre, ger, dut, chi, …) are not valid BCP 47 subtags and are mapped to their terminology (T) equivalents first.

qaa..qtz (private use), und, mul, mis and zxx pass through unchanged. Unknown or malformed codes return None.