mirror of
https://github.com/ALLFATHER-BV/wadamesh.git
synced 2026-10-15 10:29:58 +00:00
pisti87 reported a long list of text that stays English whatever the language, and said the strings were in his language file and still did not appear (#257). Both halves are true, and the reason is the audit. The extractor only ever recognised TR("literal"). Three very common shapes were therefore invisible: mk_row_btn("Reload tiles in view", cb) // helper TR()s its parameter for (auto& r : rows) TR(r.label) // literal lives in a local table TR(contactsSortOptName(m)) // helper returns one of several All three translate correctly at runtime, so the source looks properly wrapped. But the literal at the call site was never emitted as a key, so it never entered a .lang file, so no translator could ever supply it -- and adding it by hand did nothing, because the audit's key list is what the files are checked against. That is 51 strings across the map options sheet, the sort sheets, the contacts filters and the home launcher. The audit now understands all three, plus tr("...") in the Lua apps, and the newly visible keys are in all thirteen files as placeholders so translators can see them. 1017 keys, up from 966. Four strings were genuinely raw and are now wrapped: the reader's idle status, the Discover empty feed, the crash-report export button and Paste (move/copy). Lua apps had no way to translate anything at all, so every built-in was hard English regardless of the device language. wada.sys.tr() gives them the same table the interface uses; airtime 1.4 is the first to use it, with the `sys.tr or identity` fallback so it still runs on older firmware. Two more instances of the drift this issue is really about: - gen-lua-builtin.py read out/firmware/apps/, which nothing writes -- the deploy rsyncs deploy/apps/ straight to the VPS. So the mirror was stale and the two apps added in beta_68 were never baked in: boards that cannot reach the Store shipped without them. It reads the canonical directory now, and regenerates from the same pre-build hook as the language table. - Baking a row whose translation equals its key does nothing, since TR() returns the key on a miss. Skipping them takes the header from 1.11 MB to 939 KB and gives the V4 back 16 KB of flash, which matters at 89%. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
47 lines
2.1 KiB
Python
47 lines
2.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""PlatformIO pre-build hook: keep the baked-in tables in step with deploy/apps/.
|
|
|
|
gen-lang-builtin.py's whole point is that the baked-in table and the .lang files
|
|
the store serves can never drift. That only holds if something runs it. Nothing
|
|
did: its docstring promised a pre-build step that was never wired up, so editing
|
|
a .lang and building produced an image with the OLD translations and no warning
|
|
(caught 2026-08-22 adding the Hungarian map credits, #257).
|
|
|
|
The same hazard applies to lua_builtin.h, which seeds the Lua apps into boards
|
|
that cannot reach the Store: it read a mirror directory nothing writes, so two
|
|
apps added in beta_68 were never baked in at all.
|
|
|
|
Regenerates only when a source file is newer than its generated output, so a
|
|
normal rebuild pays a handful of stat() calls.
|
|
"""
|
|
import glob, os, subprocess, sys
|
|
|
|
# PlatformIO runs pre: scripts through SConscript, where __file__ is undefined;
|
|
# there the project dir is the cwd. Standalone (the IDF build.sh) has __file__.
|
|
try:
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
except NameError:
|
|
ROOT = os.getcwd()
|
|
HERE = os.path.join(ROOT, "scripts", "build")
|
|
HDR = os.path.join(ROOT, "src", "ui-touch", "i18n_builtin.h")
|
|
GEN = os.path.join(HERE, "gen-lang-builtin.py")
|
|
LUAH = os.path.join(ROOT, "src", "ui-touch", "lua_builtin.h")
|
|
LUAG = os.path.join(HERE, "gen-lua-builtin.py")
|
|
|
|
def _stale(out, sources):
|
|
if not sources:
|
|
return False
|
|
return not os.path.exists(out) or os.path.getmtime(out) < max(os.path.getmtime(f) for f in sources)
|
|
|
|
|
|
if _stale(HDR, glob.glob(os.path.join(ROOT, "deploy", "apps", "lang", "*.lang"))):
|
|
print("i18n: a .lang changed, regenerating i18n_builtin.h")
|
|
subprocess.run([sys.executable, GEN], cwd=ROOT, check=True)
|
|
|
|
lua_src = glob.glob(os.path.join(ROOT, "deploy", "apps", "*", "*", "*.lua"))
|
|
lua_src += [os.path.join(ROOT, "deploy", "apps", "apps.json")]
|
|
if _stale(LUAH, [f for f in lua_src if os.path.exists(f)]):
|
|
print("lua: an app changed, regenerating lua_builtin.h")
|
|
subprocess.run([sys.executable, LUAG], cwd=ROOT, check=True)
|