summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-04-03 17:02:15 +0200
committermetamuffin <metamuffin@disroot.org>2024-04-03 17:02:15 +0200
commit93d09d0aaef7586389daa360c1a361e915c4a228 (patch)
tree7aac353617952819d49b89eab28b9080759aa956
parent4903ef899abb88148a0835b5bde69f6de5a69a98 (diff)
downloadkeks-meet-93d09d0aaef7586389daa360c1a361e915c4a228.tar
keks-meet-93d09d0aaef7586389daa360c1a361e915c4a228.tar.bz2
keks-meet-93d09d0aaef7586389daa360c1a361e915c4a228.tar.zst
maybe autogen languages
-rw-r--r--client-web/scripts/autogen_locale.ts28
-rw-r--r--client-web/scripts/translate.py22
-rw-r--r--client-web/source/locale/ja.ts13
-rw-r--r--client-web/source/locale/mod.ts2
4 files changed, 65 insertions, 0 deletions
diff --git a/client-web/scripts/autogen_locale.ts b/client-web/scripts/autogen_locale.ts
new file mode 100644
index 0000000..c2f3d5b
--- /dev/null
+++ b/client-web/scripts/autogen_locale.ts
@@ -0,0 +1,28 @@
+// deno-lint-ignore-file no-explicit-any
+import { LOCALES } from "../source/locale/mod.ts";
+
+const global_lc = "en-US"
+
+function traverse_object(target: any, current: any): any {
+ if (typeof target == "string") return target
+ const out = {} as any
+ for (const key in target) {
+ if (!current) {
+ out[key] = target[key]
+ } else {
+ if (key in current) continue
+ out[key] = traverse_object(target[key], current)
+ }
+ }
+ return out
+}
+
+const master = LOCALES[global_lc]
+for (const lc in LOCALES) {
+ if (lc == global_lc) continue
+ const k = JSON.stringify(traverse_object(master, LOCALES[lc]));
+ if (k.length <= 2) continue
+ console.log(
+ `New strings required in ${lc}:\n\t${k}`
+ );
+}
diff --git a/client-web/scripts/translate.py b/client-web/scripts/translate.py
new file mode 100644
index 0000000..8e7de0c
--- /dev/null
+++ b/client-web/scripts/translate.py
@@ -0,0 +1,22 @@
+import json
+import sys
+from argostranslate import translate
+
+srclang = "en"
+dstlang = sys.argv[1]
+
+installed_languages = { lang.code: lang for lang in translate.load_installed_languages() }
+if srclang not in installed_languages:
+ raise Exception(f"need language {srclang}")
+if dstlang not in installed_languages:
+ raise Exception(f"need language {dstlang}")
+srclang = installed_languages[srclang]
+dstlang = installed_languages[dstlang]
+translator = srclang.get_translation(dstlang)
+if translator is None:
+ raise Exception("no translator available")
+
+
+print(json.loads("".join(sys.stdin)))
+
+print(translator.translate("Hello world"))
diff --git a/client-web/source/locale/ja.ts b/client-web/source/locale/ja.ts
new file mode 100644
index 0000000..4925667
--- /dev/null
+++ b/client-web/source/locale/ja.ts
@@ -0,0 +1,13 @@
+
+
+/*
+ This file is part of keks-meet (https://codeberg.org/metamuffin/keks-meet)
+ which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
+ Copyright (C) 2024 metamuffin <metamuffin.org>
+*/
+import { LanguageStrings } from "./mod.ts";
+
+// @ts-ignore
+export const PO_JA_JA: LanguageStrings = {
+
+}
diff --git a/client-web/source/locale/mod.ts b/client-web/source/locale/mod.ts
index 55aa79d..0f5fc77 100644
--- a/client-web/source/locale/mod.ts
+++ b/client-web/source/locale/mod.ts
@@ -1,6 +1,7 @@
import { PO_DE_DE } from "./de.ts";
import { PO_EN_US } from "./en.ts";
import { PREF_DECLS } from "../preferences/decl.ts";
+import { PO_JA_JA } from "./ja.ts";
export let PO: LanguageStrings;
@@ -16,6 +17,7 @@ export const LOCALES: { [key: string]: LanguageStrings } = {
"en-GB": PO_EN_US, // close enough
"de": PO_DE_DE,
"de-DE": PO_DE_DE,
+ "ja-JA": PO_JA_JA,
}
export interface LanguageStrings {