Files
VoelinClient/docs/i18n.md
T
Claude fca31f8638 Docs: manual test matrix, release process, security, translations
- docs/testing/manual-matrix.md: the checks CI cannot run (streams with the
  official TS6 client, global push-to-talk, echo cancellation over an hour,
  hotplug, Android background voice and streams, installers) per platform,
  with result, date and version columns.
- docs/release.md: versioning, changelog, notices, signing (Authenticode
  with Azure Trusted Signing or a certificate, Flathub, Android keystore
  outside the repository) and the release checklist.
- docs/i18n.md: @tr, slint-tr-extractor, .po files under
  crates/tsc-ui/lang, bundled translations and language selection.
- SECURITY.md: reporting, what the client and the gateway store, what
  stream peers see.
- CHANGELOG.md with an Unreleased section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
2026-09-26 10:21:58 +00:00

5.4 KiB

Translations

The UI is translated with Slint's gettext-based translations: strings in .slint files are marked with @tr(...), extracted into a .pot template, translated in .po files, and compiled into the binary (Slint's bundled translations). Nothing is loaded at runtime, so there is no dependency on GNU gettext (LGPL) and it works the same on Linux, Windows and Android.

Marking strings

In .slint files every user-visible string goes through @tr:

Button { text: @tr("Connect"); }
Text { text: @tr("Connected to {}", server-name); }            // arguments: {} or {0} {1}
Text { text: @tr("{n} user online" | "{n} users online" % count); }   // plurals
Text { text: @tr("menu" => "Quit"); }                         // explicit context
  • Whole sentences with placeholders, never concatenated fragments: word order differs between languages. Use {0}, {1} when there are several arguments, so translators can reorder them.
  • Plurals always with the | / % form, even if English only needs two forms; other languages have more.
  • Not translated: nicknames, channel and server names, chat text, protocol identifiers, the product name, log messages.
  • By default the context of a string is the name of the component it is in, so the same English word can be translated differently in different places. Renaming a component therefore invalidates its translations until they are merged again (msgmerge keeps them as fuzzy).

Strings produced in Rust (error messages, notification texts, status lines) cannot use @tr. Keep the wording in Slint: an exported global with pure functions that the Rust code calls, e.g.

export global Strings {
    pure public function connection-lost(reason: string) -> string {
        return @tr("Connection lost: {}", reason);
    }
}
let text = window.global::<Strings>().invoke_connection_lost(reason.into());

Errors from lower layers (protocol, IO) are shown as details after a translated sentence; they stay in English.

Files

crates/tsc-ui/lang/
  tsc-ui.pot                       template, generated
  de/LC_MESSAGES/tsc-ui.po         one directory per language (gettext locale name)
  pt_BR/LC_MESSAGES/tsc-ui.po

The file name is the translation domain, which is the crate name (tsc-ui); Slint's build looks for lang/<lang>/LC_MESSAGES/<crate>.po.

Workflow

Tools (developer machines only): cargo install slint-tr-extractor, and GNU gettext for msgmerge / msginit (gettext package; on Windows from MSYS2 or Git for Windows' bundled tools).

# 1. Extract the template after changing strings
slint-tr-extractor --package-name tsc-ui crates/tsc-ui/ui/*.slint -o crates/tsc-ui/lang/tsc-ui.pot

# 2. Update every translation (new strings empty, changed ones fuzzy)
for po in crates/tsc-ui/lang/*/LC_MESSAGES/tsc-ui.po; do
	msgmerge --update --backup=none "$po" crates/tsc-ui/lang/tsc-ui.pot
done

# 3. Start a new language
mkdir -p crates/tsc-ui/lang/de/LC_MESSAGES
msginit --no-translator --locale=de --input=crates/tsc-ui/lang/tsc-ui.pot \
	--output-file=crates/tsc-ui/lang/de/LC_MESSAGES/tsc-ui.po

Translators edit the .po files (Poedit, Lokalize, or a hosted service such as Weblate pointed at crates/tsc-ui/lang). Fuzzy and untranslated entries fall back to English. Run the extraction when strings change and before each release (string freeze, see release.md). The template carries a creation date and source line numbers, so CI does not compare it exactly; a stale template only means new strings are not translatable yet.

Bundling and language selection

crates/tsc-ui/build.rs compiles the translations into the binary:

slint_build::compile_with_config(
	"ui/app.slint",
	slint_build::CompilerConfiguration::new()
		.with_style("fluent-dark".into())
		.with_bundled_translations("lang"),
)

slint-build tracks the .po files, so edits rebuild. It fails ("No translations found") while lang/ has no .po file yet, so enable it together with the first language.

At startup Slint picks the translation matching the system locale (exact match such as pt_BR first, then the language pt), English otherwise. A language setting in the app (stored in the settings, "System" by default) calls slint::select_bundled_translation("de") after the window has been created; "" or "en" selects English. Changing it takes effect immediately for all @tr strings.

The desktop app (tsc-ui) and the Android app share the .slint files and therefore the translations. Texts outside Slint need their own mechanism:

  • Android system texts (foreground service notification, permission rationale): Android string resources in android/app/src/main/res/values-<lang>/.
  • Desktop file and AppStream metainfo: translated with itstool / msgfmt --desktop / msgfmt --xml from .po files when there are translations for the app itself.

Checks

  • A pseudo-translation catches unmarked strings and truncation: create a test language (e.g. lang/eo/) with msgen from the template, replace the texts with longer accented versions, and select it with the language setting (or LANG=eo.UTF-8 on Linux).
  • Test at least one language with longer words (German) and one with a different script (Russian) on every screen before a release (manual matrix row GE7).
  • Dates and numbers are formatted in Rust; use unambiguous formats (ISO dates, 24-hour times) until there is locale-aware formatting.