Consolidate shared UI, hardware transport, and translation tooling

This commit is contained in:
Storm Dragon committed 2026-11-16 20:07:56 -05:00
1 parent ed6951f4cd
commit 2c612de63b
61 files changed
+2417 -1573

No files matched your search

+81
View File
@@ -0,0 +1,81 @@
# Translating Fenrir and Cthulhu
Both screen readers use gettext catalogs and the same tool to build and check
them. Each reader has its own domain and catalog directory:
| Reader | Domain | Catalogs |
|---------|-----------|-------------------------------------------|
| Fenrir | `fenrir` | `internal/i18n/locale/` in the Fenrir checkout |
| Cthulhu | `cthulhu` | `internal/i18n/locale/` in the Cthulhu checkout |
Each directory holds the template, `<domain>.pot`, and one catalog per
language at `<language>/LC_MESSAGES/<domain>.po`. Catalogs are built into the
reader, and missing translations fall back to English. The reader picks its
interface language from `LANGUAGE`, `LC_ALL`, `LC_MESSAGES` or `LANG`, in that
order. Speech language is a separate setting.
Run every command below from the reader's checkout root. `update` and `check`
need GNU gettext (`msgmerge` and `msgfmt`).
## Add a language
1. Create the catalog from the template, using a language code such as `de`
or `pt_BR`. With Fenrir, for example:
```sh
mkdir -p internal/i18n/locale/de/LC_MESSAGES
msginit --no-translator --locale=de \
--input=internal/i18n/locale/fenrir.pot \
--output-file=internal/i18n/locale/de/LC_MESSAGES/fenrir.po
```
For Cthulhu, use `cthulhu.pot` and `cthulhu.po`.
2. Translate every `msgstr`. Keep `{0}`, `{1}` and other placeholders: you
may reorder them, but not drop or rename them. Keep leading and trailing
spaces. A `{{` or `}}` is a literal brace.
3. Run `go run ./tools/translations check`. It reports untranslated or fuzzy
entries, changed placeholders, changed boundary spaces and gettext format
errors.
## Update a catalog after the reader changes
```sh
go run ./tools/translations update
go run ./tools/translations check
```
`update` regenerates the template and merges it into every catalog without
fuzzy matching, so new messages appear untranslated. Translate them, then run
`check` until it passes.
## Test a translation
Start the reader with the language set, for example `LANGUAGE=de`, and
listen to menus, settings and announcements. Some text is composed from
pieces, so check that whole sentences still read naturally in speech and
braille.
An installed catalog in `/usr/share/locale/<language>/LC_MESSAGES/` takes
priority over the bundled one for the same language, which is useful for
trying changes without rebuilding.
## For developers
- Wrap a user-facing message with `i18n.T("...")`, or `i18n.Format("... {0}",
value)` for one with fields. The message must be a string literal so the
tool can extract it.
- Never translate screen contents, application text, accessible names,
Tentacle-provided text, command or setting identifiers, or protocol values.
- Messages built at run time need an entry in the reader's
`tools/translations/dynamic.json` (Fenrir), listing each one under the file
where it occurs as a literal.
- Shared text from screenreader-common reaches each reader's template through
the packages' `MessageIDs()` lists. When you add a message to a common
package, add it to that list; the package tests check that the list matches
the source.
- Plural messages (`i18n.N`) are not supported by the tool yet; it reports an
error at the first call.
The extraction rules for each reader are in its `tools/translations/main.go`.
The shared loader and tool are in screenreader-common's `i18n` and
`i18n/catalogtool` packages.