You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.8 KiB
2.8 KiB
Title: feat: Add extensible i18n architecture for admin interface and templates
Summary
This PR introduces an extensible i18n architecture for server-rendered templates, backend notifications, and Admin UI strings. The core design keeps default behavior deterministic and zero-cost with compile-time embedded catalogs, while enabling runtime locale overrides for self-hosters.
Motivation
Vaultwarden has historically lacked localized coverage in the /admin interface and template-driven surfaces. This PR:
- Centralizes locale dictionaries under
src/static/locales/<locale>/. - Removes hardcoded locale lists by leveraging directory auto-discovery at compile time.
- Enforces strict translation coverage and schema parity using lightweight CI quality gates.
Key Features
- Extensible Compile-Time Locale Discovery:
- Base catalogs are embedded via
include_dir. - New languages added under
src/static/locales/<locale>/are picked up automatically without modifying Rust source files.
- Base catalogs are embedded via
- Runtime Override Support:
- Self-hosters can supply custom translations via
DATA_FOLDER/locales(single-file<locale>.jsonor directory<locale>/*.json).
- Self-hosters can supply custom translations via
- Admin Frontend Serving:
admin_ui.jsondictionaries are automatically exposed at/vw_static/locales/<locale>/admin_ui.jsonand consumed by the admin client script.
- Fallback & Graceful Degradation:
- Robust fallback chain (
full-locale->base-lang->en). - Missing keys render the key identifier safely instead of failing the render.
- Robust fallback chain (
- Zero-Dependency CI Guards:
- Standalone Python standard-library scripts prevent missing keys, duplicate registrations, and inline dictionary regressions.
Compatibility & Breaking Changes
- Fully backward compatible: Existing deployments, database backends, and environment configurations behave identically.
- API integrity preserved: Client-facing API payloads and error formats for official Bitwarden apps remain intact.
Testing Performed
- Validation Scripts (Python stdlib):
python3 tools/check_template_locale_duplicates.py(Passed)python3 tools/check_template_i18n_keys.py(Passed)python3 tools/check_admin_i18n_keys.py(Passed)
- Engine Database Feature Matrix:
cargo check --features sqlite(Passed)cargo check --features postgresql(Passed)cargo check --features mysql(Passed)
- Formatting & Lints:
cargo fmt --all --check(Passed)cargo clippy --all-targets -- -D warnings(Passed)
- Runtime Verification:
- Tested
/adminlocalization with variousAccept-Languageheaders (ru,en-US, unsupported fallbacks). - Verified static dictionary delivery under
/vw_static/locales/.
- Tested
Documentation
A full architectural overview and contributor guide is provided in docs/i18n.md.