Expand description
Locale messaging helpers. Automatic multi-language UI for human-facing suggestions.
§Language isolation (crates.io / agent contract)
- All identifiers, comments, and technical
messagefields are English. - Portuguese appears only as catalog string literals for human
suggestionUI text when locale resolves topt-BR(not in identifiers or logs). - Agent-stable JSON
error.messageremains English regardless of locale. - Prefer [
Mensagem] / [suggestion_key] over hardcoding UI strings at call sites. - Stdout JSON envelopes are not translated (machine contract).
§Boot order (rules multi-idioma)
- Windows console UTF-8 ([
configure_console_utf8]) - TTY / plain / screen-reader hints (see
crate::color) - OS locale via
sys-localeinside [resolve_locale] - Parse →
LanguageIdentifier(unic-langid) - Negotiate against compiled packs (
fluent-langneg) - Publish in [
OnceLock] via [set_effective_idioma]
§Precedence (5 layers)
--lang → BROWSER_AUTOMATION_CLI_LANG → XDG lang → system → default en
Structs§
- Resolved
Locale - Result of the 5-layer resolution chain.
Enums§
- Direcao
- Text direction for terminal/UI rendering.
- Idioma
- Supported UI locale for human-facing suggestions.
- Locale
Source - Where the effective UI locale came from (diagnostics /
localesubcommand). - Mensagem
- Every human-facing UI string key for this binary.
- Script
Escrita - Writing system tag used for documentation and future CJK/RTL packs.
Constants§
- LANG_
ENV - Product env override:
BROWSER_AUTOMATION_CLI_LANG(rules:<CRATE_UPPER>_LANG).
Functions§
- configure_
console_ utf8 - Configure Windows console to UTF-8 (and VT) before any user-facing I/O.
- detect_
system_ langid - Read OS locale once via
sys-locale(never directLANGreads in portable code). - effective_
idioma - Current effective idioma (defaults to
enif unset). - effective_
lang - Current effective language legacy token (defaults to
enif unset). - effective_
resolved - Full resolved snapshot (for
localesubcommand). - format_
ftl - Format a message id from the embedded FTL; falls back to enum catalog on miss.
- ftl_id
- Stable FTL / catalog id for a
Mensagemvariant. - ftl_
keys - Extract bare message ids from an FTL source (lines
key = value, skip comments/blank). - ftl_
source - Embedded FTL source for a compiled idioma.
- locale_
diagnostics - JSON-ready diagnostics for
localesubcommand (machine keys English). - localize_
error_ suggestion - Apply kind-based localized suggestion when none is set, or re-map known EN strings.
- negotiate
- Negotiate requested identifiers against compiled packs; always returns a pack.
- normalize_
lang - Normalize lang token to legacy
"en"or"pt". - parse_
langid - Normalize raw OS / user locale strings into a
LanguageIdentifier. - resolve
- Full 5-layer resolution:
- resolve_
lang - Resolve language from CLI flag, then XDG config, then OS locale hints.
- resolve_
locale - Resolve language from CLI flag, then env, XDG, OS locale (see
resolve). - set_
effective_ idioma - Store effective locale for the process (call once from
run()). - set_
effective_ lang - Store effective language for the process (call once from
run()). - suggestion_
for - Localized suggestion for a known kind key.
- suggestion_
key - Catalog of stable suggestion keys (preferred over hard-coded English).
- truncate_
graphemes - Grapheme-aware truncation for terminal width (CJK-safe boundary).