cbcp
BCP 47 locale-ID casting and vendor code mapping, identical in every language.
import from '@corbet-labs/cbcp';
; // 'de-ch' — storage and wire form
; // 'de-CH' — display form
; // 'EN-GB' — vendor contract
use ;
assert_eq!;
assert_eq!;
assert_eq!;
assert ==
assert ==
assert ==
#import "cbcp.typ": normalize-locale-id, to-bcp47, deepl-target
#assert.eq(normalize-locale-id(" DE_Ch "), "de-ch")
#assert.eq(to-bcp47("de-ch"), "de-CH")
#assert.eq(deepl-target("en"), "EN-GB")
Rule
Two spellings, one rule. Lowercase (de-ch) is stored and sent:
filesystem paths, keys, bundle IDs, URLs, document metadata. BCP 47
(de-CH) is displayed: UI labels and vendor adapters that demand their own
casing. tests/vectors/*.json is the executable contract every port
implements verbatim — same names, same inputs, same expectations.
cbcp is the syntax layer below correspondence: no locale resolution, no
country keywords, no variant mapping, no greetings. Those live in cletter,
which composes this crate. Vendor adapters (deepl_*, google_language)
transliterate canonical codes into vendor-expected codes and track vendor
documentation; a vendor change is a new cbcp minor version.
Install
| Environment | Command |
|---|---|
| Rust / Cargo | cargo add cbcp |
| Node.js / npm | npm install @corbet-labs/cbcp |
| Deno | deno add jsr:@corbet-labs/cbcp |
| Python / pip | python -m pip install cbcp |
See installation for details and releasing for the vector-first release process.
License
Copyright 2026 Julian Y. Richard Corbet. Licensed under LGPL-3.0-only WITH LGPL-3.0-linking-exception, with the incorporated GPL version 3. See the licensing notes. Contributions are subject to the Contributor License Agreement.