A lightweight library for representing locale information and serializing to and from strings. A Locale record is an immutable object representing the information in IETF BCP 47. This can be used for distinctions necessary in written and spoken language, but does not provide the full locale information specified by POSIX LC_* variables such as collation and numeric and time formatting, except for reasonable defaults that can be inferred from the region.
locale:rootwhich is the empty locale.
languageshould be a 2 or 3 letter symbol such as
regionis an ISO 3166 code, either an uppercased 2 letter symbol such as
'FRor a 3 digit code from ISO 3166-1 or UN M49 such as
variantis a 5-8 letter language variant such as
'polytonfor Polytonic (Ancient) Greek. The
scriptis a 4 letter titlecased symbol such as
'Jpan(Han + Hiragana + Katakana). The
extensionsare an alist whose keys are single letter symbols (currently only
'xare defined) with subtag string values. The implementation may intern or otherwise coalesce locale objects with the same values. Note the order of the arguments differs from the serialized string representation (moving
variant) to make the common case construction more convenient. Example:
(locale->string (make-locale 'ja 'JP))
#tiff all components of
b, i.e. it
ais a more general locale, differing only in components specified in
bwhich are unspecific in
localeby ablating one of its components, or
#fif locale can't be made more general (i.e. is already
locale:root). The order of generalization follows that of the serialized string representation, first removing the extensions if present, then the variant, then the region, then script.
(locale-language (string->locale "ja-JP"))