From 632703628359c5e15af28b2a328901d3eaa84307 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Tue, 12 Mar 2024 06:45:03 -0400 Subject: [PATCH] Implement basic i18n Not fully functional yet, so this won't/shouldn't be pushed onto the site yet (no language dropdown, there are still quite a few hardcoded strings that need to become string keys ...) but it works more than well enough to at least test and add more things as string keys that are currently hardcoded. There are two languages provided, "en-us" and "pirate". Pirate is a test language to make sure all string keys are applying properly and all that. As a bonus the new I18n system also offers a slightly less boneheaded way to do replacements, which is much more flexible than blind replace calls, and can take any type which is able to be stringified. The parsing code for this is far from my best work, but it'll do for now, and seems to work okay (and has basic idiot proofing), so eh. Supersedes #13. --- .prettierignore | 1 - src/html/index.html | 30 ++--- src/ts/StringLike.ts | 9 ++ src/ts/i18n.ts | 209 ++++++++++++++++++++++++++++++ src/ts/main.ts | 32 +++-- src/ts/protocol/CollabVMClient.ts | 16 +-- src/ts/protocol/Guacutils.ts | 2 +- static/.gitkeep | 0 static/lang/en-us.json | 28 ++++ static/lang/pirate.json | 28 ++++ 10 files changed, 315 insertions(+), 40 deletions(-) create mode 100644 src/ts/StringLike.ts create mode 100644 src/ts/i18n.ts delete mode 100644 static/.gitkeep create mode 100644 static/lang/en-us.json create mode 100644 static/lang/pirate.json diff --git a/.prettierignore b/.prettierignore index 90e561d..ce6945c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,5 +1,4 @@ dist *.md -*.json *.html *.css \ No newline at end of file diff --git a/src/html/index.html b/src/html/index.html index 70be3b2..dca2cfe 100644 --- a/src/html/index.html +++ b/src/html/index.html @@ -15,9 +15,7 @@ - - - +