mirror of
https://github.com/ALLFATHER-BV/wadamesh.git
synced 2026-09-25 15:34:39 +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>
76 lines
3.2 KiB
Python
76 lines
3.2 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Bake the catalog's Lua apps into the firmware as seeded built-ins.
|
|
|
|
The Lua host already supports this: luaAppLaunchFile(id, title, embedded, len)
|
|
tries <data>/apps/<id>.lua first and falls back to an embedded source when the
|
|
file is not there. That file-first order is what makes a seeded app updatable —
|
|
download a newer version from the Store and the file simply wins.
|
|
|
|
This generates src/ui-touch/lua_builtin.h from deploy/apps/, i.e. exactly the
|
|
sources the Store serves, so a board that cannot reach the Store still ships
|
|
with the apps rather than an empty drawer.
|
|
|
|
It used to read out/firmware/apps/ instead. Nothing writes that directory --
|
|
deploy-apps.sh rsyncs deploy/apps/ straight to the VPS -- so it was a stale
|
|
mirror, and the "same sources the Store serves" guarantee was false: a bumped
|
|
app shipped to the Store while the baked-in copy stayed on whatever version was
|
|
mirrored last (#257).
|
|
|
|
Run from the repo root: python3 scripts/build/gen-lua-builtin.py
|
|
"""
|
|
import json, os, re, sys
|
|
|
|
ROOT = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
|
APPS = os.path.join(ROOT, 'deploy/apps') # canonical; what deploy-apps.sh publishes
|
|
OUT = os.path.join(ROOT, 'src/ui-touch/lua_builtin.h')
|
|
DELIM = 'WADALUA' # raw-string delimiter: keeps Lua source verbatim
|
|
|
|
|
|
def main():
|
|
cat_path = os.path.join(APPS, 'apps.json')
|
|
if not os.path.exists(cat_path):
|
|
sys.exit('no catalog at ' + cat_path)
|
|
cat = json.load(open(cat_path, encoding='utf-8'))['apps']
|
|
|
|
entries = []
|
|
for app in cat:
|
|
aid, ver, name = app['id'], app['ver'], app['name']
|
|
src = os.path.join(APPS, aid, ver, aid + '.lua')
|
|
if not os.path.exists(src):
|
|
print(' skip %s: no %s' % (aid, os.path.relpath(src, ROOT)))
|
|
continue
|
|
code = open(src, encoding='utf-8').read()
|
|
if (')' + DELIM + '"') in code:
|
|
sys.exit('%s contains the raw-string delimiter' % aid)
|
|
entries.append((aid, name, ver, code))
|
|
|
|
if not entries:
|
|
sys.exit('no app sources found under ' + APPS)
|
|
|
|
w = ['// Generated by scripts/build/gen-lua-builtin.py — DO NOT EDIT.',
|
|
'// Source: deploy/apps/ (the same .lua the Lua Store serves).',
|
|
'// Seeded built-ins: a downloaded <data>/apps/<id>.lua always wins.',
|
|
'#pragma once', '',
|
|
'struct LuaBuiltinApp { const char* id; const char* name; const char* ver; const char* src; };', '']
|
|
for aid, name, ver, code in entries:
|
|
w.append('static const char kLuaSrc_%s[] = R"%s(%s)%s";' % (aid, DELIM, code, DELIM))
|
|
w.append('')
|
|
w.append('static const LuaBuiltinApp kLuaBuiltin[] = {')
|
|
for aid, name, ver, _ in entries:
|
|
w.append(' { "%s", "%s", "%s", kLuaSrc_%s },' % (aid, name, ver, aid))
|
|
w.append('};')
|
|
w.append('static const int kLuaBuiltinCount = (int)(sizeof(kLuaBuiltin)/sizeof(kLuaBuiltin[0]));')
|
|
w.append('')
|
|
|
|
open(OUT, 'w', encoding='utf-8').write('\n'.join(w))
|
|
total = sum(len(c) for _, _, _, c in entries)
|
|
print('%s: %d apps, %d bytes of Lua' %
|
|
(os.path.relpath(OUT, ROOT), len(entries), total))
|
|
for aid, _, ver, code in entries:
|
|
print(' %-10s v%-4s %6d B' % (aid, ver, len(code)))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|