feat(ui): add chinese localization#160
Conversation
|
@Craun718 is attempting to deploy a commit to the retrofor Team on Vercel. A member of the Team first needs to authorize it. |
Reviewer's GuideAdds a full i18n system with English and Chinese message dictionaries, wires a global LanguageProvider into the app, and replaces hard-coded UI strings, validation messages, toast texts, and labels across settings, instances, login, editor, and navigation with locale-aware translations and language switching. File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues, and left some high level feedback:
- Several user-facing strings are still created outside the i18n hook via
translate(...)at module initialization (e.g., zod schemas increate.tsx, stepper titles, and messages in the auth/instance/settings stores), so those messages won’t reflect runtime locale changes; consider moving them into components/hooks or passing a translated string from the caller so they react to language switches. - The duplicate-instance default name was changed to append the literal string
Copy(inInstancesPage), which will remain English even in Chinese; consider using a localized template viat(...)(e.g., something liket("instances.copyName", { name: instance.name })).
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Several user-facing strings are still created outside the i18n hook via `translate(...)` at module initialization (e.g., zod schemas in `create.tsx`, stepper titles, and messages in the auth/instance/settings stores), so those messages won’t reflect runtime locale changes; consider moving them into components/hooks or passing a translated string from the caller so they react to language switches.
- The duplicate-instance default name was changed to append the literal string `Copy` (in `InstancesPage`), which will remain English even in Chinese; consider using a localized template via `t(...)` (e.g., something like `t("instances.copyName", { name: instance.name })`).
## Individual Comments
### Comment 1
<location path="packages/ui/src/components/login-modal.tsx" line_range="72-81" />
<code_context>
- Login to your Minecraft account or play offline
- </DialogDescription>
+ <DialogTitle>{t("login.title")}</DialogTitle>
+ <DialogDescription>{t("login.desc")}</DialogDescription>
</DialogHeader>
<div className="p-4 w-full overflow-hidden">
</code_context>
<issue_to_address>
**issue:** Avoid duplicating URL/code text now that `login.instructions` includes them
`login.instructions` already interpolates `{url}`, `{code}`, and `{seconds}`, but the JSX still renders the link and code separately. This can lead to duplicated/awkward text and harder translations. Either let `login.instructions` provide the full sentence and remove the extra `url`/`code` rendering here, or make `login.instructions` only define the generic sentence structure and keep the explicit `<a>`/`<code>` elements in JSX. That way the wording is defined in exactly one place and translators have a clearer structure.
</issue_to_address>
### Comment 2
<location path="packages/ui/src/pages/instances/index.tsx" line_range="86" />
<code_context>
const openDuplicate = (instance: Instance) => {
setSelectedInstance(instance);
- setDuplicateName(`${instance.name} (Copy)`);
+ setDuplicateName(`${instance.name} Copy`);
setShowDuplicateModal(true);
};
</code_context>
<issue_to_address>
**suggestion:** The default duplicate suffix is hardcoded in English; consider localizing it
Since the rest of this page is localized, it would be better to move this suffix into the i18n layer, e.g. via a key like `instances.copySuffix` or a template like `instances.copyNameTemplate` that takes the original name. That lets languages control both wording and word order.
Suggested implementation:
```typescript
const openDuplicate = (instance: Instance) => {
setSelectedInstance(instance);
setDuplicateName(
t("instances.copyNameTemplate", { name: instance.name })
);
setShowDuplicateModal(true);
};
```
1. Add a new i18n key `instances.copyNameTemplate` in all locale files. For English, a suitable value would be `{{name}} Copy`.
2. Adjust the translation value per language to control both wording and word order as appropriate (e.g., `"Copy of {{name}}"`, `"Kopie von {{name}}"`, etc.).
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| <DialogDescription>{t("login.desc")}</DialogDescription> | ||
| </DialogHeader> | ||
| <div className="p-4 w-full overflow-hidden"> | ||
| {!authStore.loginMode && ( | ||
| <div className="flex flex-col space-y-4"> | ||
| <Button size="lg" onClick={handleMicrosoftLogin}> | ||
| <Mail /> | ||
| Login with Microsoft | ||
| {t("login.microsoft")} | ||
| </Button> | ||
| <Button |
There was a problem hiding this comment.
issue: Avoid duplicating URL/code text now that login.instructions includes them
login.instructions already interpolates {url}, {code}, and {seconds}, but the JSX still renders the link and code separately. This can lead to duplicated/awkward text and harder translations. Either let login.instructions provide the full sentence and remove the extra url/code rendering here, or make login.instructions only define the generic sentence structure and keep the explicit <a>/<code> elements in JSX. That way the wording is defined in exactly one place and translators have a clearer structure.
| const openDuplicate = (instance: Instance) => { | ||
| setSelectedInstance(instance); | ||
| setDuplicateName(`${instance.name} (Copy)`); | ||
| setDuplicateName(`${instance.name} Copy`); |
There was a problem hiding this comment.
suggestion: The default duplicate suffix is hardcoded in English; consider localizing it
Since the rest of this page is localized, it would be better to move this suffix into the i18n layer, e.g. via a key like instances.copySuffix or a template like instances.copyNameTemplate that takes the original name. That lets languages control both wording and word order.
Suggested implementation:
const openDuplicate = (instance: Instance) => {
setSelectedInstance(instance);
setDuplicateName(
t("instances.copyNameTemplate", { name: instance.name })
);
setShowDuplicateModal(true);
};- Add a new i18n key
instances.copyNameTemplatein all locale files. For English, a suitable value would be{{name}} Copy. - Adjust the translation value per language to control both wording and word order as appropriate (e.g.,
"Copy of {{name}}","Kopie von {{name}}", etc.).
Summary by Sourcery
Introduce a localization system with English and Chinese support and apply it across key UI flows, including settings, instances, authentication, and instance editing.
New Features:
Enhancements: