vocab_table: Build a 'vocab' function from a plain name table

View source: R/01_labels.R

vocab_tableR Documentation

Build a vocab function from a plain name table

Description

The common case for a label_scheme() vocab argument: a hand-listed table of names, one entry per locale, each a named list of renderings. By convention these follow CLDR's wide/abbreviated/narrow, but type can be anything. vocab_table() wraps it in the ⁠function(type = NULL, locale = NULL)⁠ shape vocab requires.

Usage

vocab_table(..., default_locale = "en-GB")

Arguments

...

Named entries, one per locale (e.g. `en-GB` = list(wide = month.name, abbreviated = month.abb)). Locale tags follow BCP 47.

default_locale

The locale returned when locale is unsupplied (or explicitly NULL, meaning "caller didn't ask", since time_parse()/format() always pass some value for locale).

Details

For vocab backed by an external i18n source instead of a hand-listed table, write that ⁠function(type, locale)⁠ directly instead. Same shape, no list needed.

Value

A function ⁠function(type = NULL, locale = NULL)⁠, suitable as the vocab field of a label_scheme().

See Also

label_scheme()

Examples

month_vocab <- vocab_table(`en-GB` = list(wide = month.name, abbreviated = month.abb))
month_vocab("abbreviated")
month_vocab(locale = "en-GB")


mixtime documentation built on Nov. 18, 2026, 5:08 p.m.