diff --git a/app/static/js/logs.js b/app/static/js/logs.js index 8af5d43..939708c 100644 --- a/app/static/js/logs.js +++ b/app/static/js/logs.js @@ -81,7 +81,7 @@ renderAll(); }) .catch(err => { - if (loadingMsg) loadingMsg.textContent = 'Failed to load logs'; + if (loadingMsg) loadingMsg.textContent = t('logs.load_failed'); console.error('Failed to load logs:', err); }); } @@ -203,8 +203,8 @@ const total = entries.length; const shown = logEntries.children.length; logCount.textContent = shown === total - ? `${total} entries` - : `${shown} / ${total} entries`; + ? tn('logs.entries', total) + : tn('logs.entries_filtered', total, { shown }); } function updateLoggerOptions() { @@ -212,7 +212,7 @@ // Group loggers by top-level module const sorted = Array.from(knownLoggers).sort(); - loggerFilter.innerHTML = ''; + loggerFilter.innerHTML = ``; for (const name of sorted) { const opt = document.createElement('option'); opt.value = name; diff --git a/app/templates/logs.html b/app/templates/logs.html index 7815e59..905b4aa 100644 --- a/app/templates/logs.html +++ b/app/templates/logs.html @@ -3,7 +3,7 @@ - System Log - mc-webui + {{ t('logs.title') }} - mc-webui {% include "_head_i18n.html" %} @@ -154,14 +154,14 @@
- 0 entries + {{ tn('logs.entries', 0) }}
- -
@@ -171,18 +171,19 @@
-
@@ -190,7 +191,7 @@
-
Loading logs...
+
{{ t('logs.loading') }}
diff --git a/app/translations/en.json b/app/translations/en.json index fc55f5d..d2dc53c 100644 --- a/app/translations/en.json +++ b/app/translations/en.json @@ -8,6 +8,24 @@ "common.minutes_ago": "{count} min ago", "common.yesterday": "Yesterday", + "logs.clear_title": "Clear display", + "logs.entries": { + "one": "{count} entry", + "other": "{count} entries" + }, + "logs.entries_filtered": { + "one": "{shown} / {count} entry", + "other": "{shown} / {count} entries" + }, + "logs.filter.all_levels": "All levels", + "logs.filter.all_modules": "All modules", + "logs.filter.reset_title": "Reset filters", + "logs.filter.search_ph": "Search...", + "logs.load_failed": "Failed to load logs", + "logs.loading": "Loading logs...", + "logs.pause_title": "Pause/Resume", + "logs.title": "System Log", + "meta.language_english_name": "English", "meta.language_name": "English", "meta.translator": "mc-webui" diff --git a/app/translations/pl.json b/app/translations/pl.json index 9d76015..529dfca 100644 --- a/app/translations/pl.json +++ b/app/translations/pl.json @@ -10,6 +10,28 @@ "common.minutes_ago": "{count} min temu", "common.yesterday": "Wczoraj", + "logs.clear_title": "Wyczyść widok", + "logs.entries": { + "one": "{count} wpis", + "few": "{count} wpisy", + "many": "{count} wpisów", + "other": "{count} wpisu" + }, + "logs.entries_filtered": { + "one": "{shown} / {count} wpis", + "few": "{shown} / {count} wpisy", + "many": "{shown} / {count} wpisów", + "other": "{shown} / {count} wpisu" + }, + "logs.filter.all_levels": "Wszystkie poziomy", + "logs.filter.all_modules": "Wszystkie moduły", + "logs.filter.reset_title": "Wyczyść filtry", + "logs.filter.search_ph": "Szukaj...", + "logs.load_failed": "Nie udało się wczytać dziennika", + "logs.loading": "Ładowanie dziennika...", + "logs.pause_title": "Wstrzymaj/Wznów", + "logs.title": "Dziennik systemowy", + "meta.language_english_name": "Polish", "meta.language_name": "Polski", "meta.translator": "mc-webui" diff --git a/docs/whatsnew.md b/docs/whatsnew.md index 701767b..9792ff9 100644 --- a/docs/whatsnew.md +++ b/docs/whatsnew.md @@ -10,6 +10,12 @@ For deep technical notes, see [architecture.md](architecture.md). For the full g ## Unreleased +### Features + +- **The interface can be translated, and Polish has started.** mc-webui was written English-only, with every label and message baked into the code. There is now a translation system behind it, and a **Language** setting at the top of Settings → Appearance. This first step covers the groundwork plus the **System Log** panel; the remaining panels follow one at a time, so for now most of the interface is still English whichever language you pick. Your choice applies to the browser you set it in and also becomes the default for anyone else opening the server without a preference of their own. +- **You can add a language yourself, without waiting for a release.** A language is a single file. Copy `en.json` from `app/translations/`, translate the values, and drop it into a `translations` folder inside your config directory — the same place the database lives. Refresh the page and it appears in the Language list, named however you named it, with no rebuild and no restart. Anything you leave untranslated falls back to English, so a half-finished translation is perfectly usable. A file you drop in also overrides one that ships with the app, so you can correct the built-in Polish on your own server. English and Polish ship in the box; everything else is open to whoever wants to write it. See [translations.md](translations.md), which explains the format and — importantly — which words to leave alone: mesh terms like flood, hop, advert, RSSI and the repeater roles stay English in every language, because that is what the firmware, the CLI and the forums all use. The Console and the log lines themselves stay English for the same reason. +- **Times and dates behave the same in every language.** Only the words are translated — "Yesterday" becomes "Wczoraj", "5 min ago" becomes "5 min temu". The clock and the number formatting keep following your browser's own settings, so switching the menus to English will not suddenly turn your 24-hour clock into "9:53 AM". One display of large numbers on the repeater statistics page had been hard-coded to American thousands separators; it now follows your locale like everything else. + --- ## 2.4.2 — 2026-07-31 diff --git a/scripts/i18n_check.py b/scripts/i18n_check.py index 5fd466e..d977455 100644 --- a/scripts/i18n_check.py +++ b/scripts/i18n_check.py @@ -20,6 +20,14 @@ import sys from collections import defaultdict from pathlib import Path +# Catalog values and the --missing worklist contain non-ASCII text. Windows consoles +# default to a legacy code page, which would mangle them and corrupt a redirected file. +for _stream in (sys.stdout, sys.stderr): + try: + _stream.reconfigure(encoding='utf-8') + except (AttributeError, OSError): + pass + REPO = Path(__file__).resolve().parent.parent TRANSLATIONS = REPO / 'app' / 'translations' SCAN_GLOBS = ['app/templates/**/*.html', 'app/static/js/*.js'] @@ -129,19 +137,17 @@ def check_usage(en: dict, kinds: dict[str, set[str]], sites: dict[str, list[str] warn(f'en.json: unused key {key!r}') # Markup in a catalog value only survives through the _html variants. + # + # Only flagged in this direction. The reverse (_html used on a markup-free value) is + # not a problem and must not be warned about: what _html buys at an innerHTML sink is + # param escaping, not markup support. Warning there would push people toward t() in + # exactly the place where t() is the XSS hazard. for key, value in sorted(en.items()): if key not in kinds: continue - has_markup = any('<' in text for text in value_strings(value)) - used_plain = bool(kinds[key] & {'t', 'tn'}) - used_html = bool(kinds[key] & {'tHtml', 't_html'}) - - if has_markup and used_plain: - err(f'{sites[key][0]}: {key!r} contains markup but is used via t()/tn() — ' + if any('<' in text for text in value_strings(value)) and kinds[key] & {'t', 'tn'}: + err(f'{sites[key][0]}: {key!r} contains markup but is used via t()/tn() - ' f'use tHtml()/t_html()') - if not has_markup and used_html: - warn(f'{sites[key][0]}: {key!r} has no markup but is used via the _html ' - f'variant — t() is enough') def check_language(lang: str, en: dict, catalog: dict) -> float: