Skip to content

MiroTalk P2P Internationalization

MiroTalk P2P translates the in-room UI (buttons, tooltips, dialogs, and notifications).

Translation files live in public/lang/ (one JSON file per language). See the upstream translations README for the latest details.


Configuration

Set these variables in your .env file:

Variable Default Description
UI_LANGUAGE en Default interface language code (for example en, es, fr)
UI_TRANSLATION_MODE google How translations are applied (see the modes below)

Example:

Bash
UI_LANGUAGE=es
UI_TRANSLATION_MODE=native
Mode Behavior
google (default) Use Google Translate and ignore the native JSON files
auto Use a native file when available, otherwise fall back to Google Translate
native Use native files only. Untranslated text stays in English

Language selection

Users can change the language and the translation mode in a room from Settings > Language. The choice is saved in the browser's local storage and reused in later rooms on the same browser. When the translation mode changes, the app shows a short notice and reloads the page to apply it.

The precedence is: browser override → server default from .env.


Supported languages

27 languages are available:

Code Language
en 🇬🇧 English
hu 🇭🇺 Magyar
es 🇪🇸 Español
fr 🇫🇷 Français
de 🇩🇪 Deutsch
pt 🇵🇹 Português
it 🇮🇹 Italiano
pl 🇵🇱 Polski
ru 🇷🇺 Русский
uk 🇺🇦 Українська
zh 🇨🇳 中文
ja 🇯🇵 日本語
th 🇹🇭 ไทย
ar 🇸🇦 العربية
hi 🇮🇳 हिन्दी
sr 🇷🇸 Српски
id 🇮🇩 Bahasa Indonesia
ko 🇰🇷 한국어
tr 🇹🇷 Türkçe
bn 🇧🇩 বাংলা
ur 🇵🇰 اردو
vi 🇻🇳 Tiếng Việt
te 🇮🇳 తెలుగు
mr 🇮🇳 मराठी
ta 🇮🇳 தமிழ்
sw 🇹🇿 Kiswahili
fa 🇮🇷 فارسی

Right-to-left languages (ar, ur, fa) switch the page direction automatically.


Add or update a language

  1. Copy public/lang/en.json to public/lang/<language-code>.json (for example hu.json).
  2. Translate the values only. Keep the English keys, punctuation, casing, and placeholders such as {name} unchanged.
  3. Add the language code, flag, and native name to LANG_DISPLAY in public/js/i18n.js. For a right-to-left language, also add the code to RTL_LANGS.
  4. Set UI_LANGUAGE to the language code and UI_TRANSLATION_MODE to auto or native in .env.

Each file is grouped into namespaces:

Namespace Content
tooltips Hover hints
buttons Button text and attributes
labels Static text, headings, and label attributes
dialogs Popup titles, text, buttons, and inputs
toasts Notifications

Fallback behavior

Missing namespaces, keys, or empty values use the original English text, so translations can be added incrementally.

In auto mode, Google Translate is used only when the language file is unavailable. When a native file is loaded, missing entries stay in English; they do not fall back individually to Google Translate.


Synchronize translation keys

After changing in-room UI strings, run this from the repository root:

Bash
npm run lang

The script regenerates en.json and synchronizes the other language files. It keeps existing translations, preserves the key order of en.json, adds missing keys with English values, and removes stale keys. Review the changes before committing, and translate newly added English values manually or with npm run lang:translate.


Auto-translate missing values (optional)

To fill untranslated values with machine translation, run:

Bash
npm run lang:translate

The script uses Node's built-in fetch with the public Google Translate endpoint, so it needs no extra dependencies. It only fills values that are empty or still match the English source, and it never changes en.json.

  • Rate limits: Requests are paced and retried with backoff. Progress is saved after each batch, so if a run stops because of rate limits, wait a moment and run the command again. The next run continues from the saved progress.
  • Placeholders: {placeholders} are protected during translation. If a translation would lose a placeholder, the value keeps its English text.
  • Acronyms: Short all-caps values such as ID, OK, URL, or FULL HD are not translated.

To limit or extend a run, pass options after --:

Bash
npm run lang:translate -- --locale it          # one locale (or --locale it,de)
npm run lang:translate -- --max-batches 0      # no per-locale batch limit (default: 30 batches of 5 values)
npm run lang:translate -- --stop-on-error      # stop the whole run on the first locale error
npm run lang:translate -- --help

To synchronize keys and translate in one step, run:

Bash
npm run lang:auto

Warning

Machine translations are a starting point. Review them before committing. Some values can intentionally match the English text, such as brand names or technical identifiers.