A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(editor): i18n foundation - zh-CN/en on the engine's own LocalizationApi
yhha1f9f74c453a
diff --git a/desktop/src/commands/editorCommands.ts b/desktop/src/commands/editorCommands.tsindex c64f6aea8..2afcca8c1 100644--- a/desktop/src/commands/editorCommands.ts+++ b/desktop/src/commands/editorCommands.ts@@ -25,6 +25,7 @@ import { useEditorMode } from '@/store/editorModeStore';import { useEditorStore } from '@/store/editorStore';import { useSelection } from '@/store/selectionStore';import { Toasts } from '@/store/Toasts';+import { t } from '@/i18n';import type { ToolMode } from '@/types';const editor = () => useEditorStore.getState();@@ -34,26 +35,26 @@ const tool = (mode: ToolMode) => () => editor().setTool(mode);// — File / project —commands.register({id: 'scene.new',- label: 'New Scene',- category: 'File',+ label: t('cmd.scene.new'),+ category: t('cat.file'),keybinding: 'mod+n',isEnabled: () => !!ProjectStore.getSnapshot(),run: async () => {- if (!(await confirmDiscard('Creating a new scene will discard them'))) return;+ if (!(await confirmDiscard(t('discard.newScene')))) return;void ProjectStore.newScene().then(() => sel().select(null));},});commands.register({id: 'project.open',- label: 'Open Project…',- category: 'File',+ label: t('cmd.project.open'),+ category: t('cat.file'),keybinding: 'mod+o',run: () => void ProjectStore.openViaDialog().then((ok) => ok && sel().select(null)),});commands.register({id: 'project.save',- label: 'Save Scene',- category: 'File',+ label: t('cmd.project.save'),+ category: t('cat.file'),keybinding: 'mod+s',// Enabled while there are unsaved edits, or the scene is untitled (Save → Save As// to give it a path on disk for the first time).@@ -65,26 +66,26 @@ commands.register({});commands.register({id: 'project.saveAs',- label: 'Save Scene As…',- category: 'File',+ label: t('cmd.project.saveAs'),+ category: t('cat.file'),keybinding: 'mod+shift+s',isEnabled: () => !!ProjectStore.getSnapshot(),run: () => void ProjectStore.saveAsViaDialog(),});commands.register({id: 'project.export',- label: 'Build…',- category: 'File',+ label: t('cmd.project.export'),+ category: t('cat.file'),isEnabled: () => !!ProjectStore.getSnapshot(),run: () => editor().setBuildOpen(true),});commands.register({id: 'project.close',- label: 'Close Project',- category: 'File',+ label: t('cmd.project.close'),+ category: t('cat.file'),isEnabled: () => !!ProjectStore.getSnapshot(),run: async () => {- if (!(await confirmDiscard('Closing the project will discard them'))) return;+ if (!(await confirmDiscard(t('discard.closeProject')))) return;editor().openLauncher();},});@@ -92,16 +93,16 @@ commands.register({// — Edit / history —commands.register({id: 'edit.undo',- label: 'Undo',- category: 'Edit',+ label: t('cmd.edit.undo'),+ category: t('cat.edit'),keybinding: 'mod+z',isEnabled: () => EditorHistory.canUndo(),run: () => EditorHistory.undo(),});commands.register({id: 'edit.redo',- label: 'Redo',- category: 'Edit',+ label: t('cmd.edit.redo'),+ category: t('cat.edit'),keybinding: ['mod+shift+z', 'mod+y'],isEnabled: () => EditorHistory.canRedo(),run: () => EditorHistory.redo(),@@ -110,8 +111,8 @@ commands.register({// — Entity —commands.register({id: 'entity.add',- label: 'Add Entity',- category: 'Entity',+ label: t('cmd.entity.add'),+ category: t('cat.entity'),run: () => {const e = SceneCommands.addEntity();if (e != null) sel().select(e);@@ -119,8 +120,8 @@ commands.register({});commands.register({id: 'tilemap.new',- label: 'New Tilemap',- category: 'Entity',+ label: t('cmd.tilemap.new'),+ category: t('cat.entity'),isEnabled: () => !!ProjectStore.getSnapshot(),// A tilemap needs a tileset palette. Zero → guide the user to make one; exactly// one → create straight away; many → let them pick (TilemapPickerDialog). The@@ -128,7 +129,7 @@ commands.register({run: () => {const list = ProjectStore.listAssets('tileset');if (list.length === 0) {- Toasts.push('No tileset in the project yet — right-click a texture in the Content Browser → Create Tileset', 'warn');+ Toasts.push(t('toast.noTileset'), 'warn');return;}if (list.length === 1) {@@ -141,8 +142,8 @@ commands.register({});commands.register({id: 'entity.duplicate',- label: 'Duplicate',- category: 'Entity',+ label: t('cmd.entity.duplicate'),+ category: t('cat.entity'),keybinding: 'mod+d',isEnabled: () => sel().selectedId != null,run: () => {@@ -154,8 +155,8 @@ commands.register({});commands.register({id: 'entity.delete',- label: 'Delete',- category: 'Entity',+ label: t('cmd.entity.delete'),+ category: t('cat.entity'),keybinding: ['delete', 'backspace'],isEnabled: () => sel().selectedIds.size > 0,// Despawn self-heals the selection (SelectionStore) — no manual deselect.@@ -163,24 +164,24 @@ commands.register({});commands.register({id: 'entity.copy',- label: 'Copy',- category: 'Entity',+ label: t('cmd.entity.copy'),+ category: t('cat.entity'),keybinding: 'mod+c',isEnabled: () => sel().selectedIds.size > 0,run: () => { SceneCommands.copyEntities([...sel().selectedIds]); },});commands.register({id: 'entity.cut',- label: 'Cut',- category: 'Entity',+ label: t('cmd.entity.cut'),+ category: t('cat.entity'),keybinding: 'mod+x',isEnabled: () => sel().selectedIds.size > 0,run: () => { SceneCommands.cutEntities([...sel().selectedIds]); },});commands.register({id: 'entity.paste',- label: 'Paste',- category: 'Entity',+ label: t('cmd.entity.paste'),+ category: t('cat.entity'),keybinding: 'mod+v',isEnabled: () => hasEntityClipboard(),// Paste under the lone selection's parent (as a sibling), else at the scene root.@@ -193,8 +194,8 @@ commands.register({});commands.register({id: 'edit.selectAll',- label: 'Select All',- category: 'Edit',+ label: t('cmd.edit.selectAll'),+ category: t('cat.edit'),keybinding: 'mod+a',isEnabled: () => SceneModel.entityOrder().length > 0,run: () => {@@ -204,17 +205,17 @@ commands.register({});commands.register({id: 'entity.deselect',- label: 'Deselect',- category: 'Entity',+ label: t('cmd.entity.deselect'),+ category: t('cat.entity'),isEnabled: () => sel().selectedId != null,run: () => sel().select(null),});// — Transform tools —-commands.register({ id: 'tool.select', label: 'Select Tool', category: 'Tools', keybinding: 'q', run: tool('select') });-commands.register({ id: 'tool.move', label: 'Move Tool', category: 'Tools', keybinding: 'w', run: tool('move') });-commands.register({ id: 'tool.rotate', label: 'Rotate Tool', category: 'Tools', keybinding: 'e', run: tool('rotate') });-commands.register({ id: 'tool.scale', label: 'Scale Tool', category: 'Tools', keybinding: 'r', run: tool('scale') });+commands.register({ id: 'tool.select', label: t('cmd.tool.select'), category: t('cat.tools'), keybinding: 'q', run: tool('select') });+commands.register({ id: 'tool.move', label: t('cmd.tool.move'), category: t('cat.tools'), keybinding: 'w', run: tool('move') });+commands.register({ id: 'tool.rotate', label: t('cmd.tool.rotate'), category: t('cat.tools'), keybinding: 'e', run: tool('rotate') });+commands.register({ id: 'tool.scale', label: t('cmd.tool.scale'), category: t('cat.tools'), keybinding: 'r', run: tool('scale') });// — Editor modes — pin an explicit editing context (Scene/UI/Tilemap) and reveal its// companion panels. Without a pin the mode follows the selection; a pin holds until the@@ -223,8 +224,8 @@ commands.register({ id: 'tool.scale', label: 'Scale Tool', category: 'Tools', kefor (const m of EDITOR_MODES) {commands.register({id: `mode.${m.id}`,- label: `${m.label} Mode`,- category: 'Tools',+ label: t(`cmd.mode.${m.id}`),+ category: t('cat.tools'),isChecked: () => activeMode().id === m.id,run: () => {useEditorMode.getState().setMode(m.id);@@ -269,8 +270,8 @@ const NUDGES: Array<{ id: string; key: string; ux: number; uy: number; big: boolfor (const n of NUDGES) {commands.register({id: n.id,- label: 'Nudge Selection',- category: 'Entity',+ label: t('cmd.entity.nudge'),+ category: t('cat.entity'),keybinding: n.key,isEnabled: () => sel().selectedIds.size > 0,run: () => nudgeSelection(n.ux, n.uy, n.big),@@ -280,8 +281,8 @@ for (const n of NUDGES) {// — Viewport / view —commands.register({id: 'view.frameSelected',- label: 'Frame Selected',- category: 'View',+ label: t('cmd.view.frameSelected'),+ category: t('cat.view'),keybinding: 'f',isEnabled: () => sel().selectedId != null,run: () => {@@ -294,22 +295,22 @@ commands.register({});commands.register({id: 'view.toggleGrid',- label: 'Show Grid',- category: 'View',+ label: t('cmd.view.toggleGrid'),+ category: t('cat.view'),isChecked: () => editor().showGrid,run: () => editor().toggleGrid(),});commands.register({id: 'view.toggleGizmos',- label: 'Show Gizmos',- category: 'View',+ label: t('cmd.view.toggleGizmos'),+ category: t('cat.view'),isChecked: () => editor().showGizmos,run: () => editor().toggleGizmos(),});commands.register({id: 'view.togglePreviewFx',- label: 'Preview FX',- category: 'View',+ label: t('cmd.view.togglePreviewFx'),+ category: t('cat.view'),isChecked: () => editor().previewFx,run: () => {editor().togglePreviewFx();@@ -318,29 +319,29 @@ commands.register({});commands.register({id: 'view.toggleColliders',- label: 'Show Colliders',- category: 'View',+ label: t('cmd.view.toggleColliders'),+ category: t('cat.view'),isChecked: () => editor().showColliders,run: () => editor().toggleColliders(),});commands.register({id: 'view.toggleCoordSpace',- label: 'Local Axes',- category: 'View',+ label: t('cmd.view.toggleCoordSpace'),+ category: t('cat.view'),isChecked: () => editor().coordSpace === 'local',run: () => editor().toggleCoordSpace(),});commands.register({id: 'view.togglePivotMode',- label: 'Pivot (vs Center)',- category: 'View',+ label: t('cmd.view.togglePivotMode'),+ category: t('cat.view'),isChecked: () => editor().pivotMode === 'pivot',run: () => editor().togglePivotMode(),});commands.register({id: 'view.toggleSnapping',- label: 'Snapping',- category: 'View',+ label: t('cmd.view.toggleSnapping'),+ category: t('cat.view'),isChecked: () => editor().snapping,run: () => editor().toggleSnapping(),});@@ -348,8 +349,8 @@ commands.register({// — Editor —commands.register({id: 'settings.open',- label: 'Settings…',- category: 'Editor',+ label: t('cmd.settings.open'),+ category: t('cat.editor'),keybinding: 'mod+,',run: () => editor().setSettingsOpen(true),});@@ -357,15 +358,15 @@ commands.register({// — Play —commands.register({id: 'play.toggle',- label: 'Play',- category: 'Play',+ label: t('cmd.play.toggle'),+ category: t('cat.play'),keybinding: 'f5',run: () => editor().togglePlay(),});commands.register({id: 'play.stop',- label: 'Stop',- category: 'Play',+ label: t('cmd.play.stop'),+ category: t('cat.play'),keybinding: 'escape',isEnabled: () => editor().isPlaying,run: () => editor().stop(),@@ -374,12 +375,12 @@ commands.register({// — Build —commands.register({id: 'build.scripts',- label: 'Build Project Scripts',- category: 'Build',+ label: t('cmd.build.scripts'),+ category: t('cat.build'),isEnabled: () => !!ProjectStore.getSnapshot(),run: () =>void window.estella?.project?.buildScripts?.()- .then(() => Toasts.push('Built project scripts', 'success'))- .catch(() => Toasts.push('Build failed', 'error')),+ .then(() => Toasts.push(t('toast.builtScripts'), 'success'))+ .catch(() => Toasts.push(t('toast.buildFailed'), 'error')),});diff --git a/desktop/src/components/SettingsDialog.tsx b/desktop/src/components/SettingsDialog.tsxindex 18b256e1b..55ac80dae 100644--- a/desktop/src/components/SettingsDialog.tsx+++ b/desktop/src/components/SettingsDialog.tsx@@ -22,6 +22,7 @@ import { SearchField } from '@/components/SearchField';import { Segmented } from '@/components/Segmented';import { Select } from '@/components/Select';import type { Setting, NumberSetting, KeybindingSetting, StringListSetting, MatrixSetting, FlagListSetting } from '@/settings/types';+import { t } from '@/i18n';// A bound list setting's getter returns a fresh array each call; useShallow below// keeps the read referentially stable (else useSyncExternalStore loops). A shared@@ -29,9 +30,9 @@ import type { Setting, NumberSetting, KeybindingSetting, StringListSetting, Matrconst EMPTY_LIST: readonly string[] = [];const CATEGORY_LABEL: Record<string, string> = {- editor: 'Editor',- project: 'Project',- plugin: 'Plugins',+ editor: t('set.cat.editor'),+ project: t('set.cat.project'),+ plugin: t('set.cat.plugin'),};const clamp = (v: number, lo: number, hi: number) => Math.max(lo, Math.min(hi, v));@@ -121,10 +122,10 @@ function KeybindCapture({ setting }: { setting: KeybindingSetting }) {<buttontype="button"className={`set-key${capturing ? ' capturing' : ''}`}- title="Click to rebind"+ title={t('set.rebindHint')}onClick={() => setCapturing((c) => !c)}>- {capturing ? 'Press keys…' : formatKeybinding(chord) || 'Unbound'}+ {capturing ? t('set.pressKeys') : formatKeybinding(chord) || t('set.unbound')}</button>);}@@ -175,13 +176,13 @@ function MatrixControl({ setting }: { setting: MatrixSetting }) {<thead><tr><th />- {shown.map((j) => <th key={j} className="set-matrix-col"><span>{labels[j] || `Layer ${j}`}</span></th>)}+ {shown.map((j) => <th key={j} className="set-matrix-col"><span>{labels[j] || t('set.layerN', { i: j })}</span></th>)}</tr></thead><tbody>{shown.map((i) => (<tr key={i}>- <th className="set-matrix-row">{labels[i] || `Layer ${i}`}</th>+ <th className="set-matrix-row">{labels[i] || t('set.layerN', { i })}</th>{shown.map((j) => (<td key={j}><input type="checkbox" checked={collides(i, j)} onChange={() => toggle(i, j)} />@@ -209,7 +210,7 @@ function FlagListControl({ setting }: { setting: FlagListSetting }) {{shown.map((i) => (<label key={i} className="set-flaglist-item"><input type="checkbox" checked={isOn(i)} onChange={() => toggle(i)} />- <span>{labels[i] || `Layer ${i}`}</span>+ <span>{labels[i] || t('set.layerN', { i })}</span></label>))}</div>@@ -308,7 +309,7 @@ function Row({ setting }: { setting: Setting }) {</div><spanclassName={`set-reset${isChanged ? ' show' : ''}`}- title="Reset to default"+ title={t('set.resetDefault')}onClick={() => isChanged && reset(setting.id)}>{isChanged && <RotateCcw size={11} strokeWidth={2} />}@@ -375,18 +376,18 @@ export function SettingsDialog() {className="set-win"role="dialog"aria-modal="true"- aria-label="Settings"+ aria-label={t('set.title')}tabIndex={-1}onMouseDown={(e) => e.stopPropagation()}><div className="set-head"><span className="set-title"><span className="ic"><SettingsIcon size={16} strokeWidth={1.8} /></span>- Settings+ {t('set.title')}</span><span className="set-head-sp" />- <SearchField className="set-search" iconSize={12} autoFocus placeholder="Search settings…" value={query} onChange={setQuery} />- <IconButton size="lg" title="Close (Esc)" onClick={close}>+ <SearchField className="set-search" iconSize={12} autoFocus placeholder={t('set.search')} value={query} onChange={setQuery} />+ <IconButton size="lg" title={t('set.closeEsc')} onClick={close}><X size={14} strokeWidth={2} /></IconButton></div>@@ -415,7 +416,7 @@ export function SettingsDialog() {<div className="set-content">{content.length === 0 ? (- <div className="empty-line">No settings match “{query}”.</div>+ <div className="empty-line">{t('set.noMatch', { query })}</div>) : (content.map((g) => <Group key={g.label} label={g.label} settings={g.settings} />))}diff --git a/desktop/src/i18n/index.ts b/desktop/src/i18n/index.tsnew file mode 100644index 000000000..6c61ac27d--- /dev/null+++ b/desktop/src/i18n/index.ts@@ -0,0 +1,81 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file index.ts — editor localization, built on the ENGINE's LocalizationApi+ * (one i18n engine for games and the editor — no second library). The+ * locale is resolved ONCE at module load, before any other editor module+ * evaluates: command labels, settings descriptors, and menu titles are+ * registered at import time, so a per-session locale keeps every surface+ * consistent. Changing the language setting prompts a reload (the+ * renderer-backend precedent) rather than re-rendering half the strings.+ *+ * t(key) is typed over the merged catalog — a typo'd key or a key+ * missing a language is a compile error, not a runtime blank.+ */+import { LocalizationApi, type TParams } from 'esengine';+import { editorMessages } from './messages';++export type { Message, MessageMap } from './messages/types';+export { editorMessages };++export type EditorLocale = 'en' | 'zh-CN';+export type MsgKey = keyof typeof editorMessages;++/** Languages offered in Settings. Labels are the languages' own names — never translated. */+export const EDITOR_LOCALES: { value: EditorLocale; label: string }[] = [+ { value: 'en', label: 'English' },+ { value: 'zh-CN', label: '简体中文' },+];++/**+ * Pure boot-locale rule: the persisted setting wins when valid, else the system+ * language (any zh variant → zh-CN), else English.+ */+export function resolveLocale(persisted: unknown, systemLang: string): EditorLocale {+ if (persisted === 'en' || persisted === 'zh-CN') return persisted;+ return /^zh/i.test(systemLang) ? 'zh-CN' : 'en';+}++// Reads the language straight from the settings store's persistence (the+// LS_KEY/value-map contract in store/settingsStore.ts) — importing the store+// here would cycle (settings descriptors import t()).+const LS_SETTINGS_KEY = 'estella.settings';+export const LANGUAGE_SETTING_ID = 'appearance.language';++function readPersistedLanguage(): unknown {+ if (typeof localStorage === 'undefined') return undefined;+ try {+ const values = JSON.parse(localStorage.getItem(LS_SETTINGS_KEY) ?? '{}') as Record<string, unknown>;+ return values[LANGUAGE_SETTING_ID];+ } catch {+ return undefined;+ }+}++// System-language detection wants a real renderer window: Node ≥21 also has a+// global navigator whose language tracks the OS, which would make the node test+// suite locale-dependent. Outside a window, English — deterministically.+const systemLang = typeof window !== 'undefined' && typeof navigator !== 'undefined' ? navigator.language : 'en';++/** What the language setting resets to: the OS language, clamped to what we ship. */+export const systemDefaultLocale: EditorLocale = resolveLocale(undefined, systemLang);++/** The locale this editor session renders in — fixed for the session's lifetime. */+export const editorLocale: EditorLocale = resolveLocale(readPersistedLanguage(), systemLang);++const loc = new LocalizationApi(editorLocale, 'en');+{+ const en: Record<string, string> = {};+ const zh: Record<string, string> = {};+ for (const key of Object.keys(editorMessages) as MsgKey[]) {+ en[key] = editorMessages[key].en;+ zh[key] = editorMessages[key].zh;+ }+ loc.addCatalog('en', en);+ loc.addCatalog('zh-CN', zh);+}++/** Translate an editor string. `{name}` placeholders interpolate from `params`. */+export function t(key: MsgKey, params?: TParams): string {+ return loc.t(key, params);+}diff --git a/desktop/src/i18n/messages/commands.ts b/desktop/src/i18n/messages/commands.tsnew file mode 100644index 000000000..3ac0c557e--- /dev/null+++ b/desktop/src/i18n/messages/commands.ts@@ -0,0 +1,87 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file commands.ts — labels + categories for the command registry+ * (commands/editorCommands.ts) and the editor-mode table. Menus, the+ * shortcuts settings page, and the command palette all render from the+ * registry, so translating here covers every surface a command shows on.+ * Key convention: `cmd.<command id>`, `cat.<category>`, `mode.<mode id>`.+ */+import { defineMessages } from './types';++export const commandMessages = defineMessages({+ // — File / project —+ 'cmd.scene.new': { en: 'New Scene', zh: '新建场景' },+ 'cmd.project.open': { en: 'Open Project…', zh: '打开项目…' },+ 'cmd.project.save': { en: 'Save Scene', zh: '保存场景' },+ 'cmd.project.saveAs': { en: 'Save Scene As…', zh: '场景另存为…' },+ 'cmd.project.export': { en: 'Build…', zh: '构建…' },+ 'cmd.project.close': { en: 'Close Project', zh: '关闭项目' },++ // — Edit / history —+ 'cmd.edit.undo': { en: 'Undo', zh: '撤销' },+ 'cmd.edit.redo': { en: 'Redo', zh: '重做' },+ 'cmd.edit.selectAll': { en: 'Select All', zh: '全选' },++ // — Entity —+ 'cmd.entity.add': { en: 'Add Entity', zh: '添加实体' },+ 'cmd.tilemap.new': { en: 'New Tilemap', zh: '新建瓦片地图' },+ 'cmd.entity.duplicate': { en: 'Duplicate', zh: '创建副本' },+ 'cmd.entity.delete': { en: 'Delete', zh: '删除' },+ 'cmd.entity.copy': { en: 'Copy', zh: '复制' },+ 'cmd.entity.cut': { en: 'Cut', zh: '剪切' },+ 'cmd.entity.paste': { en: 'Paste', zh: '粘贴' },+ 'cmd.entity.deselect': { en: 'Deselect', zh: '取消选择' },+ 'cmd.entity.nudge': { en: 'Nudge Selection', zh: '微移所选' },++ // — Tools / modes —+ 'cmd.tool.select': { en: 'Select Tool', zh: '选择工具' },+ 'cmd.tool.move': { en: 'Move Tool', zh: '移动工具' },+ 'cmd.tool.rotate': { en: 'Rotate Tool', zh: '旋转工具' },+ 'cmd.tool.scale': { en: 'Scale Tool', zh: '缩放工具' },+ 'cmd.mode.scene': { en: 'Scene Mode', zh: '场景模式' },+ 'cmd.mode.ui': { en: 'UI Mode', zh: 'UI 模式' },+ 'cmd.mode.tilemap': { en: 'Tilemap Mode', zh: '瓦片地图模式' },++ // — View —+ 'cmd.view.frameSelected': { en: 'Frame Selected', zh: '聚焦所选' },+ 'cmd.view.toggleGrid': { en: 'Show Grid', zh: '显示网格' },+ 'cmd.view.toggleGizmos': { en: 'Show Gizmos', zh: '显示 Gizmo' },+ 'cmd.view.togglePreviewFx': { en: 'Preview FX', zh: '预览特效' },+ 'cmd.view.toggleColliders': { en: 'Show Colliders', zh: '显示碰撞体' },+ 'cmd.view.toggleCoordSpace': { en: 'Local Axes', zh: '局部坐标轴' },+ 'cmd.view.togglePivotMode': { en: 'Pivot (vs Center)', zh: '轴心(而非中心)' },+ 'cmd.view.toggleSnapping': { en: 'Snapping', zh: '吸附' },++ // — Editor / play / build —+ 'cmd.settings.open': { en: 'Settings…', zh: '设置…' },+ 'cmd.play.toggle': { en: 'Play', zh: '运行' },+ 'cmd.play.stop': { en: 'Stop', zh: '停止' },+ 'cmd.build.scripts': { en: 'Build Project Scripts', zh: '构建项目脚本' },++ // — Command categories (menus, shortcuts page grouping) —+ 'cat.file': { en: 'File', zh: '文件' },+ 'cat.edit': { en: 'Edit', zh: '编辑' },+ 'cat.entity': { en: 'Entity', zh: '实体' },+ 'cat.tools': { en: 'Tools', zh: '工具' },+ 'cat.view': { en: 'View', zh: '视图' },+ 'cat.editor': { en: 'Editor', zh: '编辑器' },+ 'cat.play': { en: 'Play', zh: '运行' },+ 'cat.build': { en: 'Build', zh: '构建' },+ 'cat.general': { en: 'General', zh: '通用' },++ // — Editor modes (viewport toolbar) + their companion panels —+ 'mode.scene': { en: 'Scene', zh: '场景' },+ 'mode.ui': { en: 'UI', zh: 'UI' },+ 'mode.tilemap': { en: 'Tilemap', zh: '瓦片地图' },+ 'panel.tilemap': { en: 'Tilemap', zh: '瓦片地图' },+ 'panel.uiWidgets': { en: 'UI Widgets', zh: 'UI 控件' },++ // — Command-fired feedback —+ 'toast.builtScripts': { en: 'Built project scripts', zh: '项目脚本构建完成' },+ 'toast.buildFailed': { en: 'Build failed', zh: '构建失败' },+ 'toast.noTileset': {+ en: 'No tileset in the project yet — right-click a texture in the Content Browser → Create Tileset',+ zh: '项目中还没有瓦片集——在内容浏览器中右键一张纹理 → 创建瓦片集',+ },+});diff --git a/desktop/src/i18n/messages/common.ts b/desktop/src/i18n/messages/common.tsnew file mode 100644index 000000000..4f01b97b8--- /dev/null+++ b/desktop/src/i18n/messages/common.ts@@ -0,0 +1,38 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file common.ts — strings shared across panels and dialogs: generic verbs,+ * confirm/cancel pairs, empty-state fragments. Prefer one of these over+ * minting a per-panel duplicate.+ */+import { defineMessages } from './types';++export const commonMessages = defineMessages({+ 'ui.ok': { en: 'OK', zh: '确定' },+ 'ui.cancel': { en: 'Cancel', zh: '取消' },+ 'ui.close': { en: 'Close', zh: '关闭' },+ 'ui.delete': { en: 'Delete', zh: '删除' },+ 'ui.rename': { en: 'Rename', zh: '重命名' },+ 'ui.search': { en: 'Search', zh: '搜索' },+ 'ui.reset': { en: 'Reset', zh: '重置' },+ 'ui.untitled': { en: 'untitled', zh: '未命名' },+ 'ui.download': { en: 'Download', zh: '下载' },+ 'ui.reloadNow': { en: 'Reload now', zh: '立即重新加载' },++ // — The unsaved-changes gate (project/discardGuard.ts) —+ // `discard.body` wraps a consequence sentence; the `discard.*` fragments+ // below are the consequences callers pass in (no trailing period — the+ // body template owns the punctuation in each language).+ 'discard.title': { en: 'Unsaved changes', zh: '未保存的更改' },+ 'discard.body': { en: 'You have unsaved changes. {what}.', zh: '有未保存的更改。{what}。' },+ 'discard.confirm': { en: 'Discard changes', zh: '丢弃更改' },+ 'discard.default': { en: 'They will be lost', zh: '它们将会丢失' },+ 'discard.newScene': { en: 'Creating a new scene will discard them', zh: '新建场景将丢弃这些更改' },+ 'discard.closeProject': { en: 'Closing the project will discard them', zh: '关闭项目将丢弃这些更改' },+ 'discard.openScene': { en: 'Opening {name} will discard them', zh: '打开 {name} 将丢弃这些更改' },+ 'discard.reloadChanged': {+ en: '“{name}” changed on disk. Reloading discards your unsaved edits',+ zh: '“{name}”在磁盘上已被修改。重新加载将丢弃未保存的编辑',+ },+ 'toast.reloadedFromDisk': { en: 'Reloaded {name} from disk', zh: '已从磁盘重新加载 {name}' },+});diff --git a/desktop/src/i18n/messages/index.ts b/desktop/src/i18n/messages/index.tsnew file mode 100644index 000000000..3669aa2d1--- /dev/null+++ b/desktop/src/i18n/messages/index.ts@@ -0,0 +1,39 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file index.ts — merges every per-area catalog into ONE map; `keyof` of the+ * merge is the typed key union behind t(). New area = new module here ++ * one spread below. Keys must be globally unique (the spread would+ * silently last-write-wins otherwise); i18n.test.ts pins that.+ *+ * Translation glossary — keep zh terminology consistent across areas:+ * Scene 场景 · Entity 实体 · Component 组件 · Asset 资产 · Project 项目 ·+ * Build 构建 · Play 运行 · Stop 停止 · Viewport 视口 · Outliner 大纲 ·+ * Details 细节 · Content Browser 内容浏览器 · Output Log 输出日志 ·+ * Tilemap 瓦片地图 · Tileset 瓦片集 · Tile 瓦片 · Material 材质 ·+ * Shader 着色器 · Texture 纹理 · Sprite 精灵 · Particle 粒子 ·+ * Emitter 发射器 · Animation 动画 · Clip 剪辑 · Timeline 时间线 ·+ * State Machine 状态机 · Behavior Tree 行为树 · Undo 撤销 · Redo 重做 ·+ * Snap 吸附 · Grid 网格 · Layer 层 · Camera 相机 · Collider 碰撞体 ·+ * Rigid body 刚体 · Joint 关节 · Prefab 预制体 · Launcher 启动器 ·+ * Gizmo / UI / Spine / Canvas / Schema stay untranslated (proper nouns).+ */+import { commonMessages } from './common';+import { commandMessages } from './commands';+import { menuMessages } from './menu';+import { settingsMessages } from './settings';++/** Every per-area module, for the uniqueness guard in i18n.test.ts. */+export const messageModules = {+ common: commonMessages,+ commands: commandMessages,+ menu: menuMessages,+ settings: settingsMessages,+} as const;++export const editorMessages = {+ ...commonMessages,+ ...commandMessages,+ ...menuMessages,+ ...settingsMessages,+} as const;diff --git a/desktop/src/i18n/messages/menu.ts b/desktop/src/i18n/messages/menu.tsnew file mode 100644index 000000000..5317288a1--- /dev/null+++ b/desktop/src/i18n/messages/menu.ts@@ -0,0 +1,34 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file menu.ts — the menu bar: top-level titles and the few items that are+ * not command-registry entries (layout, launcher, about/updates). Items+ * built from commands take their label from `cmd.*` automatically.+ */+import { defineMessages } from './types';++export const menuMessages = defineMessages({+ 'menu.file': { en: 'File', zh: '文件' },+ 'menu.edit': { en: 'Edit', zh: '编辑' },+ 'menu.entity': { en: 'Entity', zh: '实体' },+ 'menu.view': { en: 'View', zh: '视图' },+ 'menu.build': { en: 'Build', zh: '构建' },+ 'menu.window': { en: 'Window', zh: '窗口' },+ 'menu.help': { en: 'Help', zh: '帮助' },++ 'menu.extractSchemas': { en: 'Extract Component Schemas', zh: '提取组件 Schema' },+ 'menu.resetLayout': { en: 'Reset Layout', zh: '重置布局' },+ 'menu.backToLauncher': { en: 'Back to Launcher', zh: '返回启动器' },+ 'menu.about': { en: 'About Estella', zh: '关于 Estella' },+ 'menu.aboutTagline': {+ en: 'A modern editor for the Estella 2D engine.',+ zh: 'Estella 2D 引擎的现代化编辑器。',+ },+ 'menu.checkUpdates': { en: 'Check for Updates…', zh: '检查更新…' },+ 'menu.openLogs': { en: 'Open Log Folder', zh: '打开日志文件夹' },++ 'toast.extractedSchemas': { en: 'Extracted component schemas', zh: '组件 Schema 已提取' },+ 'toast.extractFailed': { en: 'Extract failed', zh: '提取失败' },+ 'toast.updateAvailable': { en: 'Estella {version} is available', zh: '新版本 Estella {version} 可用' },+ 'toast.upToDate': { en: 'Estella is up to date', zh: 'Estella 已是最新版本' },+});diff --git a/desktop/src/i18n/messages/settings.ts b/desktop/src/i18n/messages/settings.tsnew file mode 100644index 000000000..1c94750e1--- /dev/null+++ b/desktop/src/i18n/messages/settings.ts@@ -0,0 +1,200 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file settings.ts — the settings surface: dialog chrome, nav categories,+ * sections, group headers, and every registered setting's label ++ * description. Key convention: `set.<setting id>` for the label and+ * `set.<setting id>.desc` for the description; `set.section.<id>` /+ * `set.group.<name>` for the structure around them.+ */+import { defineMessages } from './types';++export const settingsMessages = defineMessages({+ // — Dialog chrome —+ 'set.title': { en: 'Settings', zh: '设置' },+ 'set.search': { en: 'Search settings…', zh: '搜索设置…' },+ 'set.noMatch': { en: 'No settings match “{query}”.', zh: '没有匹配“{query}”的设置。' },+ 'set.resetDefault': { en: 'Reset to default', zh: '重置为默认值' },+ 'set.closeEsc': { en: 'Close (Esc)', zh: '关闭 (Esc)' },+ 'set.pressKeys': { en: 'Press keys…', zh: '请按键…' },+ 'set.unbound': { en: 'Unbound', zh: '未绑定' },+ 'set.rebindHint': { en: 'Click to rebind', zh: '点击重新绑定' },+ 'set.layerN': { en: 'Layer {i}', zh: '层 {i}' },++ // — Nav categories —+ 'set.cat.editor': { en: 'Editor', zh: '编辑器' },+ 'set.cat.project': { en: 'Project', zh: '项目' },+ 'set.cat.plugin': { en: 'Plugins', zh: '插件' },++ // — Sections —+ 'set.section.appearance': { en: 'Appearance', zh: '外观' },+ 'set.section.viewport': { en: 'Viewport', zh: '视口' },+ 'set.section.performance': { en: 'Performance', zh: '性能' },+ 'set.section.shortcuts': { en: 'Keyboard Shortcuts', zh: '键盘快捷键' },+ 'set.section.console': { en: 'Console', zh: '控制台' },+ 'set.section.renderer': { en: 'Renderer', zh: '渲染器' },+ 'set.section.display': { en: 'Display', zh: '显示' },+ 'set.section.physics': { en: 'Physics', zh: '物理' },+ 'set.section.rendering': { en: 'Rendering', zh: '渲染' },+ 'set.section.packaging': { en: 'Packaging', zh: '打包' },++ // — Group headers —+ 'set.group.appearance': { en: 'Appearance', zh: '外观' },+ 'set.group.grid': { en: 'Grid', zh: '网格' },+ 'set.group.gizmos': { en: 'Gizmos', zh: 'Gizmo' },+ 'set.group.background': { en: 'Background', zh: '后台' },+ 'set.group.console': { en: 'Console', zh: '控制台' },+ 'set.group.renderer': { en: 'Renderer', zh: '渲染器' },+ 'set.group.designResolution': { en: 'Design Resolution', zh: '设计分辨率' },+ 'set.group.sortingLayers': { en: 'Sorting Layers', zh: '排序层' },+ 'set.group.ySort': { en: 'Y-Sort', zh: 'Y 轴排序' },+ 'set.group.physics': { en: 'Physics', zh: '物理' },+ 'set.group.gravity': { en: 'Gravity', zh: '重力' },+ 'set.group.collisionLayers': { en: 'Collision Layers', zh: '碰撞层' },+ 'set.group.solver': { en: 'Solver', zh: '求解器' },+ 'set.group.wechat': { en: 'WeChat', zh: '微信' },+ 'set.group.desktop': { en: 'Desktop', zh: '桌面' },+ 'set.group.playable': { en: 'Playable', zh: 'Playable' },++ // — Editor settings —+ 'set.appearance.language': { en: 'Language', zh: '语言' },+ 'set.appearance.language.desc': {+ en: 'Editor display language. Takes effect after a reload.',+ zh: '编辑器界面语言。重新加载后生效。',+ },+ 'set.appearance.accent': { en: 'Accent color', zh: '强调色' },+ 'set.appearance.accent.desc': {+ en: 'Used for selection, active controls, and focus.',+ zh: '用于选中、激活控件与焦点高亮。',+ },+ 'set.appearance.uiScale': { en: 'UI scale', zh: '界面缩放' },+ 'set.appearance.uiScale.desc': {+ en: 'Scales every panel — fonts and controls.',+ zh: '缩放所有面板——字体与控件。',+ },+ 'set.renderer.backend': { en: 'Graphics backend', zh: '图形后端' },+ 'set.renderer.backend.desc': {+ en: 'Which GPU API the viewport renders through. Applies on engine reload (Ctrl+R). WebGPU falls back to WebGL2 automatically if no adapter is available.',+ zh: '视口使用的 GPU 图形接口。引擎重载(Ctrl+R)后生效。无可用适配器时 WebGPU 自动回退到 WebGL2。',+ },+ 'set.viewport.showGrid': { en: 'Show grid', zh: '显示网格' },+ 'set.viewport.gridSize': { en: 'Grid size', zh: '网格大小' },+ 'set.viewport.gridSize.desc': {+ en: 'World-unit spacing of the scene grid (and Move snap).',+ zh: '场景网格的世界单位间距(同时是移动吸附步长)。',+ },+ 'set.viewport.snapping': { en: 'Snap to grid', zh: '吸附到网格' },+ 'set.viewport.showGizmos': { en: 'Show gizmos', zh: '显示 Gizmo' },+ 'set.performance.useLessCpuInBackground': { en: 'Use less CPU in background', zh: '后台降低 CPU 占用' },+ 'set.performance.useLessCpuInBackground.desc': {+ en: 'Caps the engine at 10 fps while the editor window is unfocused.',+ zh: '编辑器窗口失焦时将引擎限制为 10 fps。',+ },+ 'set.console.maxLines': { en: 'Max retained lines', zh: '最大保留行数' },+ 'set.console.maxLines.desc': {+ en: 'Output Log keeps at most this many entries.',+ zh: '输出日志最多保留的条目数。',+ },++ // — Project settings —+ 'set.project.display.width': { en: 'Width', zh: '宽度' },+ 'set.project.display.width.desc': {+ en: 'Reference resolution new Canvas entities are created at; each Canvas keeps its own value afterwards.',+ zh: '新建 Canvas 实体使用的参考分辨率;创建后每个 Canvas 保留自己的值。',+ },+ 'set.project.display.height': { en: 'Height', zh: '高度' },+ 'set.project.rendering.sortingLayers': { en: 'Layer names', zh: '层名称' },+ 'set.project.rendering.sortingLayers.desc': {+ en: 'Name render sorting layers (lowest first); a render `layer` field then picks from them instead of a raw number.',+ zh: '为渲染排序层命名(最低层在前);渲染组件的 layer 字段将从中选择,而非填原始数字。',+ },+ 'set.project.rendering.ySortLayers': { en: 'Y-sorted layers', zh: 'Y 轴排序层' },+ 'set.project.rendering.ySortLayers.desc': {+ en: 'Entities on a checked layer draw in world-Y order (lower on screen on top) — top-down occlusion. Within a y-sorted layer, paint order wins over material batching.',+ zh: '勾选层上的实体按世界 Y 排序绘制(屏幕位置越低越靠上)——俯视视角遮挡。同一 Y 排序层内,绘制顺序优先于材质合批。',+ },+ 'set.project.physics.enabled': { en: 'Enable physics', zh: '启用物理' },+ 'set.project.physics.enabled.desc': {+ en: 'Install the Box2D world when this project plays — required for bodies a script spawns at runtime.',+ zh: '项目运行时安装 Box2D 物理世界——脚本在运行时生成刚体也需要它。',+ },+ 'set.project.physics.gravityX': { en: 'Gravity X', zh: '重力 X' },+ 'set.project.physics.gravityY': { en: 'Gravity Y', zh: '重力 Y' },+ 'set.project.physics.gravityY.desc': {+ en: 'Negative pulls down (Box2D default −9.81).',+ zh: '负值向下(Box2D 默认 −9.81)。',+ },+ 'set.project.physics.collisionLayers': { en: 'Layer names', zh: '层名称' },+ 'set.project.physics.collisionLayers.desc': {+ en: 'Names for the 16 collision-filter layers — shown in collider Category/Mask pickers.',+ zh: '16 个碰撞过滤层的名称——显示在碰撞体的 Category/Mask 选择器中。',+ },+ 'set.project.physics.collisionMatrix': { en: 'Collision matrix', zh: '碰撞矩阵' },+ 'set.project.physics.collisionMatrix.desc': {+ en: 'Which layers collide. A collider on a single named layer derives its mask from this row (so it overrides the collider’s own Mask). All-on = no restriction.',+ zh: '哪些层之间发生碰撞。位于单个命名层上的碰撞体由该行推导掩码(会覆盖其自身的 Mask)。全开 = 无限制。',+ },+ 'set.project.physics.fixedTimestep': { en: 'Fixed timestep', zh: '固定时间步长' },+ 'set.project.physics.fixedTimestep.desc': {+ en: 'Simulation step size; smaller is more accurate but costlier. Default 1/60.',+ zh: '模拟步长;越小越精确但开销越大。默认 1/60。',+ },+ 'set.project.physics.subStepCount': { en: 'Sub-steps', zh: '子步数' },+ 'set.project.physics.subStepCount.desc': {+ en: 'Solver sub-steps per step — higher firms up stacks/joints at more cost. Default 4.',+ zh: '每步的求解器子步数——更高让堆叠/关节更稳定,开销也更大。默认 4。',+ },+ 'set.project.physics.contactHertz': { en: 'Contact Hz', zh: '接触频率' },+ 'set.project.physics.contactHertz.desc': {+ en: 'Contact stiffness frequency. Default 120.',+ zh: '接触刚度频率。默认 120。',+ },+ 'set.project.physics.contactDampingRatio': { en: 'Contact damping', zh: '接触阻尼' },+ 'set.project.physics.contactDampingRatio.desc': {+ en: 'Contact damping ratio. Default 10.',+ zh: '接触阻尼比。默认 10。',+ },+ 'set.project.physics.contactSpeed': { en: 'Contact push speed', zh: '接触推出速度' },+ 'set.project.physics.contactSpeed.desc': {+ en: 'Max speed used to resolve overlap. Default 10.',+ zh: '解除重叠使用的最大速度。默认 10。',+ },+ 'set.project.physics.enableSleep': { en: 'Allow sleeping', zh: '允许休眠' },+ 'set.project.physics.enableSleep.desc': {+ en: 'Let resting bodies sleep to save CPU (Box2D default on).',+ zh: '让静止刚体休眠以节省 CPU(Box2D 默认开启)。',+ },+ 'set.project.physics.enableContinuous': { en: 'Continuous collision', zh: '连续碰撞检测' },+ 'set.project.physics.enableContinuous.desc': {+ en: 'Anti-tunneling for fast bodies (Box2D default on).',+ zh: '高速刚体的防穿透(Box2D 默认开启)。',+ },+ 'set.project.packaging.wechat.appid': { en: 'AppID', zh: 'AppID' },+ 'set.project.packaging.wechat.appid.desc': {+ en: 'Your WeChat MiniGame appid — written into project.config.json on export.',+ zh: '微信小游戏的 appid——导出时写入 project.config.json。',+ },+ 'set.project.packaging.orientation': { en: 'Orientation', zh: '屏幕方向' },+ 'set.orientation.portrait': { en: 'Portrait', zh: '竖屏' },+ 'set.orientation.landscape': { en: 'Landscape', zh: '横屏' },+ 'set.project.packaging.desktop.appId': { en: 'App ID', zh: 'App ID' },+ 'set.project.packaging.desktop.appId.desc': {+ en: 'Reverse-DNS id for the installer (electron-builder appId), e.g. com.studio.game.',+ zh: '安装包的反向域名 id(electron-builder appId),例如 com.studio.game。',+ },+ 'set.project.packaging.desktop.productName': { en: 'Product name', zh: '产品名称' },+ 'set.project.packaging.desktop.productName.desc': {+ en: 'Display name for the desktop app + installer (defaults to the project name).',+ zh: '桌面应用与安装包的显示名称(默认为项目名)。',+ },++ // — Setting-fired feedback —+ 'toast.langReload': {+ en: 'Reload to switch the editor language',+ zh: '重新加载以切换编辑器语言',+ },+ 'toast.backendReload': {+ en: 'Reload to render with {backend}',+ zh: '重新加载后使用 {backend} 渲染',+ },+});diff --git a/desktop/src/i18n/messages/types.ts b/desktop/src/i18n/messages/types.tsnew file mode 100644index 000000000..f7b64210b--- /dev/null+++ b/desktop/src/i18n/messages/types.ts@@ -0,0 +1,23 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file types.ts — the message-entry shape shared by every per-area catalog+ * module. Both languages live on ONE entry, so a key can never exist in+ * one locale and not the other; `defineMessages` (an identity function)+ * checks the shape while keeping literal key inference for the typed+ * t(key) union. Adding a locale later = widen Message; tsc then flags+ * every entry missing it.+ */++/** One user-facing string in every supported editor language. */+export interface Message {+ en: string;+ zh: string;+}++export type MessageMap = Record<string, Message>;++/** Identity with shape-checking; preserves literal keys for the MsgKey union. */+export function defineMessages<T extends MessageMap>(messages: T): T {+ return messages;+}diff --git a/desktop/src/layout/MenuBar.tsx b/desktop/src/layout/MenuBar.tsxindex 3c7e163a4..6fe34e370 100644--- a/desktop/src/layout/MenuBar.tsx+++ b/desktop/src/layout/MenuBar.tsx@@ -15,6 +15,7 @@ import { EditorHistory } from '@/engine/EditorHistory';import { Toasts } from '@/store/Toasts';import { MenuItems, handleMenuListKey, type MenuItem } from '@/components/Menu';import { commands, formatKeybinding } from '@/commands';+import { t } from '@/i18n';interface MenuDef {title: string;@@ -83,7 +84,7 @@ export function MenuBar() {const menus: MenuDef[] = [{- title: 'File',+ title: t('menu.file'),items: [cmdItem('scene.new'),{ sep: true },@@ -98,7 +99,7 @@ export function MenuBar() {],},{- title: 'Edit',+ title: t('menu.edit'),items: [cmdItem('edit.undo'),cmdItem('edit.redo'),@@ -113,7 +114,7 @@ export function MenuBar() {],},{- title: 'Entity',+ title: t('menu.entity'),items: [cmdItem('entity.add'),cmdItem('tilemap.new'),@@ -125,7 +126,7 @@ export function MenuBar() {],},{- title: 'View',+ title: t('menu.view'),items: [cmdItem('view.toggleGrid'),cmdItem('view.toggleGizmos'),@@ -138,53 +139,53 @@ export function MenuBar() {],},{- title: 'Build',+ title: t('menu.build'),items: [cmdItem('build.scripts'),{- label: 'Extract Component Schemas',+ label: t('menu.extractSchemas'),// refreshUserSchemas extracts AND reloads into the editor (so the// inspector updates), unlike a bare extract that only writes the file.onClick: () => void ProjectStore.refreshUserSchemas()- .then(() => Toasts.push('Extracted component schemas', 'success'))- .catch(() => Toasts.push('Extract failed', 'error')),+ .then(() => Toasts.push(t('toast.extractedSchemas'), 'success'))+ .catch(() => Toasts.push(t('toast.extractFailed'), 'error')),disabled: !project,},],},{- title: 'Window',+ title: t('menu.window'),items: [- { label: 'Reset Layout', onClick: () => { localStorage.removeItem(LAYOUT_KEY); location.reload(); } },+ { label: t('menu.resetLayout'), onClick: () => { localStorage.removeItem(LAYOUT_KEY); location.reload(); } },{ sep: true },- { label: 'Back to Launcher', onClick: openLauncher },+ { label: t('menu.backToLauncher'), onClick: openLauncher },],},{- title: 'Help',+ title: t('menu.help'),items: [{- label: 'About Estella',+ label: t('menu.about'),onClick: () => void window.estella?.getVersion?.()- .then((v) => window.alert(`Estella Editor${v ? ' · ' + v : ''}\nA modern editor for the Estella 2D engine.`))+ .then((v) => window.alert(`Estella Editor${v ? ' · ' + v : ''}\n${t('menu.aboutTagline')}`)).catch(() => window.alert('Estella Editor')),},{- label: 'Check for Updates…',+ label: t('menu.checkUpdates'),onClick: () => void window.estella?.app?.checkUpdates?.().then((release) => {if (release) {- Toasts.push(`Estella ${release.version} is available`, 'info', 0, {- label: 'Download',+ Toasts.push(t('toast.updateAvailable', { version: release.version }), 'info', 0, {+ label: t('ui.download'),run: () => window.open(release.url),});} else {- Toasts.push('Estella is up to date', 'success');+ Toasts.push(t('toast.upToDate'), 'success');}}),},{ sep: true },{- label: 'Open Log Folder',+ label: t('menu.openLogs'),onClick: () => void window.estella?.app?.openLogs?.(),},],@@ -254,7 +255,7 @@ export function MenuBar() {) : (<><span className="sep">/</span>- <span className="mono">untitled</span>+ <span className="mono">{t('ui.untitled')}</span></>)}{dirty && <DirtyDot />}diff --git a/desktop/src/mode/editorModes.ts b/desktop/src/mode/editorModes.tsindex 3c3aa6db2..3ce73cc98 100644--- a/desktop/src/mode/editorModes.ts+++ b/desktop/src/mode/editorModes.ts@@ -13,6 +13,7 @@*/import type { LucideIcon } from 'lucide-react';import { MousePointer2, LayoutPanelTop, Grid3x3 } from 'lucide-react';+import { t } from '@/i18n';export type EditorModeId = 'scene' | 'ui' | 'tilemap';@@ -46,26 +47,26 @@ export interface EditorModeDef {const tilemapMode: EditorModeDef = {id: 'tilemap',- label: 'Tilemap',+ label: t('mode.tilemap'),icon: Grid3x3,toolset: 'tilemap',- panels: [{ id: 'tilemap', component: 'tilemap', title: 'Tilemap', side: 'left', width: 300 }],+ panels: [{ id: 'tilemap', component: 'tilemap', title: t('panel.tilemap'), side: 'left', width: 300 }],suggestFor: (s) => s.hasComponent('TilemapLayer'),};const uiMode: EditorModeDef = {id: 'ui',- label: 'UI',+ label: t('mode.ui'),icon: LayoutPanelTop,toolset: 'transform',- panels: [{ id: 'ui-widgets', component: 'uiWidgets', title: 'UI Widgets', side: 'left', width: 240 }],+ panels: [{ id: 'ui-widgets', component: 'uiWidgets', title: t('panel.uiWidgets'), side: 'left', width: 240 }],overlays: { designFrame: true, safeArea: true, letterbox: true },suggestFor: (s) => s.hasComponent('Canvas') || s.hasComponent('UINode'),};const sceneMode: EditorModeDef = {id: 'scene',- label: 'Scene',+ label: t('mode.scene'),icon: MousePointer2,toolset: 'transform',};diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsxindex dc8e47bf3..61f61bc86 100644--- a/desktop/src/panels/Details.tsx+++ b/desktop/src/panels/Details.tsx@@ -52,6 +52,7 @@ import { buildImporterComponent, applyImporterEdit } from '@/project/assetImportimport { referencingPaths } from '@/project/assetRefs';import { ProjectStore } from '@/project/ProjectStore';import { confirmDiscard } from '@/project/discardGuard';+import { t } from '@/i18n';import { MaterialDocument } from '@/material/MaterialDocument';import {isMaterialAsset,@@ -2078,7 +2079,7 @@ function GenericAssetInspector({ path }: { path: string }) {type="button"className="primary"onClick={async () => {- if (await confirmDiscard(`Opening ${baseName(path)} will discard them`)) void ProjectStore.openScene(path);+ if (await confirmDiscard(t('discard.openScene', { name: baseName(path) }))) void ProjectStore.openScene(path);}}><FolderOpen size={13} strokeWidth={1.85} /> Open Scenediff --git a/desktop/src/project/ProjectStore.ts b/desktop/src/project/ProjectStore.tsindex b50dcc44f..0cfd72f22 100644--- a/desktop/src/project/ProjectStore.ts+++ b/desktop/src/project/ProjectStore.ts@@ -19,6 +19,7 @@ import { installSpineSync, type SpineTransport } from '@/engine/spineSync';import { useSelection } from '@/store/selectionStore';import { Toasts } from '@/store/Toasts';import { confirmDiscard } from './discardGuard';+import { t } from '@/i18n';import { assetTypeOf } from '@/project/assetMeta';import type { AssetType } from '@/types';import { resolveLayout, WORKSPACE_DIR, PROJECT_MANIFEST_FILE, type OpenedProject, type ProjectFeatures, type ProjectLayout, type ProjectPackaging, type WorkspaceState, type DesignResolution } from './format';@@ -1171,7 +1172,7 @@ class ProjectStoreImpl {// not stack more dialogs for the same question.if (this.reloadPromptOpen) return;this.reloadPromptOpen = true;- const ok = await confirmDiscard(`"${name}" changed on disk. Reloading discards your unsaved edits`);+ const ok = await confirmDiscard(t('discard.reloadChanged', { name }));this.reloadPromptOpen = false;if (!ok) {this.knownSceneText = text;@@ -1180,7 +1181,7 @@ class ProjectStoreImpl {}}await this.loadCurrentScene();- Toasts.push(`Reloaded ${name} from disk`, 'info', 1600);+ Toasts.push(t('toast.reloadedFromDisk', { name }), 'info', 1600);}private async persistLastScene(relPath: string): Promise<void> {diff --git a/desktop/src/project/assetOpen.ts b/desktop/src/project/assetOpen.tsindex 83e31da8e..330c199f6 100644--- a/desktop/src/project/assetOpen.ts+++ b/desktop/src/project/assetOpen.ts@@ -10,6 +10,7 @@import type { AssetType } from '@/types';import { ProjectStore } from './ProjectStore';import { confirmDiscard } from './discardGuard';+import { t } from '@/i18n';import { toggleAudioPreview } from './audioPreview';import { openAnimationClip } from '@/timeline/openClip';import { openTileset } from '@/tileset/openTileset';@@ -21,7 +22,7 @@ import { openBehaviorTree } from '@/bt/openBehaviorTree';/** Open action per asset type; types absent here aren't double-click-openable. */export const ASSET_OPEN: Partial<Record<AssetType, (path: string, name: string) => void>> = {scene: async (path, name) => {- if (!(await confirmDiscard(`Opening ${name} will discard them`))) return;+ if (!(await confirmDiscard(t('discard.openScene', { name })))) return;void ProjectStore.openScene(path);},audio: (path) => toggleAudioPreview(path),diff --git a/desktop/src/project/discardGuard.ts b/desktop/src/project/discardGuard.tsindex 39d85dca2..0ebf11ddc 100644--- a/desktop/src/project/discardGuard.ts+++ b/desktop/src/project/discardGuard.ts@@ -10,20 +10,22 @@*/import { EditorHistory } from '@/engine/EditorHistory';import { confirm } from '@/components/confirm';+import { t } from '@/i18n';/*** Resolves true if it's safe to proceed with a destructive document action:* when there are no unsaved changes, or the user confirms discarding them.- * `what` names the consequence, e.g. "Creating a new scene will discard them".+ * `what` names the consequence, PRE-TRANSLATED and without a trailing period —+ * e.g. t('discard.newScene'); the body template owns the punctuation.* Async (a themed dialog, not window.confirm) — callers gate with* `if (!(await confirmDiscard(...))) return;`.*/-export async function confirmDiscard(what = 'They will be lost'): Promise<boolean> {+export async function confirmDiscard(what = t('discard.default')): Promise<boolean> {if (!EditorHistory.isDirty()) return true;return confirm({- title: 'Unsaved changes',- body: `You have unsaved changes. ${what}.`,- confirmLabel: 'Discard changes',+ title: t('discard.title'),+ body: t('discard.body', { what }),+ confirmLabel: t('discard.confirm'),danger: true,});}diff --git a/desktop/src/settings/editorSettings.ts b/desktop/src/settings/editorSettings.tsindex 35fb4a0ad..047a4d41c 100644--- a/desktop/src/settings/editorSettings.ts+++ b/desktop/src/settings/editorSettings.ts@@ -17,18 +17,38 @@ import { commands } from '@/commands';import { setUseLessCpuInBackground } from '@/engine/backgroundThrottle';import { EngineHost } from '@/engine/EngineHost';import { Toasts } from '@/store/Toasts';+import { t, editorLocale, systemDefaultLocale, EDITOR_LOCALES, LANGUAGE_SETTING_ID } from '@/i18n';const root = () => document.documentElement.style;// ── Sections (editor category) ──────────────────────────────────────────────-settingsRegistry.registerSection({ id: 'appearance', label: 'Appearance', category: 'editor', order: 1 });-settingsRegistry.registerSection({ id: 'viewport', label: 'Viewport', category: 'editor', order: 2 });-settingsRegistry.registerSection({ id: 'performance', label: 'Performance', category: 'editor', order: 3 });-settingsRegistry.registerSection({ id: 'shortcuts', label: 'Keyboard Shortcuts', category: 'editor', order: 4 });-settingsRegistry.registerSection({ id: 'console', label: 'Console', category: 'editor', order: 5 });-settingsRegistry.registerSection({ id: 'renderer', label: 'Renderer', category: 'editor', order: 6 });+settingsRegistry.registerSection({ id: 'appearance', label: t('set.section.appearance'), category: 'editor', order: 1 });+settingsRegistry.registerSection({ id: 'viewport', label: t('set.section.viewport'), category: 'editor', order: 2 });+settingsRegistry.registerSection({ id: 'performance', label: t('set.section.performance'), category: 'editor', order: 3 });+settingsRegistry.registerSection({ id: 'shortcuts', label: t('set.section.shortcuts'), category: 'editor', order: 4 });+settingsRegistry.registerSection({ id: 'console', label: t('set.section.console'), category: 'editor', order: 5 });+settingsRegistry.registerSection({ id: 'renderer', label: t('set.section.renderer'), category: 'editor', order: 6 });// ── Appearance (store-owned, applied via CSS) ───────────────────────────────+// The session renders in the locale resolved at boot from this same persisted+// value (see i18n/index.ts), so a change only lands after a reload — prompt for+// it. Setting it back before reloading needs no prompt (nothing would change).+settingsRegistry.register({+ id: LANGUAGE_SETTING_ID,+ type: 'enum',+ scope: 'editor',+ section: 'appearance',+ group: t('set.group.appearance'),+ label: t('set.appearance.language'),+ description: t('set.appearance.language.desc'),+ default: systemDefaultLocale,+ options: EDITOR_LOCALES,+ effect: (v) => {+ if (v === editorLocale) return;+ Toasts.push(t('toast.langReload'), 'info', 8000, { label: t('ui.reloadNow'), run: () => location.reload() });+ },+});+// The accent is a family, not one color — hover/pressed shades and the// translucent selection/focus tints all derive from the chosen hue. On the// default azure the overrides are removed so the hand-tuned tokens.css values@@ -48,9 +68,9 @@ settingsRegistry.register({type: 'color',scope: 'editor',section: 'appearance',- group: 'Appearance',- label: 'Accent color',- description: 'Used for selection, active controls, and focus.',+ group: t('set.group.appearance'),+ label: t('set.appearance.accent'),+ description: t('set.appearance.accent.desc'),default: ACCENT_DEFAULT,swatches: [ACCENT_DEFAULT, '#46b08c', '#b272d6', '#e08c43', '#c75d6e'],effect: (v) => {@@ -60,10 +80,10 @@ settingsRegistry.register({return;}const [r, g, b] = rgb;- const toward = (t: number) =>- t >= 0- ? `rgb(${rgb.map((c) => Math.round(c + (255 - c) * t)).join(' ')})`- : `rgb(${rgb.map((c) => Math.round(c * (1 + t))).join(' ')})`;+ const toward = (amt: number) =>+ amt >= 0+ ? `rgb(${rgb.map((c) => Math.round(c + (255 - c) * amt)).join(' ')})`+ : `rgb(${rgb.map((c) => Math.round(c * (1 + amt))).join(' ')})`;root().setProperty('--star', v);root().setProperty('--acc', v);root().setProperty('--star-hi', toward(0.16));@@ -79,9 +99,9 @@ settingsRegistry.register({type: 'number',scope: 'editor',section: 'appearance',- group: 'Appearance',- label: 'UI scale',- description: 'Scales every panel — fonts and controls.',+ group: t('set.group.appearance'),+ label: t('set.appearance.uiScale'),+ description: t('set.appearance.uiScale.desc'),default: 100,min: 80,max: 150,@@ -101,11 +121,9 @@ settingsRegistry.register({type: 'enum',scope: 'editor',section: 'renderer',- group: 'Renderer',- label: 'Graphics backend',- description:- 'Which GPU API the viewport renders through. Applies on engine reload (Ctrl+R). ' +- 'WebGPU falls back to WebGL2 automatically if no adapter is available.',+ group: t('set.group.renderer'),+ label: t('set.renderer.backend'),+ description: t('set.renderer.backend.desc'),default: 'webgl2',segmented: true,options: [@@ -120,10 +138,10 @@ settingsRegistry.register({if (!backendPrimed) { backendPrimed = true; return; }if (v === EngineHost.activeBackend) return;Toasts.push(- `Reload to render with ${v === 'webgpu' ? 'WebGPU' : 'WebGL2'}`,+ t('toast.backendReload', { backend: v === 'webgpu' ? 'WebGPU' : 'WebGL2' }),'info',8000,- { label: 'Reload now', run: () => location.reload() },+ { label: t('ui.reloadNow'), run: () => location.reload() },);},});@@ -136,8 +154,8 @@ settingsRegistry.register({type: 'boolean',scope: 'editor',section: 'viewport',- group: 'Grid',- label: 'Show grid',+ group: t('set.group.grid'),+ label: t('set.viewport.showGrid'),default: true,bind: { get: () => ed().showGrid, set: (v) => useEditorStore.setState({ showGrid: v }) },});@@ -147,9 +165,9 @@ settingsRegistry.register({type: 'number',scope: 'editor',section: 'viewport',- group: 'Grid',- label: 'Grid size',- description: 'World-unit spacing of the scene grid (and Move snap).',+ group: t('set.group.grid'),+ label: t('set.viewport.gridSize'),+ description: t('set.viewport.gridSize.desc'),default: 32,min: 8,max: 128,@@ -162,8 +180,8 @@ settingsRegistry.register({type: 'boolean',scope: 'editor',section: 'viewport',- group: 'Grid',- label: 'Snap to grid',+ group: t('set.group.grid'),+ label: t('set.viewport.snapping'),default: false,bind: { get: () => ed().snapping, set: (v) => useEditorStore.setState({ snapping: v }) },});@@ -173,8 +191,8 @@ settingsRegistry.register({type: 'boolean',scope: 'editor',section: 'viewport',- group: 'Gizmos',- label: 'Show gizmos',+ group: t('set.group.gizmos'),+ label: t('set.viewport.showGizmos'),default: true,bind: { get: () => ed().showGizmos, set: (v) => useEditorStore.setState({ showGizmos: v }) },});@@ -185,9 +203,9 @@ settingsRegistry.register({type: 'boolean',scope: 'editor',section: 'performance',- group: 'Background',- label: 'Use less CPU in background',- description: 'Caps the engine at 10 fps while the editor window is unfocused.',+ group: t('set.group.background'),+ label: t('set.performance.useLessCpuInBackground'),+ description: t('set.performance.useLessCpuInBackground.desc'),default: true,effect: (v) => setUseLessCpuInBackground(v),});@@ -198,9 +216,9 @@ settingsRegistry.register({type: 'number',scope: 'editor',section: 'console',- group: 'Console',- label: 'Max retained lines',- description: 'Output Log keeps at most this many entries.',+ group: t('set.group.console'),+ label: t('set.console.maxLines'),+ description: t('set.console.maxLines.desc'),default: 2000,min: 100,max: 10000,@@ -221,7 +239,7 @@ for (const cmd of commands.all()) {type: 'keybinding',scope: 'editor',section: 'shortcuts',- group: cmd.category ?? 'General',+ group: cmd.category ?? t('cat.general'),label: cmd.label,commandId: cmd.id,default: primaryChord(cmd.keybinding),diff --git a/desktop/src/settings/projectSettings.ts b/desktop/src/settings/projectSettings.tsindex 427314a33..936a19621 100644--- a/desktop/src/settings/projectSettings.ts+++ b/desktop/src/settings/projectSettings.ts@@ -9,15 +9,16 @@*/import { settingsRegistry } from './registry';import { ProjectStore } from '@/project/ProjectStore';+import { t } from '@/i18n';// ── Display (design/reference resolution; seeds new Canvas entities) ──-settingsRegistry.registerSection({ id: 'display', label: 'Display', category: 'project', order: 0 });+settingsRegistry.registerSection({ id: 'display', label: t('set.section.display'), category: 'project', order: 0 });settingsRegistry.register({id: 'project.display.width',- type: 'number', scope: 'project', section: 'display', group: 'Design Resolution',- label: 'Width', suffix: 'px',- description: 'Reference resolution new Canvas entities are created at; each Canvas keeps its own value afterwards.',+ type: 'number', scope: 'project', section: 'display', group: t('set.group.designResolution'),+ label: t('set.project.display.width'), suffix: 'px',+ description: t('set.project.display.width.desc'),default: 1920, min: 1, step: 1,bind: {get: () => ProjectStore.designResolution().width,@@ -27,8 +28,8 @@ settingsRegistry.register({settingsRegistry.register({id: 'project.display.height',- type: 'number', scope: 'project', section: 'display', group: 'Design Resolution',- label: 'Height', suffix: 'px',+ type: 'number', scope: 'project', section: 'display', group: t('set.group.designResolution'),+ label: t('set.project.display.height'), suffix: 'px',default: 1080, min: 1, step: 1,bind: {get: () => ProjectStore.designResolution().height,@@ -37,21 +38,21 @@ settingsRegistry.register({});// ── Physics (the enable flag = UE Plugins-Browser analog; gravity = Project Settings) ──-settingsRegistry.registerSection({ id: 'physics', label: 'Physics', category: 'project', order: 1 });+settingsRegistry.registerSection({ id: 'physics', label: t('set.section.physics'), category: 'project', order: 1 });// ── Rendering (named sorting layers feed the inspector's render `layer` dropdown) ──-settingsRegistry.registerSection({ id: 'rendering', label: 'Rendering', category: 'project', order: 2 });+settingsRegistry.registerSection({ id: 'rendering', label: t('set.section.rendering'), category: 'project', order: 2 });settingsRegistry.register({id: 'project.rendering.sortingLayers',type: 'stringList',scope: 'project',section: 'rendering',- group: 'Sorting Layers',- label: 'Layer names',- description: 'Name render sorting layers (lowest first); a render `layer` field then picks from them instead of a raw number.',+ group: t('set.group.sortingLayers'),+ label: t('set.project.rendering.sortingLayers'),+ description: t('set.project.rendering.sortingLayers.desc'),count: 8,- placeholder: (i) => `Layer ${i}`,+ placeholder: (i) => t('set.layerN', { i }),default: Array.from({ length: 8 }, () => ''),bind: {get: () => ProjectStore.renderingFeature().sortingLayers,@@ -64,11 +65,9 @@ settingsRegistry.register({type: 'flagList',scope: 'project',section: 'rendering',- group: 'Y-Sort',- label: 'Y-sorted layers',- description:- 'Entities on a checked layer draw in world-Y order (lower on screen on top) — top-down occlusion. ' +- 'Within a y-sorted layer, paint order wins over material batching.',+ group: t('set.group.ySort'),+ label: t('set.project.rendering.ySortLayers'),+ description: t('set.project.rendering.ySortLayers.desc'),count: 8,labels: () => ProjectStore.renderingFeature().sortingLayers,default: [],@@ -83,9 +82,9 @@ settingsRegistry.register({type: 'boolean',scope: 'project',section: 'physics',- group: 'Physics',- label: 'Enable physics',- description: 'Install the Box2D world when this project plays — required for bodies a script spawns at runtime.',+ group: t('set.group.physics'),+ label: t('set.project.physics.enabled'),+ description: t('set.project.physics.enabled.desc'),default: false,bind: {get: () => ProjectStore.physicsFeature().enabled,@@ -98,8 +97,8 @@ settingsRegistry.register({type: 'number',scope: 'project',section: 'physics',- group: 'Gravity',- label: 'Gravity X',+ group: t('set.group.gravity'),+ label: t('set.project.physics.gravityX'),default: 0,step: 0.1,bind: {@@ -113,11 +112,11 @@ settingsRegistry.register({type: 'stringList',scope: 'project',section: 'physics',- group: 'Collision Layers',- label: 'Layer names',- description: 'Names for the 16 collision-filter layers — shown in collider Category/Mask pickers.',+ group: t('set.group.collisionLayers'),+ label: t('set.project.physics.collisionLayers'),+ description: t('set.project.physics.collisionLayers.desc'),count: 16,- placeholder: (i) => `Layer ${i}`,+ placeholder: (i) => t('set.layerN', { i }),default: Array.from({ length: 16 }, (_, i) => (i === 0 ? 'Default' : '')),bind: {get: () => ProjectStore.physicsFeature().collisionLayers,@@ -130,9 +129,9 @@ settingsRegistry.register({type: 'matrix',scope: 'project',section: 'physics',- group: 'Collision Layers',- label: 'Collision matrix',- description: 'Which layers collide. A collider on a single named layer derives its mask from this row (so it overrides the collider’s own Mask). All-on = no restriction.',+ group: t('set.group.collisionLayers'),+ label: t('set.project.physics.collisionMatrix'),+ description: t('set.project.physics.collisionMatrix.desc'),count: 16,labels: () => ProjectStore.physicsFeature().collisionLayers,default: Array.from({ length: 16 }, () => 0xffff),@@ -143,15 +142,18 @@ settingsRegistry.register({});// ── Packaging (per-platform Project Settings; read by the export, persisted to project.esproject) ──-settingsRegistry.registerSection({ id: 'packaging', label: 'Packaging', category: 'project', order: 3 });+settingsRegistry.registerSection({ id: 'packaging', label: t('set.section.packaging'), category: 'project', order: 3 });-const ORIENTATION = [{ value: 'portrait', label: 'Portrait' }, { value: 'landscape', label: 'Landscape' }];+const ORIENTATION = [+ { value: 'portrait', label: t('set.orientation.portrait') },+ { value: 'landscape', label: t('set.orientation.landscape') },+];settingsRegistry.register({id: 'project.packaging.wechat.appid',- type: 'string', scope: 'project', section: 'packaging', group: 'WeChat',- label: 'AppID',- description: 'Your WeChat MiniGame appid — written into project.config.json on export.',+ type: 'string', scope: 'project', section: 'packaging', group: t('set.group.wechat'),+ label: t('set.project.packaging.wechat.appid'),+ description: t('set.project.packaging.wechat.appid.desc'),placeholder: 'wx0123456789abcdef', default: '',bind: {get: () => ProjectStore.platformPackaging().wechat?.appid ?? '',@@ -161,8 +163,8 @@ settingsRegistry.register({settingsRegistry.register({id: 'project.packaging.wechat.orientation',- type: 'enum', scope: 'project', section: 'packaging', group: 'WeChat',- label: 'Orientation', options: ORIENTATION, segmented: true, default: 'portrait',+ type: 'enum', scope: 'project', section: 'packaging', group: t('set.group.wechat'),+ label: t('set.project.packaging.orientation'), options: ORIENTATION, segmented: true, default: 'portrait',bind: {get: () => ProjectStore.platformPackaging().wechat?.orientation ?? 'portrait',set: (v) => void ProjectStore.setPlatformPackaging('wechat', { orientation: v as 'portrait' | 'landscape' }),@@ -171,9 +173,9 @@ settingsRegistry.register({settingsRegistry.register({id: 'project.packaging.desktop.appId',- type: 'string', scope: 'project', section: 'packaging', group: 'Desktop',- label: 'App ID',- description: 'Reverse-DNS id for the installer (electron-builder appId), e.g. com.studio.game.',+ type: 'string', scope: 'project', section: 'packaging', group: t('set.group.desktop'),+ label: t('set.project.packaging.desktop.appId'),+ description: t('set.project.packaging.desktop.appId.desc'),placeholder: 'com.studio.game', default: '',bind: {get: () => ProjectStore.platformPackaging().desktop?.appId ?? '',@@ -183,9 +185,9 @@ settingsRegistry.register({settingsRegistry.register({id: 'project.packaging.desktop.productName',- type: 'string', scope: 'project', section: 'packaging', group: 'Desktop',- label: 'Product name',- description: 'Display name for the desktop app + installer (defaults to the project name).',+ type: 'string', scope: 'project', section: 'packaging', group: t('set.group.desktop'),+ label: t('set.project.packaging.desktop.productName'),+ description: t('set.project.packaging.desktop.productName.desc'),placeholder: '(project name)', default: '',bind: {get: () => ProjectStore.platformPackaging().desktop?.productName ?? '',@@ -195,8 +197,8 @@ settingsRegistry.register({settingsRegistry.register({id: 'project.packaging.playable.orientation',- type: 'enum', scope: 'project', section: 'packaging', group: 'Playable',- label: 'Orientation', options: ORIENTATION, segmented: true, default: 'portrait',+ type: 'enum', scope: 'project', section: 'packaging', group: t('set.group.playable'),+ label: t('set.project.packaging.orientation'), options: ORIENTATION, segmented: true, default: 'portrait',bind: {get: () => ProjectStore.platformPackaging().playable?.orientation ?? 'portrait',set: (v) => void ProjectStore.setPlatformPackaging('playable', { orientation: v as 'portrait' | 'landscape' }),@@ -208,9 +210,9 @@ settingsRegistry.register({type: 'number',scope: 'project',section: 'physics',- group: 'Gravity',- label: 'Gravity Y',- description: 'Negative pulls down (Box2D default −9.81).',+ group: t('set.group.gravity'),+ label: t('set.project.physics.gravityY'),+ description: t('set.project.physics.gravityY.desc'),default: -9.81,step: 0.1,bind: {@@ -222,9 +224,9 @@ settingsRegistry.register({// ── Solver (world simulation tuning; absent ⇒ engine defaults) ──settingsRegistry.register({id: 'project.physics.fixedTimestep',- type: 'number', scope: 'project', section: 'physics', group: 'Solver',- label: 'Fixed timestep', suffix: 's',- description: 'Simulation step size; smaller is more accurate but costlier. Default 1/60.',+ type: 'number', scope: 'project', section: 'physics', group: t('set.group.solver'),+ label: t('set.project.physics.fixedTimestep'), suffix: 's',+ description: t('set.project.physics.fixedTimestep.desc'),default: 1 / 60, min: 0.001, step: 0.001,bind: {get: () => ProjectStore.physicsFeature().fixedTimestep,@@ -233,9 +235,9 @@ settingsRegistry.register({});settingsRegistry.register({id: 'project.physics.subStepCount',- type: 'number', scope: 'project', section: 'physics', group: 'Solver',- label: 'Sub-steps',- description: 'Solver sub-steps per step — higher firms up stacks/joints at more cost. Default 4.',+ type: 'number', scope: 'project', section: 'physics', group: t('set.group.solver'),+ label: t('set.project.physics.subStepCount'),+ description: t('set.project.physics.subStepCount.desc'),default: 4, min: 1, max: 8, step: 1,bind: {get: () => ProjectStore.physicsFeature().subStepCount,@@ -244,9 +246,9 @@ settingsRegistry.register({});settingsRegistry.register({id: 'project.physics.contactHertz',- type: 'number', scope: 'project', section: 'physics', group: 'Solver',- label: 'Contact Hz',- description: 'Contact stiffness frequency. Default 120.',+ type: 'number', scope: 'project', section: 'physics', group: t('set.group.solver'),+ label: t('set.project.physics.contactHertz'),+ description: t('set.project.physics.contactHertz.desc'),default: 120, min: 1, step: 1,bind: {get: () => ProjectStore.physicsFeature().contactHertz,@@ -255,9 +257,9 @@ settingsRegistry.register({});settingsRegistry.register({id: 'project.physics.contactDampingRatio',- type: 'number', scope: 'project', section: 'physics', group: 'Solver',- label: 'Contact damping',- description: 'Contact damping ratio. Default 10.',+ type: 'number', scope: 'project', section: 'physics', group: t('set.group.solver'),+ label: t('set.project.physics.contactDampingRatio'),+ description: t('set.project.physics.contactDampingRatio.desc'),default: 10, min: 0, step: 0.5,bind: {get: () => ProjectStore.physicsFeature().contactDampingRatio,@@ -266,9 +268,9 @@ settingsRegistry.register({});settingsRegistry.register({id: 'project.physics.contactSpeed',- type: 'number', scope: 'project', section: 'physics', group: 'Solver',- label: 'Contact push speed', suffix: 'm/s',- description: 'Max speed used to resolve overlap. Default 10.',+ type: 'number', scope: 'project', section: 'physics', group: t('set.group.solver'),+ label: t('set.project.physics.contactSpeed'), suffix: 'm/s',+ description: t('set.project.physics.contactSpeed.desc'),default: 10, min: 0, step: 0.5,bind: {get: () => ProjectStore.physicsFeature().contactSpeed,@@ -277,9 +279,9 @@ settingsRegistry.register({});settingsRegistry.register({id: 'project.physics.enableSleep',- type: 'boolean', scope: 'project', section: 'physics', group: 'Solver',- label: 'Allow sleeping',- description: 'Let resting bodies sleep to save CPU (Box2D default on).',+ type: 'boolean', scope: 'project', section: 'physics', group: t('set.group.solver'),+ label: t('set.project.physics.enableSleep'),+ description: t('set.project.physics.enableSleep.desc'),default: true,bind: {get: () => ProjectStore.physicsFeature().enableSleep,@@ -288,9 +290,9 @@ settingsRegistry.register({});settingsRegistry.register({id: 'project.physics.enableContinuous',- type: 'boolean', scope: 'project', section: 'physics', group: 'Solver',- label: 'Continuous collision',- description: 'Anti-tunneling for fast bodies (Box2D default on).',+ type: 'boolean', scope: 'project', section: 'physics', group: t('set.group.solver'),+ label: t('set.project.physics.enableContinuous'),+ description: t('set.project.physics.enableContinuous.desc'),default: true,bind: {get: () => ProjectStore.physicsFeature().enableContinuous,diff --git a/desktop/tests/i18n.test.ts b/desktop/tests/i18n.test.tsnew file mode 100644index 000000000..1c4926507--- /dev/null+++ b/desktop/tests/i18n.test.ts@@ -0,0 +1,74 @@+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file i18n.test.ts — the editor localization seams: the pure boot-locale+ * rule, catalog integrity (key uniqueness across area modules — the+ * merge spread would silently last-write-wins), and t() resolution in+ * both languages. Per-entry language completeness is a COMPILE error+ * (Message requires en+zh), so no runtime test re-checks it.+ */+import { describe, it, expect } from 'vitest';+import { resolveLocale, t, editorLocale, editorMessages } from '@/i18n';+import { messageModules } from '@/i18n/messages';+import { LocalizationApi } from 'esengine';++describe('resolveLocale', () => {+ it('persisted value wins when it is a shipped locale', () => {+ expect(resolveLocale('zh-CN', 'en-US')).toBe('zh-CN');+ expect(resolveLocale('en', 'zh-CN')).toBe('en');+ });++ it('falls back to the system language, mapping any zh variant to zh-CN', () => {+ expect(resolveLocale(undefined, 'zh-CN')).toBe('zh-CN');+ expect(resolveLocale(undefined, 'zh-Hans-CN')).toBe('zh-CN');+ expect(resolveLocale(undefined, 'zh')).toBe('zh-CN');+ expect(resolveLocale(undefined, 'en-US')).toBe('en');+ expect(resolveLocale(undefined, 'ja-JP')).toBe('en');+ });++ it('rejects junk persisted values (corrupt storage, removed locales)', () => {+ expect(resolveLocale('fr', 'en-US')).toBe('en');+ expect(resolveLocale(42, 'zh-CN')).toBe('zh-CN');+ expect(resolveLocale(null, 'en-US')).toBe('en');+ });+});++describe('catalog integrity', () => {+ it('keys are unique across area modules (no silent spread override)', () => {+ const perModule = Object.values(messageModules).map((m) => Object.keys(m).length);+ const total = perModule.reduce((a, b) => a + b, 0);+ expect(Object.keys(editorMessages).length).toBe(total);+ });++ it('placeholders match between languages on every entry', () => {+ const params = (s: string) => [...s.matchAll(/\{(\w+)\}/g)].map((m) => m[1]).sort();+ for (const [key, msg] of Object.entries(editorMessages)) {+ expect(params(msg.zh), `placeholder drift in '${key}'`).toEqual(params(msg.en));+ }+ });+});++describe('t()', () => {+ it('resolves English deterministically outside a browser window', () => {+ // Node ≥21 has a global navigator tracking the OS locale; the service must+ // ignore it without a window so this suite passes on any machine.+ expect(editorLocale).toBe('en');+ expect(t('cmd.entity.delete')).toBe('Delete');+ });++ it('interpolates params', () => {+ expect(t('set.layerN', { i: 3 })).toBe('Layer 3');+ expect(t('toast.updateAvailable', { version: '1.2.3' })).toContain('1.2.3');+ });++ it('the zh catalog serves the same keys through the shared engine', () => {+ // The editor's own t() is boot-locked to en here; drive a second+ // LocalizationApi over the same messages to pin the zh side.+ const zh: Record<string, string> = {};+ for (const [k, m] of Object.entries(editorMessages)) zh[k] = m.zh;+ const loc = new LocalizationApi('zh-CN', 'en');+ loc.addCatalog('zh-CN', zh);+ expect(loc.t('cmd.entity.delete')).toBe('删除');+ expect(loc.t('set.layerN', { i: 3 })).toBe('层 3');+ });+});