diff --git a/data/lang_install.sh b/data/lang_install.sh index 867d847..39afde4 100644 --- a/data/lang_install.sh +++ b/data/lang_install.sh @@ -65,6 +65,10 @@ fi mv -f /tmp/base.*.lmo $DIR_PATCH/ mv -f /tmp/lang_patch.sh $DIR_PATCH/ chmod +x $DIR_PATCH/lang_patch.sh +if [ -f /tmp/lang_patch_www.sh ]; then + mv -f /tmp/lang_patch_www.sh $DIR_PATCH/ + chmod +x $DIR_PATCH/lang_patch_www.sh +fi INSTALL_METHOD=2 if [ ! -e "/usr/lib/os-release" ]; then diff --git a/data/lang_patch.sh b/data/lang_patch.sh index f325f64..dbe729f 100644 --- a/data/lang_patch.sh +++ b/data/lang_patch.sh @@ -70,6 +70,12 @@ sed -i 's/ and features\["system"\]\["i18n"\] == "1" //' /usr/lib/lua/luci/view/ rm -rf $SYNCOBJECT2 +# Wrap the hardcoded Chinese of the www templates in <%: %> so the LMO can +# translate it. The templates live in the tmpfs mirror mounted above, which is +# rebuilt from the read-only squashfs on every boot, so this has to run here on +# every boot - after the bind mount and before luci-reload. +[ -x $DIR_PATCH/lang_patch_www.sh ] && sh $DIR_PATCH/lang_patch_www.sh > /tmp/lang_patch_www.log 2>&1 + echo "lang patched" > $INST_FLAG_FN MAIN_LANG=$( uci -q get luci.main.lang ) diff --git a/data/lang_uninstall.sh b/data/lang_uninstall.sh index f6ccca2..c682667 100644 --- a/data/lang_uninstall.sh +++ b/data/lang_uninstall.sh @@ -37,8 +37,15 @@ uci commit firewall rm -rf $DIR_BACKUP rm -f $DIR_PATCH/lang_patch.sh +rm -f $DIR_PATCH/lang_patch_www.sh rm -f $DIR_PATCH/base.*.lmo rm -f $INST_FLAG_FN +rm -f /tmp/lang_patch_www.log +# The <%: %> wrapping applied by lang_patch_www.sh is not undone here: the +# templates under /usr/lib/lua/luci/view live in a tmpfs mirror that is rebuilt +# from the read-only squashfs on every boot, so it disappears by itself. Until +# then the wrapping is harmless - LuCI prints the original text when the +# catalogue holds no translation for it. rm -f $SYNCOBJECT1 rm -f $SYNCOBJECT2 diff --git a/install_lang.py b/install_lang.py index 03305c8..26b16b2 100644 --- a/install_lang.py +++ b/install_lang.py @@ -242,8 +242,9 @@ gw.run_cmd(f"chmod +x {run_script} ; {run_script}", timeout = 17) time.sleep(1.5) gw.run_cmd(f"rm -f {fn_remote} ; rm -f {fn_remote_i} ; rm -f {fn_remote_u}") -if full_install: - gw.run_cmd(f"rm -f {fn_www_remote}") +# lang_patch_www.sh is deliberately not removed here: lang_install.sh moves it +# into /etc/crontabs/patches, and should that move not have happened this is the +# only copy left. It lives in tmpfs, so a stale one is gone after a reboot. prefix = '' if action == 'install' else 'un' print(f"Ready! The language files are {prefix}installed.")