tl-split: draw the rest of the owl

This commit is contained in:
ed
2025-10-12 22:49:47 +00:00
parent ff01723c6d
commit d099e5e84e
17 changed files with 159 additions and 112 deletions

View File

@@ -481,10 +481,12 @@ rm -f ftp/pyftpdlib/{__main__,prefork}.py
langs="eng|$langs"
aerr "ERROR: removing english is not supported; will do this instead: $langs"
}
for f in copyparty/web/{browser.js,splash.js}; do
gzip -d "$f.gz" || true
iawk '/^\}/{l=0} !l; /^var Ls =/{l=1;next} !l{next} o; /^\t["}]/{o=0} /^\t"'"$langs"'"/{o=1;print}' $f
done
f=copyparty/web/browser.js
gzip -d "$f.gz" || true
iawk '/^\]/{s=0} !s; /^var LANGN /{s=1;next} !s{next} /"'"$langs"'"/' $f
ls -1 copyparty/web/tl/* >t
grep -vE "/($langs)\." <t | xargs -- rm
rm t
}
[ ! $repack ] && {

View File

@@ -113,6 +113,26 @@ copyparty/web/splash.html,
copyparty/web/splash.js,
copyparty/web/svcs.html,
copyparty/web/svcs.js,
copyparty/web/tl,
copyparty/web/tl/chi.js,
copyparty/web/tl/cze.js,
copyparty/web/tl/deu.js,
copyparty/web/tl/epo.js,
copyparty/web/tl/fin.js,
copyparty/web/tl/fra.js,
copyparty/web/tl/grc.js,
copyparty/web/tl/ita.js,
copyparty/web/tl/kor.js,
copyparty/web/tl/nld.js,
copyparty/web/tl/nno.js,
copyparty/web/tl/nor.js,
copyparty/web/tl/pol.js,
copyparty/web/tl/por.js,
copyparty/web/tl/rus.js,
copyparty/web/tl/spa.js,
copyparty/web/tl/swe.js,
copyparty/web/tl/tur.js,
copyparty/web/tl/ukr.js,
copyparty/web/ui.css,
copyparty/web/up2k.js,
copyparty/web/util.js,

View File

@@ -30,53 +30,48 @@ after editing tl.js, reload your webbrowser by pressing ctrl-shift-r
def generate_javascript(lang3, native_name, tl_browser):
note = "// NOTE: please use tabs for indenting, not spaces :-)"
if lang3 == "eng":
note += """\n
// NOTE: since you are using the tl.js straight from the repo, you'll
// need to find/replace all "eng" with your own three-letter name"""
note1 = ""
note2 = ""
if lang3 == "hmn":
note1 = ";\n// please adjust this (and the \"Ls.hmn\" further down)"
note2 = """
// the three-letter language-code "hmn" and language-name "Hymmnos"
// is used as an example; please replace these with your language
//"""
return f""""use strict";
{note}
// the three-letter name of the language you're translating to
// the three-letter name of the language you're translating to{note1}
var my_lang = "{lang3}";
// and because we don't know these yet...
var SR='', wah='';
// this function is automatically called when the page is loaded:
////////////////////////////////////////////////////////////////////////
// please ignore the next 5 lines:
var Ls={{}}, SR='', wah='';
function langmod() {{
// which page is the javascript currently running on?
// look for some well-known elements to figure it out:
if (QS("h1#cc") && QS("a#k")) {{
// we are running in the control-panel
Ls[my_lang] = tl_cpanel[my_lang];
}}
else if (ebi("op_cfg")) {{
// we are running in the filebrowser
Ls[my_lang] = tl_browser[my_lang];
// inform the settings tab that a new lang is available
LANGS.push(my_lang);
}}
if (window.LANGN)
LANGN.push([my_lang, Ls[my_lang].tt]);
}}
////////////////////////////////////////////////////////////////////////
// alright,
// below this point is where the actual translation happens;
// here is the pairs of "text-identifier": "text-to-translate"
////////////////////////////////////////////////////////////////////////
// translation of splash.js (the control-panel);
//{note2}
// you do not need to translate the TLNotes, those are just for you :-)
//
// when you are happy with this translation and want to submit it,
// copy the text below into a new file in the translations folder;
// https://github.com/9001/copyparty/tree/hovudstraum/copyparty/web/tl
var tl_cpanel = {{
"{lang3}": {{
Ls.{lang3} = {{
"tt": "{native_name}",
{tl_browser}
"splash": {{
"a1": "refresh",
"b1": "howdy stranger &nbsp; <small>(you're not logged in)</small>",
"c1": "logout",
@@ -115,21 +110,9 @@ var tl_cpanel = {{
"ac1": "enable no304",
"ad1": "enabling no304 will disable all caching; try this if k304 wasn't enough. This will waste a huge amount of network traffic!",
"ae1": "active downloads:",
"af1": "show recent uploads",
}},
"af1": "show recent uploads",
}}
}};
////////////////////////////////////////////////////////////////////////
// translation of browser.js (the filebrowser):
var tl_browser = {{
"{lang3}": {{
"tt": "{native_name}",
{tl_browser}
}};
"""
@@ -158,7 +141,8 @@ def main():
browserjs = f.read().decode("utf-8")
_, browserjs = browserjs.split('\n\t\t"tt": "English",\n', 1)
browserjs, _ = browserjs.split('\n\t"nor": {', 1)
browserjs, _ = browserjs.split('\n}', 1)
browserjs = browserjs.replace("\n\t", "\n")
try:
lang3 = sys.argv[1]

View File

@@ -1,13 +1,15 @@
#!/bin/bash
set -e
# usage: ./scripts/tlcheck.sh eng chi copyparty/web/browser.js
[ -f "$1" ] && [ -f "$2" ] && [ $# = 2 ] || {
echo usage: ./scripts/tlcheck.sh scripts/tl.js copyparty/web/tl/nor.js
exit 1
}
awk <"$3" -v lang1=\"$1\": -v lang2=\"$2\": '
/^\t\}/{fa=0;fb=0}
cat "$1" "$2" | awk '
/^\}/{fa=0;fb=0}
/^Ls\./{if(nln++){fb=1}else{fa=1}}
!/":/{next}
$0~lang1{fa=1}
$0~lang2{fb=1}
fa{a[ia++]=$0}
fb{b[ib++]=$0}
END{for (i=0;i<ia;i++) printf "%s\n%s\n\n",a[i],b[i]}