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-25 09:12:04 +09:00
committed by GitHub
parent f188af6029
commit 9088adeb7a
14 changed files with 845 additions and 215 deletions
+11 -5
View File
@@ -4,6 +4,7 @@ import {
englishRecommendedTransformers,
} from "obscenity";
import { simpleHash } from "../Util";
import { translateText } from "../../client/Utils";
const matcher = new RegExpMatcher({
...englishDataset.build(),
@@ -41,28 +42,33 @@ export function validateUsername(username: string): {
error?: string;
} {
if (typeof username !== "string") {
return { isValid: false, error: "Username must be a string." };
return { isValid: false, error: translateText("username.not_string") };
}
if (username.length < MIN_USERNAME_LENGTH) {
return {
isValid: false,
error: `Username must be at least ${MIN_USERNAME_LENGTH} characters long.`,
error: translateText("username.too_short", {
min: MIN_USERNAME_LENGTH,
}),
};
}
if (username.length > MAX_USERNAME_LENGTH) {
return {
isValid: false,
error: `Username must not exceed ${MAX_USERNAME_LENGTH} characters.`,
error: translateText("username.too_long", {
max: MAX_USERNAME_LENGTH,
}),
};
}
if (!validPattern.test(username)) {
return {
isValid: false,
error:
"Username can only contain letters, numbers, spaces, underscores, and [square brackets].",
error: translateText("username.invalid_chars", {
max: MAX_USERNAME_LENGTH,
}),
};
}