mirror of
https://github.com/openfrontio/OpenFrontIO.git
synced 2026-07-10 22:54:17 +00:00
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:
@@ -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,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user