Skip to contents

A chart can display Chinese text, format numbers in German and use British English dates. All settings are local to the chart. The language chosen for a paragraph guides shaping and wrapping. It leaves axes, ordering and statistical calculations under the author's control.

Usage

locale_info(
  lang = "en",
  region = NULL,
  number_locale = NULL,
  date_locale = NULL,
  font_family = "sans",
  text_direction = "auto",
  break_locale = NULL,
  percent_locale = NULL
)

Arguments

lang

Display language in BCP 47 form. Language, optional script, region, variants and extensions are accepted. Use Unicode locale IDs, e.g. "zh-Hant" or "en-Latn-GB". Legacy grandfathered, extlang and private-only forms need their modern language equivalent.

region

Optional territory such as "GB" or "419" to substitute in the language's formatting tag. A full tag such as "de-DE" selects both the formatting language and the region. The display tag stays unchanged.

number_locale, date_locale

Independent formatting tags. Each defaults to the regional tag derived from lang and region.

font_family

Requested local font or generic family. Use font_check() to inspect actual glyph coverage and fallback on the rendering host.

text_direction

One of "auto", "ltr" and "rtl". Auto resolves a paragraph base direction from its explicit or likely script.

break_locale

Locale for ICU line breaking. Defaults to lang.

percent_locale

Percentage formatting tag. Defaults to number_locale.

Value

A named forma_locale_info list containing the display tag, resolved script, formatting region, formatting and line-break tags, font request and paragraph direction. number_resource and percent_resource identify the chosen CLDR data. icu_date_locale is the locale passed to ICU's date formatter. It can internally inherit region patterns.

Details

Number and script metadata use bundled Unicode CLDR 48.0.0 data. For a missing number resource, the resolver tries the likely script and territory, then the same language, then English. ICU handles date patterns and calendars. For an unknown date language ggforma explicitly uses English.

Examples

loc <- locale_info("zh-Hans", number_locale = "de-DE", date_locale = "en-GB")
forma_format(12345.5, locale = loc)
#> [1] "12.345,5"
locale_info("az-Arab")$text_direction
#> [1] "rtl"