Skip to contents

Applies the canonicalization rules from RFC 5646: preferred values are substituted for deprecated subtags, default scripts are suppressed, and each component is cased according to convention (language lower-case, script title-case, region upper-case).

Usage

bcp_normalize(tag, registry = bcp_get_registry())

Arguments

tag

A character scalar BCP 47 language tag.

registry

A data frame of the IANA Language Subtag Registry, as returned by bcp_process_registry(). Defaults to the locally cached registry, falling back to the bundled snapshot if no cache exists.

Value

A character scalar with the normalized BCP 47 tag.

Examples

bcp_normalize('en-us')
#> [1] "en-US"
bcp_normalize('ZH-hans-cn')
#> [1] "zh-Hans-CN"