Translate all out-of-game UI (start screen, lobbies, etc.) (#316)

This PR adds full translation support for all out-of-game UI elements,
including the start screen, public/private lobby modals, and other
pre-game interfaces.

All static text has been externalized to en.json and ja.json for future
language support.
If you find any spots that are not yet translated (missing from the
JSON), please let me know.
Thanks a lot!

This is a follow-up to PR
[#305](https://github.com/openfrontio/OpenFrontIO/pull/305).

---------

Co-authored-by: Cldprv <dubois.cnm@tutanota.com>
Co-authored-by: jacks0n <rosty.west89@gmail.com>
This commit is contained in:
Aotumuri
2025-03-24 17:12:04 -07:00
committed by GitHub
co-authored by Cldprv jacks0n
parent f188af6029
commit 9088adeb7a
14 changed files with 845 additions and 215 deletions
+27
View File
@@ -70,3 +70,30 @@ export function generateCryptoRandomUUID(): string {
},
);
}
export function translateText(
key: string,
params: Record<string, string | number> = {},
): string {
const keys = key.split(".");
let text: any = (window as any).translations;
for (const k of keys) {
text = text?.[k];
if (!text) break;
}
if (!text && (window as any).defaultTranslations) {
text = (window as any).defaultTranslations;
for (const k of keys) {
text = text?.[k];
if (!text) return key;
}
}
for (const [param, value] of Object.entries(params)) {
text = text.replace(`{${param}}`, String(value));
}
return text;
}