cbcp 0.1.2

Deterministic BCP 47 locale-ID casting and vendor code mapping: normalize, display, validate, DeepL/Google adapters. No models, no I/O.
Documentation
  • Coverage
  • 100%
    9 out of 9 items documented0 out of 8 items with examples
  • Size
  • Source code size: 158.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 168.5 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1s Average build duration of successful builds.
  • all releases: 1s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • julian-corbet

cbcp

BCP 47 locale-ID casting and vendor code mapping, identical in every language.

crates.io npm PyPI JSR

import { normalizeLocaleId, toBcp47, deeplTarget } from '@corbet-labs/cbcp';

normalizeLocaleId(' DE_Ch '); // 'de-ch' — storage and wire form
toBcp47('de-ch');             // 'de-CH' — display form
deeplTarget('en');            // 'EN-GB' — vendor contract
use cbcp::{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");
from cbcp import normalize_locale_id, to_bcp47, deepl_target

assert normalize_locale_id(" DE_Ch ") == "de-ch"
assert to_bcp47("de-ch") == "de-CH"
assert deepl_target("en") == "EN-GB"
#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.