CLDR is the Common Locale Data Repository, a database of localization information published by the Unicode Consortium.
The CLDR Core library is a Racket interface to the cldr-core JSON distribution published by the Unicode Consortium.
enumerating the set of locales supported by CLDR and testing whether a given locale is supported;
accessing CLDR JSON data; and
canonicalizing locale strings and mapping them to the set of supported CLDR locales.
|(require cldr/core)||package: cldr-core|
(cldr-ref data key [fail]) → any/c
data : jsexpr? key : cldr-key/c
fail : any/c =
(λ () (raise (exn:fail:contract ....)))
If fail is a procedure, it is called (through a tail call) with no arguments to produce the result.
Otherwise, fail is returned as the result.
(cldr-ref* data [#:fail fail] key ...) → any/c
data : jsexpr?
fail : any/c =
(λ () (raise (exn:fail:contract ....))) key : cldr-key/c
In order to keep download sizes reasonable (since the CLDR data set is very large), packages in the cldr collection keep their data in a .zip file named for the package in question. For example, the cldr-core package contains a data file named cldr-core.zip. This file is a compressed archive of the official distribution.
The cldr-json procedure takes:
the path to this zipfile (typically defined within the package using define-runtime-path);
the name of the package (which doubles as the name of the zipfile, without the .zip extension);
the path within the zipfile to the desired .json file; and
a key used to prune the returned JSON data.
(raise-locale-not-found locale package-name) → any/c locale : string? package-name : string?
This function is useful for authors of packages within the cldr collection.
(struct exn:cldr:locale-not-found exn:cldr (locale pkg) #:transparent) locale : string? pkg : string?
cldr-main/c : chaperone-contract?
The string argument is a locale name.
|(require cldr/likely-subtags)||package: cldr-core|
This module provides a high-level interface to the data in likelySubtags.json, described in the CLDR specification.
(locale->available-cldr-locale locale available?) → string? locale : string? available? : (-> string? boolean?)
> (locale->available-cldr-locale "gd" locale?)
> (locale->available-cldr-locale "gd" modern-locale?)
> (locale->cldr-locale "en")
(cldr-locale "en" "Latn" "US")
> (locale->cldr-locale "ar")
(cldr-locale "ar" "Arab" "EG")
> (locale->cldr-locale "zh")
(cldr-locale "zh" "Hans" "CN")
(struct cldr-locale (lang script region) #:transparent) lang : string? script : string? region : string?