Files
client/docs/i18n.md
T
omar 3d623329b3
ci / linux-x64 (push) Failing after 33s
ci / linux-arm64-cross (push) Successful in 3m8s
Transmit mode: only the latest set_transmit answer counts; forwarding terminology; 0.1.4
An older answer (same settings or a restarted core) could re-enable forwarding while a newer mode
change was pending. Requests and core restarts now start a new epoch. Renderer stats count frames
forwarded to the core. v0.1.3 was tagged but never released.
2026-10-24 09:45:49 +03:00

8.5 KiB
Raw Blame History

Localization

TeamsPeach defaults to English, independently of the operating-system language. Settings → Appearance → Language switches between English and Russian immediately. Only the language preference changes; the identity, nickname, theme, bookmarks, connection, push-to-talk state, and audio/video sessions are not replaced or restarted. The preference is validated and persisted by the existing main-process preferences service.

Files and boundaries

  • app/renderer/shared/en.js: English source catalog.
  • app/renderer/shared/ru.js: Russian catalog; the only authored source file containing Russian wording.
  • app/renderer/shared/i18n.js: browser/CommonJS formatter, explicit language normalization, cached Intl.PluralRules and Intl.NumberFormat instances.
  • app/renderer/js/i18n.js: renderer adapter, active language, static DOM translation, and change subscriptions.
  • app/main/prefs.js: persistence and the en | ru preference contract.

The main process requires the shared formatter directly. Renderer modules import the same catalogs and formatter from the existing app://teamspeach renderer directory. There is no translation service, runtime fetch, dependency, framework, IPC translation endpoint, protocol path expansion, or CSP exception.

The application stays plain JavaScript/HTML/CSS. React-specific composition and performance guidance was reviewed as requested; it does not justify adding React to this application. Locale presentation is separated from the core, capture engine, stream session, and persisted application state.

Using messages

Main process:

const { t } = require('../renderer/shared/i18n.js');
const title = t('native.identityImport.title', {}, prefs.get().language);

Renderer:

import { t, onLanguageChange } from './i18n.js';
setText(status, () => t('members.count', { count }));
toast(() => t('ui.uid.copied'));

Use complete messages with named placeholders rather than interpolating translated fragments where grammar differs. Numbers use the selected language's number formatter; plural messages supply language-specific categories plus other. Values such as version strings, UIDs, device IDs, URLs, and user text remain strings and are not reformatted.

Unknown keys and missing placeholder parameters throw programming errors rather than silently showing untranslated keys or substituting invented fallback wording. Optional technical parameters must be supplied explicitly, for example detail: '' or file: null. Both catalogs must have identical keys and placeholder sets; their plural categories may differ.

Static markup uses data-i18n, data-i18n-title, data-i18n-aria-label, and data-i18n-placeholder. Its initial English text permits an English first frame before preferences load. Do not put data-i18n on a container containing icons or input controls: key the text span instead. Translate through textContent/attributes only, never HTML.

setText(element, render) and toast(render) retain a presentation callback. The DOM helper stores callbacks in a WeakMap and only revisits attached marked nodes on a language change. A dynamic text binding supersedes an initial static text key. Device enumeration, tree labels, chat tabs/timestamps, settings diagnostics, and the update UI refresh their presentation without issuing connection or capture commands. Saved-server edit forms are not rebuilt by a locale change, preserving unsaved input.

Language changes never translate server names, channel names, nicknames, device-provided names, chat content, media, or server descriptions. App-created chat notices are callbacks; incoming messages remain plain text. Error explanations are selected by machine code. Server, operating-system, and backend diagnostic details remain visible verbatim after the localized explanation; unknown codes are not disguised as a successful or empty result. Main-process logs and technical error messages stay English. Native file and confirmation dialog titles, file filters, descriptions, and custom buttons use the current saved preference; operating-system-owned dialog controls follow the OS.

Adding a language

  1. Create a dedicated catalog beside en.js, preserving every key and placeholder.
  2. Add its locale to the shared language list, formatter instances, renderer imports, validated preference enum, and Appearance selector.
  3. Supply appropriate plural categories using Intl.PluralRules; do not copy English plural suffix rules.
  4. Keep application-owned source, comments, tests, logs, and documentation English. Localized wording belongs only in catalogs. Preserve genuine external Unicode data exactly.
  5. Add behavioral coverage and exercise a disposable profile in the real Electron app, including persistence, all categories, device context menus, tooltips, error presentation, and minimum-window screenshots.

Verification

node --test test/i18n.test.mjs test/devices.test.mjs test/prefs.test.js checks catalog parity/formatting, missing-key and missing-parameter failures, English default, English/Russian plural categories (including 1/2/5/11/21 and fractions), raw-content preservation, dynamic error/key labels, device IDs, and persisted preferences.

node scripts/smoke-i18n.mjs --out <evidence-directory> launches the actual Electron executable without a forced locale. It creates and deletes a disposable profile, remains disconnected, enumerates actual devices without requesting microphone capture, visits all settings categories and input/output context menus, switches languages live, restarts to prove persistence, and switches back to English. Screenshots cover the same Appearance, Audio, and Information surfaces at 1280×800 and 880×560, plus onboarding, connection, and device menus. The script checks catalog-backed DOM labels and attributes rather than brittle full-wording snapshots. It compares UID/nickname, connection/audio state, unchanged preferences, and the connection-form draft across the switch.

The isolated smoke does not establish live-server call or active-stream continuity; it proves the disconnected lifecycle and presentation changes without touching an owner's running client. Session and capture code paths are deliberately not called by locale selection.

Recorded development run, 2026-10-24

The targeted command above passed 14/14 tests. The real Electron smoke passed with no renderer page errors on Electron 44.9.3 / Windows x64: fresh-profile English, all seven categories and both actual-device context menus in both languages, live notification translation, Russian persistence after restart, and switching back to English. Capture remained off, the UID/nickname and unrelated preferences stayed unchanged, and the connection-form draft survived. No horizontal document overflow was detected at 880×560. The generated result and matching English/Russian screenshots are under docs/evidence/runtime/i18n-2026-10-24/; the temporary profile was deleted. Screenshots show disposable smoke identity data and real OS-provided device labels, not an owner's identity or server data.

Voice activation settings, 0.1.4 development UI

The single transmission-mode selector is in Settings → Audio: push to talk, voice activation, or an explicitly continuous open microphone. Keyboard retains the push-to-talk key binding. The transmit.* messages distinguish local speech detection from the input-level meter, recording, and speech recognition/transcription. They describe the approximate 0.4-second transmission tail and explain that noise suppression cannot guarantee rejection of television audio, other voices, or noise. error.transmit_mode retains the same {detail} placeholder in both catalogs.

A bounded real-Electron check on 2026-10-24 used a fresh disposable profile at 880×560, with no forced locale, server connection, or microphone test/capture. English and Russian screenshots of the voice-activation card and Keyboard panel are in docs/evidence/runtime/2026-10-24-vad-i18n/, alongside result.json. All three sensitivity values were selected through the UI and observed in the saved preferences. Catalog-backed card labels matched the active locale, with no horizontal overflow or renderer errors. UID/nickname and audio state were unchanged; capture and sending stayed off. The run confirmed fresh English/dark/PTT defaults, restored PTT and English, and removed the temporary profile. This proves localized UI wiring and disconnected preference behavior, not speech/noise classification quality or live transmission; those remain separate audio/backend verification.