Parse IETF Language Tag

Extract language, script, region and variant subtags from IETF language tags.

parse_IETF_language_tag(x, expand = FALSE)

a character vector with IETF language tags.


a logical indicating whether to expand subtags into their description(s).


Internet Engineering Task Force (IETF) language tags are defined by IETF BCP 47, which is currently composed by the normative RFC 5646 ( and RFC 4647 (, along with the normative content of the IANA Language Subtag Registry regulated by these RFCs. These tags are used in a number of modern computing standards.

Each language tag is composed of one or more “subtags” separated by hyphens. Normal language tags have the following subtags:

  • a language subtag (optionally, with language extension subtags),

  • an optional script subtag,

  • an optional region subtag,

  • optional variant subtags,

  • optional extension subtags,

  • an optional private use subtag.

Language subtags are mainly derived from ISO 639-1 and ISO 639-2, script subtags from ISO 15924, and region subtags from ISO 3166-1 alpha-2 and UN M.49. (See package ISOcodes for more information about these standards.) Variant subtags are not derived from any standard. The Language Subtag Registry (, maintained by the Internet Assigned Numbers Authority (IANA), lists the current valid public subtags, as well as the so-called “grandfathered” language tags.

See for more information.


If expand is false, a list of character vectors of the form "type=subtag", where type gives the type of the corresponding subtag (one of ‘Language’, ‘Extlang’, ‘Script’, ‘Region’, ‘Variant’, or ‘Extension’), or "type=tag" with type either ‘Privateuse’ or ‘Grandfathered’.

Otherwise, a list of lists of character vectors obtained by replacing the subtags by their corresponding descriptions (which may be multiple) from the IANA registry. Note that no such descriptions for Extension and Privateuse subtags are available in the registry; on the other hand, empty expansions of the other subtags indicate malformed tags (as these subtags must be available in the registry).

  • parse_IETF_language_tag
## German as used in Switzerland:
## Serbian written using Latin script as used in Serbia and Montenegro:
## Spanish appropriate to the UN Latin American and Caribbean region:
## All in one:
parse_IETF_language_tag(c("de-CH", "sr-Latn-CS", "es-419"))
parse_IETF_language_tag(c("de-CH", "sr-Latn-CS", "es-419"),
                        expand = TRUE)
## Two grandfathered tags:
parse_IETF_language_tag(c("i-klingon", "zh-min-nan"),
                        expand = TRUE)
# }
Documentation reproduced from package NLP, version 0.1-10, License: GPL-3

Community examples

Looks like there are no examples yet.