Files
RustProxy/langs/README.md
T
2026-10-03 00:27:09 +01:00

41 lines
1.8 KiB
Markdown

# Language packs
Add `de_DE.json` (or another safe unique filename) here and rebuild with Cargo.
`build.rs` discovers all `*.json` files; there is no frontend language allowlist.
The binary embeds the bundle at `/assets/langs.json`, which is accessible before
login. No runtime network dependency or external translation service is required.
```json
{
"meta": {
"locale": "de-DE",
"name": "German",
"native_name": "Deutsch",
"direction": "ltr"
},
"translations": {
"overview": "Ubersicht",
"settings": "Einstellungen"
}
}
```
Use UTF-8 and a BCP-47 locale accepted by browser Intl. Filenames may use letters,
numbers, `_` and `-`. `en_US.json` is the required fallback. `pl_pl.json` preserves
the requested filename; its metadata locale is `pl-PL`. Missing keys fall back to
English; an explicitly empty string is retained. Unknown keys are permitted for
future extensions. `rtl` enables right-to-left layout. HTML is never evaluated:
translations and metadata labels are rendered using textContent.
The saved selection is matched by ID or locale. Browser language preferences are
used when no saved language matches. Short legacy selections such as `pl` are
matched through metadata, not language-specific code. Adding or removing a file
triggers a Cargo rebuild. Duplicate locales, invalid metadata, non-string values
and oversized packs cause a build error. Limits: 128 packs, 256 KiB per pack,
4096 keys per pack, 8 MiB total bundle.
Run `python3 scripts/langs_check.py` before a build. The checker also validates
that every static UI translation key has an English fallback. Extra JSON packs survive the managed updater when the new release does not contain
the same filename. Keep a separate backup too; shipped filenames are replaced and
the previous bytes are retained in the source backup.