From 859aae94c9a511d94451b127b00dd4e8eaf384d6 Mon Sep 17 00:00:00 2001 From: David Kotval Date: Wed, 24 Jan 2024 16:39:43 +0000 Subject: [PATCH 1/4] feat: added stub to automatically fill in transaltions A missing translation will cause a panic in the localization macro. As a short term solution. The stub function in the i18n_helper.py just fills anything missing with its English placeholder. Note: After refactoring the python packing, I intend to add an "auto machine translate" funciton as well. --- tools/i18n_helper.py | 253 +++++++++++++++++++++++++++++++------------ 1 file changed, 181 insertions(+), 72 deletions(-) diff --git a/tools/i18n_helper.py b/tools/i18n_helper.py index 76202e266..dbc9d1b77 100755 --- a/tools/i18n_helper.py +++ b/tools/i18n_helper.py @@ -8,42 +8,72 @@ import os.path import pwd import re -class Main(object): +class Main(object): def __init__(self): parser = argparse.ArgumentParser(description="Xous i18n Helper") - parser.add_argument('-v', '--verbose', - help='Prints details of each action', - action='store_true', required=False) - parser.add_argument('-l', '--list-languages', - help='Lists current translations', - action='store_true', required=False) - parser.add_argument('-i', '--list-i18n-files', - help='Lists i18n files', - action='store_true', required=False) - parser.add_argument('-m', '--missing', - help='Shows missing translations', - action='store_true', required=False) - parser.add_argument('-o', '--show-ok', - help='Shows OK translations', - action='store_true', required=False) - parser.add_argument('-n', '--new-lang', - help='Add support for a new lang', - required=False) - parser.add_argument('-f', '--from-lang', - help='Copy this existing lang for the new lang', - required=False) + parser.add_argument( + "-v", + "--verbose", + help="Prints details of each action", + action="store_true", + required=False, + ) + parser.add_argument( + "-l", + "--list-languages", + help="Lists current translations", + action="store_true", + required=False, + ) + parser.add_argument( + "-i", + "--list-i18n-files", + help="Lists i18n files", + action="store_true", + required=False, + ) + parser.add_argument( + "-m", + "--missing", + help="Shows missing translations", + action="store_true", + required=False, + ) + parser.add_argument( + "-o", + "--show-ok", + help="Shows OK translations", + action="store_true", + required=False, + ) + parser.add_argument( + "-n", "--new-lang", help="Add support for a new lang", required=False + ) + parser.add_argument( + "-f", + "--from-lang", + help="Copy this existing lang for the new lang", + required=False, + ) + parser.add_argument( + "-s", + "--stub", + help="fills in all missing translation with stub from EN", + action="store_true", + required=False, + ) self.args = parser.parse_args() self.args.program = sys.argv[0] - if self.args.program[0] != '/': + if self.args.program[0] != "/": self.args.program = os.path.join(os.getcwd(), self.args.program) self.args.pdir = os.path.normpath(os.path.dirname(self.args.program)) self.args.xousdir = os.path.normpath(os.path.dirname(self.args.pdir)) self.args.program = os.path.basename(self.args.program) self.errfile = sys.stderr # if end of string matches ' *EN*' (or some other lang) - self.temp_regex = re.compile('^.* \*[a-zA-Z]{2}\*$') - self.mt_regex = re.compile('^.* \*MT\*$') + self.temp_regex = re.compile("^.* \*[a-zA-Z]{2}\*$") + self.mt_regex = re.compile("^.* \*MT\*$") def out(self, *objects): print(*objects) @@ -56,15 +86,19 @@ class Main(object): self.err(*objects) def get_languages(self): - self.verr('-- get languages --') + self.verr("-- get languages --") # services/root-keys/locales/i18n.json - root_keys = os.path.join(self.args.xousdir, 'services', 'root-keys', 'locales', 'i18n.json') + root_keys = os.path.join( + self.args.xousdir, "services", "root-keys", "locales", "i18n.json" + ) if not os.path.exists(root_keys): - self.err('cannot find: %s' % root_keys); + self.err("cannot find: %s" % root_keys) return 1 # read keys in "rootkeys.backup_key": - essential = 'rootkeys.backup_key' - f = open(root_keys,) + essential = "rootkeys.backup_key" + f = open( + root_keys, + ) obj = json.load(f) self.languages = [] if essential in obj: @@ -76,34 +110,37 @@ class Main(object): def list_languages(self): if self.get_languages() != 0: return 1 - self.verr('-- list languages --') + self.verr("-- list languages --") for lang in self.languages: self.out(lang) return 0 def get_i18n_files(self): - self.verr('-- get i18n files --') + self.verr("-- get i18n files --") self.i18n_files = [] - topdirs = ['apps', 'services'] + topdirs = ["apps", "services", "libs"] + # TODO: use glob to replicate exactly how rust looks for them. for top in topdirs: topdir = os.path.join(self.args.xousdir, top) if os.path.exists(topdir): - if top == 'apps': - manifest = os.path.join(topdir, 'manifest.json') + if top == "apps": + manifest = os.path.join(topdir, "manifest.json") if os.path.exists(manifest): - self.i18n_files.append(manifest[len(self.args.xousdir)+1:]) + self.i18n_files.append(manifest[len(self.args.xousdir) + 1 :]) for thing in os.listdir(topdir): thingdir = os.path.join(topdir, thing) if os.path.isdir(thingdir): - i18n_path = os.path.join(thingdir, 'locales', 'i18n.json') + i18n_path = os.path.join(thingdir, "locales", "i18n.json") if os.path.exists(i18n_path): - self.i18n_files.append(i18n_path[len(self.args.xousdir)+1:]) + self.i18n_files.append( + i18n_path[len(self.args.xousdir) + 1 :] + ) return 0 def list_i18n_files(self): if self.get_i18n_files() != 0: return 1 - self.verr('-- list i18n files --') + self.verr("-- list i18n files --") for pathname in self.i18n_files: self.out(pathname) return 0 @@ -113,36 +150,86 @@ class Main(object): # other TAG def show_missing(self, i18n, is_manifest): i18n_path = os.path.join(self.args.xousdir, i18n) - f = open(i18n_path,) + f = open( + i18n_path, + ) obj = json.load(f) f.close() jqpath = None translation = None for tag in obj.keys(): if is_manifest: - appmenu = 'appmenu.' + tag - jqpath = tag + '.menu_name.' + appmenu - translation = obj[tag]['menu_name'][appmenu] + appmenu = "appmenu." + tag + jqpath = tag + ".menu_name." + appmenu + translation = obj[tag]["menu_name"][appmenu] else: jqpath = tag translation = obj[tag] for lang in self.languages: - lang_path = jqpath + '.' + lang - status = 'OK' + lang_path = jqpath + "." + lang + status = "OK" if lang in translation: t = translation[lang] # to print translation # print('%s\t%s\t%s' % (i18n, lang_path, t)) - if t == '🔇': - status = 'MISSING' + if t == "🔇": + status = "MISSING" elif self.mt_regex.fullmatch(t): - status = 'MACHINE_TRANSLATION' + status = "MACHINE_TRANSLATION" elif self.temp_regex.fullmatch(t): - status = 'TEMPORARY' + status = "TEMPORARY" else: - status = 'ABSENT' - if self.args.show_ok or status != 'OK': - print('%s\t%s\t%s' % (i18n, lang_path, status)) + status = "ABSENT" + if self.args.show_ok or status != "OK": + print("%s\t%s\t%s" % (i18n, lang_path, status)) + return 0 + + # TODO: make a call to chatgipptiy to attempt a machine translation + def stub_missing(self, i18n, is_manifest): + i18n_path = os.path.join(self.args.xousdir, i18n) + f = open( + i18n_path, + ) + obj = json.load(f) + f.close() + jqpath = None + translation = None + for tag in obj.keys(): + if is_manifest: + appmenu = "appmenu." + tag + jqpath = tag + ".menu_name." + appmenu + translation = obj[tag]["menu_name"][appmenu] + else: + jqpath = tag + translation = obj[tag] + for lang in self.languages: + lang_path = jqpath + "." + lang + if not lang in translation: + stub = f"{translation['en']} *EN*" + print(f"In {i18n}, at {lang_path} with en stub: {stub}") + translation[lang] = stub + # blow 'em away. That's what git is for after all. + with open(i18n_path, "w") as f: + json.dump( + obj, + f, + ensure_ascii=False, + check_circular=False, + sort_keys=True, + indent=4, + ) + return 0 + + def fill_missing_with_en_stub(self): + if self.get_languages() != 0: + return 1 + if self.get_i18n_files() != 0: + return 1 + self.verr("-- filling missing --") + for i18n in self.i18n_files: + is_manifest = os.path.basename(i18n) == "manifest.json" + if self.stub_missing(i18n, is_manifest) != 0: + return 1 return 0 def missing(self): @@ -150,9 +237,9 @@ class Main(object): return 1 if self.get_i18n_files() != 0: return 1 - self.verr('-- missing --') + self.verr("-- missing --") for i18n in self.i18n_files: - is_manifest = os.path.basename(i18n) == 'manifest.json' + is_manifest = os.path.basename(i18n) == "manifest.json" if self.show_missing(i18n, is_manifest) != 0: return 1 return 0 @@ -162,38 +249,49 @@ class Main(object): # other TAG def add_new_lang(self, i18n, is_manifest): i18n_path = os.path.join(self.args.xousdir, i18n) - i18n_path_orig = i18n_path + '.orig' + i18n_path_orig = i18n_path + ".orig" if not os.path.exists(i18n_path_orig): os.rename(i18n_path, i18n_path_orig) self.verr('adding "%s" to %s' % (self.args.new_lang, i18n)) - orig_file = open(i18n_path_orig,) + orig_file = open( + i18n_path_orig, + ) obj = json.load(orig_file) orig_file.close() - new_file = open(i18n_path,'w') + new_file = open(i18n_path, "w") translation = None for tag in obj.keys(): if is_manifest: - appmenu = 'appmenu.' + tag - translation = obj[tag]['menu_name'][appmenu] + appmenu = "appmenu." + tag + translation = obj[tag]["menu_name"][appmenu] else: translation = obj[tag] t_from = translation[self.args.from_lang] t_new = t_from - if t_from != '🔇': + if t_from != "🔇": t_new += self.from_hint translation[self.args.new_lang] = t_new - json.dump(obj, new_file, ensure_ascii=False, check_circular=False, - sort_keys=True, indent=4) + json.dump( + obj, + new_file, + ensure_ascii=False, + check_circular=False, + sort_keys=True, + indent=4, + ) new_file.close() return 0 def new_lang(self): if self.get_i18n_files() != 0: return 1 - self.from_hint = ' *%s*' % self.args.from_lang.upper() - self.verr('-- adding new lang "%s" from "%s" by appending "%s" --' % (self.args.new_lang, self.args.from_lang, self.from_hint)) + self.from_hint = " *%s*" % self.args.from_lang.upper() + self.verr( + '-- adding new lang "%s" from "%s" by appending "%s" --' + % (self.args.new_lang, self.args.from_lang, self.from_hint) + ) for i18n in self.i18n_files: - is_manifest = os.path.basename(i18n) == 'manifest.json' + is_manifest = os.path.basename(i18n) == "manifest.json" if self.add_new_lang(i18n, is_manifest) != 0: return 1 return 0 @@ -201,7 +299,7 @@ class Main(object): def run(self): rc = 0 if self.args.verbose: - self.err('verbose mode') + self.err("verbose mode") self.err('xous dir: "%s"' % self.args.xousdir) self.err('program dir: "%s"' % self.args.pdir) self.err('program: "%s"' % self.args.program) @@ -209,27 +307,38 @@ class Main(object): if self.args.list_languages: rc = self.list_languages() elif self.args.list_i18n_files: - rc = self.list_i18n_files() + rc = self.list_i18n_files() elif self.args.missing: rc = self.missing() + elif self.args.stub: + rc = self.fill_missing_with_en_stub() elif self.args.new_lang: if not self.args.from_lang: - self.err('error: you must specify both --from-lang en --to-lang fr') + self.err("error: you must specify both --from-lang en --to-lang fr") rc = 1 else: self.get_languages() if not self.args.from_lang in self.languages: - self.err('error: --from-lang %s is not one of the existing langs: %s' % (self.args.from_lang, self.languages)) + self.err( + "error: --from-lang %s is not one of the existing langs: %s" + % (self.args.from_lang, self.languages) + ) rc = 1 elif self.args.new_lang in self.languages: - self.err('error: --new-lang %s must not be one of the existing langs: %s' % (self.args.from_lang, self.languages)) + self.err( + "error: --new-lang %s must not be one of the existing langs: %s" + % (self.args.from_lang, self.languages) + ) rc = 1 - elif not re.fullmatch('^[a-z-]{2,6}$', self.args.new_lang): - self.err('error: --new-lang %s is not valid lang' % self.args.new_lang) + elif not re.fullmatch("^[a-z-]{2,6}$", self.args.new_lang): + self.err( + "error: --new-lang %s is not valid lang" % self.args.new_lang + ) rc = 1 else: rc = self.new_lang() return rc + if __name__ == "__main__": sys.exit(Main().run()) From 14da821164888c48dd1875aa771ef0056f70c93c Mon Sep 17 00:00:00 2001 From: David Kotval Date: Wed, 24 Jan 2024 16:42:36 +0000 Subject: [PATCH 2/4] fix: added English stubs to tls messages. --- libs/tls/locales/i18n.json | 152 +++++++++++++++++++++++++------------ 1 file changed, 103 insertions(+), 49 deletions(-) diff --git a/libs/tls/locales/i18n.json b/libs/tls/locales/i18n.json index 5ed746284..176f579ef 100644 --- a/libs/tls/locales/i18n.json +++ b/libs/tls/locales/i18n.json @@ -1,74 +1,128 @@ { "tls.check_trust_prompt": { "en": "Please select trusted certificate authorities.", - "en-tts": "Please select trusted certificate authorities." + "en-tts": "Please select trusted certificate authorities.", + "fr": "Please select trusted certificate authorities. *EN*", + "ja": "Please select trusted certificate authorities. *EN*", + "zh": "Please select trusted certificate authorities. *EN*" + }, + "tls.cmd": { + "en": "net tls ", + "en-tts": "net tls ", + "fr": "net tls *EN*", + "ja": "net tls *EN*", + "zh": "net tls *EN*" }, "tls.cmd_help": { "en": "Establishing an encrypted tls connection requires the host to provide a signed Certificate of identity. Each Certificate is signed for authenticity by a Certificate Authority. The CA's Certificate will in-turn be signed by yet another CA. These signed Certificates link into a chain of trust back to a trusted Root CA.\n\nTypically, this all happens automagically because many OS's & browsers incorporate a long list of trusted Root CA Certiicates. And this is OK because you trust the CA's that your OS trusts, right!\n\nOn Precursor, you must explicitly trust one or more root CA Certificates. You can:\nnet tls inspect \n\tto trust a specific CA Certificate, or\nnet tls mozilla\n\tto trust all of the CA Certificates incporporated in the Firefox browser.", - "en-tts": "Establishing an encrypted tls connection requires the host to provide a signed Certificate of identity. Each Certificate is signed for authenticity by a Certificate Authority. The CA's Certificate will in-turn be signed by yet another CA. These signed Certificates link into a chain of trust back to a trusted Root CA.\n\nTypically, this all happens automagically because many OS's & browsers incorporate a long list of trusted Root CA Certiicates. And this is OK because you trust the CA's that your OS trusts, right!\n\nOn Precursor, you must explicitly trust one or more root CA Certificates. You can:\nnet tls inspect \n\tto trust a specific CA Certificate, or\nnet tls mozilla\n\tto trust all of the CA Certificates incporporated in the Firefox browser." - }, - "tls.cmd": { - "en": "net tls ", - "en-tts": "net tls " + "en-tts": "Establishing an encrypted tls connection requires the host to provide a signed Certificate of identity. Each Certificate is signed for authenticity by a Certificate Authority. The CA's Certificate will in-turn be signed by yet another CA. These signed Certificates link into a chain of trust back to a trusted Root CA.\n\nTypically, this all happens automagically because many OS's & browsers incorporate a long list of trusted Root CA Certiicates. And this is OK because you trust the CA's that your OS trusts, right!\n\nOn Precursor, you must explicitly trust one or more root CA Certificates. You can:\nnet tls inspect \n\tto trust a specific CA Certificate, or\nnet tls mozilla\n\tto trust all of the CA Certificates incporporated in the Firefox browser.", + "fr": "Establishing an encrypted tls connection requires the host to provide a signed Certificate of identity. Each Certificate is signed for authenticity by a Certificate Authority. The CA's Certificate will in-turn be signed by yet another CA. These signed Certificates link into a chain of trust back to a trusted Root CA.\n\nTypically, this all happens automagically because many OS's & browsers incorporate a long list of trusted Root CA Certiicates. And this is OK because you trust the CA's that your OS trusts, right!\n\nOn Precursor, you must explicitly trust one or more root CA Certificates. You can:\nnet tls inspect \n\tto trust a specific CA Certificate, or\nnet tls mozilla\n\tto trust all of the CA Certificates incporporated in the Firefox browser. *EN*", + "ja": "Establishing an encrypted tls connection requires the host to provide a signed Certificate of identity. Each Certificate is signed for authenticity by a Certificate Authority. The CA's Certificate will in-turn be signed by yet another CA. These signed Certificates link into a chain of trust back to a trusted Root CA.\n\nTypically, this all happens automagically because many OS's & browsers incorporate a long list of trusted Root CA Certiicates. And this is OK because you trust the CA's that your OS trusts, right!\n\nOn Precursor, you must explicitly trust one or more root CA Certificates. You can:\nnet tls inspect \n\tto trust a specific CA Certificate, or\nnet tls mozilla\n\tto trust all of the CA Certificates incporporated in the Firefox browser. *EN*", + "zh": "Establishing an encrypted tls connection requires the host to provide a signed Certificate of identity. Each Certificate is signed for authenticity by a Certificate Authority. The CA's Certificate will in-turn be signed by yet another CA. These signed Certificates link into a chain of trust back to a trusted Root CA.\n\nTypically, this all happens automagically because many OS's & browsers incorporate a long list of trusted Root CA Certiicates. And this is OK because you trust the CA's that your OS trusts, right!\n\nOn Precursor, you must explicitly trust one or more root CA Certificates. You can:\nnet tls inspect \n\tto trust a specific CA Certificate, or\nnet tls mozilla\n\tto trust all of the CA Certificates incporporated in the Firefox browser. *EN*" }, "tls.deleteall_cmd": { "en": "delete ALL trusted Certificates", - "en-tts": "delete ALL trusted Certificates" + "en-tts": "delete ALL trusted Certificates", + "fr": "delete ALL trusted Certificates *EN*", + "ja": "delete ALL trusted Certificates *EN*", + "zh": "delete ALL trusted Certificates *EN*" }, "tls.deleteall_done": { "en": "deleted Certificates", - "en-tts": "deleted Certificates" - }, - "tls.list_cmd": { - "en": "list trusted CA certificates", - "en-tts": "list trusted CA certificates" - }, - "tls.mozilla_cmd": { - "en": "trust all Root CA's in webpki-roots", - "en-tts": "trust all Root CA's in webpki-roots" - }, - "tls.mozilla_progress": { - "en": "trusting Mozilla Root CA's", - "en-tts": "trusting Mozilla Root CA's" - }, - "tls.mozilla_done": { - "en": "trusted Root CA's", - "en-tts": "trusted Root CA's" + "en-tts": "deleted Certificates", + "fr": "deleted Certificates *EN*", + "ja": "deleted Certificates *EN*", + "zh": "deleted Certificates *EN*" }, "tls.inspect_cmd": { "en": "save host CA'a if trusted", - "en-tts": "save host CA'a if trusted" - }, - "tls.inspect_fail_servername": { - "en": "failed to create server name from", - "en-tts": "failed to create server name from" - }, - "tls.probe_invalid_certificate": { - "en": "Invalid certificate : ", - "en-tts": "Invalid certificate : " - }, - "tls.probe_help_not_valid_yet": { - "en": "error maybe caused by an improperly set clock", - "en-tts": "error maybe caused by an improperly set clock" + "en-tts": "save host CA'a if trusted", + "fr": "save host CA'a if trusted *EN*", + "ja": "save host CA'a if trusted *EN*", + "zh": "save host CA'a if trusted *EN*" }, "tls.inspect_done": { "en": "trusted CA's", - "en-tts": "trusted CA's" + "en-tts": "trusted CA's", + "fr": "trusted CA's *EN*", + "ja": "trusted CA's *EN*", + "zh": "trusted CA's *EN*" + }, + "tls.inspect_fail_servername": { + "en": "failed to create server name from", + "en-tts": "failed to create server name from", + "fr": "failed to create server name from *EN*", + "ja": "failed to create server name from *EN*", + "zh": "failed to create server name from *EN*" + }, + "tls.list_cmd": { + "en": "list trusted CA certificates", + "en-tts": "list trusted CA certificates", + "fr": "list trusted CA certificates *EN*", + "ja": "list trusted CA certificates *EN*", + "zh": "list trusted CA certificates *EN*" + }, + "tls.mozilla_cmd": { + "en": "trust all Root CA's in webpki-roots", + "en-tts": "trust all Root CA's in webpki-roots", + "fr": "trust all Root CA's in webpki-roots *EN*", + "ja": "trust all Root CA's in webpki-roots *EN*", + "zh": "trust all Root CA's in webpki-roots *EN*" + }, + "tls.mozilla_done": { + "en": "trusted Root CA's", + "en-tts": "trusted Root CA's", + "fr": "trusted Root CA's *EN*", + "ja": "trusted Root CA's *EN*", + "zh": "trusted Root CA's *EN*" + }, + "tls.mozilla_progress": { + "en": "trusting Mozilla Root CA's", + "en-tts": "trusting Mozilla Root CA's", + "fr": "trusting Mozilla Root CA's *EN*", + "ja": "trusting Mozilla Root CA's *EN*", + "zh": "trusting Mozilla Root CA's *EN*" + }, + "tls.probe_help_not_valid_yet": { + "en": "error maybe caused by an improperly set clock", + "en-tts": "error maybe caused by an improperly set clock", + "fr": "error maybe caused by an improperly set clock *EN*", + "ja": "error maybe caused by an improperly set clock *EN*", + "zh": "error maybe caused by an improperly set clock *EN*" + }, + "tls.probe_invalid_certificate": { + "en": "Invalid certificate : ", + "en-tts": "Invalid certificate : ", + "fr": "Invalid certificate : *EN*", + "ja": "Invalid certificate : *EN*", + "zh": "Invalid certificate : *EN*" }, "tls.test_cmd": { "en": "make tls connection to host", - "en-tts": "make tls connection to host" - }, - "tls.test_success_tcp": { - "en": "tcp connected\n", - "en-tts": "tcp connected" - }, - "tls.test_success_get": { - "en": "tls accepted GET\n", - "en-tts": "tls accepted GET" + "en-tts": "make tls connection to host", + "fr": "make tls connection to host *EN*", + "ja": "make tls connection to host *EN*", + "zh": "make tls connection to host *EN*" }, "tls.test_success_bytes": { "en": "tls received bytes", - "en-tts": "tls received bytes" + "en-tts": "tls received bytes", + "fr": "tls received bytes *EN*", + "ja": "tls received bytes *EN*", + "zh": "tls received bytes *EN*" + }, + "tls.test_success_get": { + "en": "tls accepted GET\n", + "en-tts": "tls accepted GET", + "fr": "tls accepted GET\n *EN*", + "ja": "tls accepted GET\n *EN*", + "zh": "tls accepted GET\n *EN*" + }, + "tls.test_success_tcp": { + "en": "tcp connected\n", + "en-tts": "tcp connected", + "fr": "tcp connected\n *EN*", + "ja": "tcp connected\n *EN*", + "zh": "tcp connected\n *EN*" } -} +} \ No newline at end of file From 701e5b46fe30de4c10a59badb7cc9468b3fc1665 Mon Sep 17 00:00:00 2001 From: David Kotval Date: Wed, 24 Jan 2024 16:45:46 +0000 Subject: [PATCH 3/4] feat: fill app manifest with English stubs --- apps/manifest.json | 79 ++++++++++++++++++++++++++++------------------ 1 file changed, 49 insertions(+), 30 deletions(-) diff --git a/apps/manifest.json b/apps/manifest.json index 6e00842f5..f97a0d821 100644 --- a/apps/manifest.json +++ b/apps/manifest.json @@ -3,8 +3,11 @@ "context_name": "App Loader", "menu_name": { "appmenu.app-loader": { - "en": "App Loader", - "en-tts": "App Loader" + "en": "App Loader", + "en-tts": "App Loader", + "fr": "App Loader *EN*", + "ja": "App Loader *EN*", + "zh": "App Loader *EN*" } }, "submenu": 2 @@ -21,6 +24,19 @@ } } }, + "chat-test": { + "context_name": "Chat UI test", + "menu_name": { + "appmenu.chat-test": { + "en": "Chat UI test", + "en-tts": "Chat UI test *EN*", + "fr": "Chat UI test *EN*", + "ja": "Chat UI test *EN*", + "zh": "Chat UI test *EN*" + } + }, + "submenu": 1 + }, "hello": { "context_name": "Hello World", "menu_name": { @@ -33,6 +49,19 @@ } } }, + "mtxchat": { + "context_name": "[matrix]", + "menu_name": { + "appmenu.mtxchat": { + "en": "[matrix]", + "en-tts": "[matrix] *EN*", + "fr": "[matrix] *EN*", + "ja": "[matrix] *EN*", + "zh": "[matrix] *EN*" + } + }, + "submenu": 1 + }, "mtxcli": { "context_name": "Matrix cli", "menu_name": { @@ -45,24 +74,6 @@ } } }, - "mtxchat": { - "context_name": "[matrix]", - "menu_name": { - "appmenu.mtxchat": { - "en": "[matrix]" - } - }, - "submenu": 1 - }, - "chat-test": { - "context_name": "Chat UI test", - "menu_name": { - "appmenu.chat-test": { - "en": "Chat UI test" - } - }, - "submenu": 1 - }, "repl": { "context_name": "repl demo app", "menu_name": { @@ -79,11 +90,27 @@ "context_name": "signal", "menu_name": { "appmenu.sigchat": { - "en": "Signal" + "en": "Signal", + "en-tts": "Signal *EN*", + "fr": "Signal *EN*", + "ja": "Signal *EN*", + "zh": "Signal *EN*" } }, "submenu": 1 }, + "transientdisk": { + "context_name": "Transient USB disk", + "menu_name": { + "appmenu.transientdisk": { + "en": "Transient USB disk", + "en-tts": "Transient USB disk *EN*", + "fr": "Transient USB disk *EN*", + "ja": "Transient USB disk *EN*", + "zh": "Transient USB disk *EN*" + } + } + }, "vault": { "context_name": "Key Vault", "menu_name": { @@ -96,13 +123,5 @@ } }, "submenu": 1 - }, - "transientdisk": { - "context_name": "Transient USB disk", - "menu_name": { - "appmenu.transientdisk": { - "en": "Transient USB disk" - } - } } -} +} \ No newline at end of file From fa20e3c649aaaef5fd28c51fab955db7bce7bc33 Mon Sep 17 00:00:00 2001 From: David Kotval Date: Wed, 24 Jan 2024 16:46:08 +0000 Subject: [PATCH 4/4] wip: debugging sigchat build fail due to missing translations --- locales/build.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/locales/build.rs b/locales/build.rs index d32dccccf..e050522ec 100644 --- a/locales/build.rs +++ b/locales/build.rs @@ -18,16 +18,30 @@ type Locale = String; type Value = String; type Translations = HashMap>; +macro_rules! build_debug { + ($($tokens: tt)*) => { + println!("cargo:warning={}", format!($($tokens)*)) + } +} + fn read_locales() -> Translations { let mut translations: Translations = HashMap::new(); - let project_dir = project_root(); + let mut project_dir = project_root(); let build_directory = project_dir.to_str().unwrap(); let locales = format!("{}/**/i18n.json", build_directory); - println!("Reading {}", &locales); - - for entry in glob(&locales).expect("Failed to read glob pattern") { + build_debug!("Reading {}", &locales); + // TODO: once this works, get from external directory/location arguments from xtask script + project_dir.pop(); //sibling directory + project_dir.push("sigchat"); + let external_directory = project_dir.to_str().unwrap(); + let external_locales = format!("{}/**/i18n.json", external_directory); + build_debug!("Reading external {}", &external_locales); + let paths = glob(&locales).expect("Failed to read glob pattern for in tree fiels"); + let external_paths = glob(&external_locales).expect("Filed to read glob pattern for external files"); + for entry in paths.chain(external_paths) { let entry = entry.unwrap(); + build_debug!("{:?}",entry); println!("cargo:rerun-if-changed={}", entry.display()); let file = File::open(entry).expect("Failed to open the file"); let mut reader = std::io::BufReader::new(file);