Check, canonicalize and match language tags by the IANA Language Subtag Registry of file-date.
The functions take tags as text, as the root namespace's do, and those that write a tag also take its map. Validity depends on the registry, so a tag with a subtag newer than file-date isn't valid here until a later release of the library.
The matching functions work as the root namespace's, but compare ranges and tags in extlang form, so that e.g. iw matches he and zh matches yue. They return the tags as given.
Check, canonicalize and match language tags by the IANA Language Subtag Registry of file-date. The functions take tags as text, as the root namespace's do, and those that write a tag also take its map. Validity depends on the registry, so a tag with a subtag newer than file-date isn't valid here until a later release of the library. The matching functions work as the root namespace's, but compare ranges and tags in extlang form, so that e.g. iw matches he and zh matches yue. They return the tags as given.
(basic-filter priority-list tags)(basic-filter priority-list f coll)The tags that a range of the priority-list matches by basic
filtering, as langtag/basic-filter has it, in extlang form. With f, it
filters the items of coll by the tag that f returns for each.
(basic-filter "zh, he" ["yue-HK" "iw" "en"])
;; => ["yue-HK" "iw"]
The `tags` that a range of the `priority-list` matches by basic
filtering, as langtag/basic-filter has it, in extlang form. With `f`, it
filters the items of `coll` by the tag that `f` returns for each.
(basic-filter "zh, he" ["yue-HK" "iw" "en"])
;; => ["yue-HK" "iw"](basic-match? range tag)Whether the basic language range matches the tag, as
langtag/basic-match? has it, in extlang form.
Whether the basic language `range` matches the `tag`, as langtag/basic-match? has it, in extlang form.
(canonical-form x)The tag x (a map or text) in canonical form, or nil when it isn't well
formed.
(canonical-form "iw-IL")
;; => "he-IL"
It replaces a deprecated tag or subtag with the one that the registry prefers, if any, and an extlang with the language it stands for, e.g. yue-HK for zh-yue-HK. Then it writes the tag as langtag/tag does.
The tag `x` (a map or text) in canonical form, or nil when it isn't well
formed.
(canonical-form "iw-IL")
;; => "he-IL"
It replaces a deprecated tag or subtag with the one that the registry
prefers, if any, and an extlang with the language it stands for, e.g.
yue-HK for zh-yue-HK. Then it writes the tag as langtag/tag does.(error s)The reason that the tag s isn't valid, or nil when it is.
(error "en-UK")
;; => {:reason :unregistered-subtag :subtag "UK" :index 1}
The reasons are those of langtag/error, and:
The reason that the tag `s` isn't valid, or nil when it is.
(error "en-UK")
;; => {:reason :unregistered-subtag :subtag "UK" :index 1}
The reasons are those of langtag/error, and:
- :unregistered-subtag, for a language, extlang, script, region or
variant that the registry doesn't have, e.g. the UK of en-UK (it's GB)
- :unexpected-subtag, also for a second or third extlang, e.g. the gan of
zh-yue-gan (section 2.2.2)(extended-filter priority-list tags)(extended-filter priority-list f coll)The tags that a range of the priority-list matches by extended
filtering, as langtag/extended-filter has it, in extlang form. With f,
it filters the items of coll by the tag that f returns for each.
The `tags` that a range of the `priority-list` matches by extended filtering, as langtag/extended-filter has it, in extlang form. With `f`, it filters the items of `coll` by the tag that `f` returns for each.
(extended-match? range tag)Whether the extended language range matches the tag, as
langtag/extended-match? has it, in extlang form.
Whether the extended language `range` matches the `tag`, as langtag/extended-match? has it, in extlang form.
(extlang-form x)The tag x (a map or text) in extlang form, or nil when it isn't well
formed: the canonical form, with the Prefix of the language before it
when the language is also an extlang.
(extlang-form "hak-CN")
;; => "zh-hak-CN"
The tag `x` (a map or text) in extlang form, or nil when it isn't well
formed: the canonical form, with the Prefix of the language before it
when the language is also an extlang.
(extlang-form "hak-CN")
;; => "zh-hak-CN"The File-Date of the registry that the library carries, e.g. "2026-09-17".
The File-Date of the registry that the library carries, e.g. "2026-09-17".
(lookup priority-list tags)(lookup priority-list f coll)The tag in tags that best matches the priority-list by lookup, as
langtag/lookup has it, in extlang form, or nil. With f, it looks up an
item of coll by the tag that f returns for each.
(lookup "iw, en;q=0.8" ["en" "he"])
;; => "he"
A range falls back to its macrolanguage, too, when it's one of the languages that the registry also has as an extlang, e.g. from yue-HK to zh-yue and then zh.
The tag in `tags` that best matches the `priority-list` by lookup, as
langtag/lookup has it, in extlang form, or nil. With `f`, it looks up an
item of `coll` by the tag that `f` returns for each.
(lookup "iw, en;q=0.8" ["en" "he"])
;; => "he"
A range falls back to its macrolanguage, too, when it's one of the
languages that the registry also has as an extlang, e.g. from yue-HK to
zh-yue and then zh.(valid? s)Whether the tag s is well formed and the registry has each of its
subtags.
TODO: whether the subtags of the -u- (RFC 6067) and -t- (RFC 6497) extensions are valid, which CLDR's data says.
Whether the tag `s` is well formed and the registry has each of its subtags. TODO: whether the subtags of the -u- (RFC 6067) and -t- (RFC 6497) extensions are valid, which CLDR's data says.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |