feat(i18n): 统一国际化系统架构,支持插件独立翻译 (#301)
* feat(i18n): 统一国际化系统架构,支持插件独立翻译 ## 主要改动 ### 核心架构 - 增强 LocaleService,支持插件命名空间翻译扩展 - 新增 editor-runtime/i18n 模块,提供 createPluginLocale/createPluginTranslator - 新增 editor-core/tokens.ts,定义 LocaleServiceToken 等服务令牌 - 改进 PluginAPI 类型安全,使用 ServiceToken<T> 替代 any ### 编辑器本地化 - 扩展 en.ts/zh.ts 翻译文件,覆盖所有 UI 组件 - 新增 es.ts 西班牙语支持 - 重构 40+ 组件使用 useLocale() hook ### 插件本地化系统 - behavior-tree-editor: 新增 locales/ 和 useBTLocale hook - material-editor: 新增 locales/ 和 useMaterialLocale hook - particle-editor: 新增 locales/ 和 useParticleLocale hook - tilemap-editor: 新增 locales/ 和 useTilemapLocale hook - ui-editor: 新增 locales/ 和 useUILocale hook ### 类型安全改进 - 修复 Debug 工具使用公共接口替代 as any - 修复 ChunkStreamingSystem 添加 forEachChunk 公共方法 - 修复 blueprint-editor 移除不必要的向后兼容代码 * fix(behavior-tree-editor): 使用 ServiceToken 模式修复服务解析 - 创建 BehaviorTreeServiceToken 遵循"谁定义接口,谁导出Token"原则 - 使用 ServiceToken.id (symbol) 注册服务到 ServiceContainer - 更新 PluginSDKRegistry.resolveService 支持 ServiceToken 检测 - BehaviorTreeEditorPanel 现在使用类型安全的 PluginAPI.resolve * fix(behavior-tree-editor): 使用 ServiceContainer.resolve 获取类注册的服务 * fix: 修复多个包的依赖和类型问题 - core: EntityDataCollector.getEntityDetails 使用 HierarchySystem 获取父实体 - ui-editor: 添加 @esengine/editor-runtime 依赖 - tilemap-editor: 添加 @esengine/editor-runtime 依赖 - particle-editor: 添加 @esengine/editor-runtime 依赖
This commit is contained in:
137
packages/behavior-tree-editor/src/locales/en.ts
Normal file
137
packages/behavior-tree-editor/src/locales/en.ts
Normal file
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* English translations for Behavior Tree Editor
|
||||
* 行为树编辑器英文翻译
|
||||
*/
|
||||
export const en = {
|
||||
// ========================================
|
||||
// Toolbar
|
||||
// ========================================
|
||||
toolbar: {
|
||||
openFile: 'Open File (Ctrl+O)',
|
||||
save: 'Save (Ctrl+S)',
|
||||
saveUnsaved: 'Save (Ctrl+S) - Unsaved changes',
|
||||
export: 'Export Runtime Config',
|
||||
copyToClipboard: 'Copy JSON to Clipboard',
|
||||
run: 'Run (Play)',
|
||||
resume: 'Resume',
|
||||
pause: 'Pause',
|
||||
stop: 'Stop',
|
||||
step: 'Step',
|
||||
resetView: 'Reset View (scroll to zoom, Alt+drag to pan)',
|
||||
undo: 'Undo (Ctrl+Z)',
|
||||
redo: 'Redo (Ctrl+Shift+Z / Ctrl+Y)',
|
||||
goToRoot: 'Go to Root Node'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Execution Status
|
||||
// ========================================
|
||||
execution: {
|
||||
idle: 'Idle',
|
||||
running: 'Running',
|
||||
paused: 'Paused'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Node
|
||||
// ========================================
|
||||
node: {
|
||||
executionOrder: 'Execution Order: {{order}}',
|
||||
initialValue: 'Initial Value',
|
||||
currentValue: 'Current Value'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Context Menu
|
||||
// ========================================
|
||||
contextMenu: {
|
||||
delete: 'Delete',
|
||||
duplicate: 'Duplicate',
|
||||
copy: 'Copy',
|
||||
paste: 'Paste'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Quick Create Menu
|
||||
// ========================================
|
||||
quickCreate: {
|
||||
searchPlaceholder: 'Search nodes...',
|
||||
uncategorized: 'Uncategorized',
|
||||
noMatchingNodes: 'No matching nodes found'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Blackboard Panel
|
||||
// ========================================
|
||||
blackboard: {
|
||||
title: 'Blackboard',
|
||||
variableName: 'variable.name',
|
||||
copy: 'Copy',
|
||||
edit: 'Edit',
|
||||
delete: 'Delete',
|
||||
addVariable: 'Add Variable'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Compiler
|
||||
// ========================================
|
||||
compiler: {
|
||||
name: 'Behavior Tree Compiler',
|
||||
description: 'Compile behavior tree assets',
|
||||
selectAssetOutput: 'Select asset output directory...',
|
||||
selectTypeOutput: 'Select type definition output directory...',
|
||||
compile: 'Compile',
|
||||
compiling: 'Compiling...',
|
||||
success: 'Compilation successful',
|
||||
failed: 'Compilation failed'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Notifications
|
||||
// ========================================
|
||||
notifications: {
|
||||
fileSaved: 'File saved: {{path}}',
|
||||
fileSaveFailed: 'Failed to save file',
|
||||
fileOpened: 'File opened: {{path}}',
|
||||
fileOpenFailed: 'Failed to open file',
|
||||
copiedToClipboard: 'Copied to clipboard',
|
||||
exportSuccess: 'Export successful',
|
||||
exportFailed: 'Export failed',
|
||||
validationError: 'Validation error: {{message}}'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Dialogs
|
||||
// ========================================
|
||||
dialogs: {
|
||||
createBehaviorTree: 'Create Behavior Tree Asset',
|
||||
confirmDelete: 'Are you sure you want to delete this node?',
|
||||
unsavedChanges: 'You have unsaved changes. Do you want to save before closing?'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Panel
|
||||
// ========================================
|
||||
panel: {
|
||||
title: 'Behavior Tree Editor',
|
||||
noFileOpen: 'No behavior tree file is open',
|
||||
dropToOpen: 'Drop a .btree file here or use Open button'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Validation Errors
|
||||
// ========================================
|
||||
validation: {
|
||||
rootNodeMaxChildren: 'Root node can only connect to one child node',
|
||||
decoratorNodeMaxChildren: 'Decorator node can only connect to one child node',
|
||||
leafNodeNoChildren: 'Leaf node cannot have children',
|
||||
circularReference: 'Circular reference detected, node {{nodeId}} cannot connect to itself or its descendants',
|
||||
invalidConnection: 'Invalid connection: {{reason}}',
|
||||
nodeIdRequired: 'Node ID cannot be empty',
|
||||
nodeTemplateRequired: 'Node template cannot be empty',
|
||||
sourceNodeNotFound: 'Connection source node not found: {{nodeId}}',
|
||||
targetNodeNotFound: 'Connection target node not found: {{nodeId}}',
|
||||
selfConnection: 'Node cannot connect to itself',
|
||||
cycleDetected: 'Circular reference detected in behavior tree'
|
||||
}
|
||||
};
|
||||
138
packages/behavior-tree-editor/src/locales/es.ts
Normal file
138
packages/behavior-tree-editor/src/locales/es.ts
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* Spanish translations for Behavior Tree Editor
|
||||
* Traducciones en español del Editor de Árbol de Comportamiento
|
||||
*/
|
||||
export const es = {
|
||||
// ========================================
|
||||
// Toolbar
|
||||
// ========================================
|
||||
toolbar: {
|
||||
openFile: 'Abrir Archivo (Ctrl+O)',
|
||||
save: 'Guardar (Ctrl+S)',
|
||||
saveUnsaved: 'Guardar (Ctrl+S) - Cambios sin guardar',
|
||||
export: 'Exportar Configuración de Ejecución',
|
||||
copyToClipboard: 'Copiar JSON al Portapapeles',
|
||||
run: 'Ejecutar (Play)',
|
||||
resume: 'Continuar',
|
||||
pause: 'Pausar',
|
||||
stop: 'Detener',
|
||||
step: 'Paso a Paso',
|
||||
resetView: 'Restablecer Vista (scroll para zoom, Alt+arrastrar para desplazar)',
|
||||
undo: 'Deshacer (Ctrl+Z)',
|
||||
redo: 'Rehacer (Ctrl+Shift+Z / Ctrl+Y)',
|
||||
goToRoot: 'Ir al Nodo Raíz'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Execution Status
|
||||
// ========================================
|
||||
execution: {
|
||||
idle: 'Inactivo',
|
||||
running: 'Ejecutando',
|
||||
paused: 'Pausado'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Node
|
||||
// ========================================
|
||||
node: {
|
||||
executionOrder: 'Orden de Ejecución: {{order}}',
|
||||
initialValue: 'Valor Inicial',
|
||||
currentValue: 'Valor Actual'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Context Menu
|
||||
// ========================================
|
||||
contextMenu: {
|
||||
delete: 'Eliminar',
|
||||
duplicate: 'Duplicar',
|
||||
copy: 'Copiar',
|
||||
paste: 'Pegar'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Quick Create Menu
|
||||
// ========================================
|
||||
quickCreate: {
|
||||
searchPlaceholder: 'Buscar nodos...',
|
||||
uncategorized: 'Sin categoría',
|
||||
noMatchingNodes: 'No se encontraron nodos coincidentes'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Blackboard Panel
|
||||
// ========================================
|
||||
blackboard: {
|
||||
title: 'Pizarra',
|
||||
variableName: 'nombre.variable',
|
||||
copy: 'Copiar',
|
||||
edit: 'Editar',
|
||||
delete: 'Eliminar',
|
||||
addVariable: 'Agregar Variable'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Compiler
|
||||
// ========================================
|
||||
compiler: {
|
||||
name: 'Compilador de Árbol de Comportamiento',
|
||||
description: 'Compilar recursos de árbol de comportamiento',
|
||||
selectAssetOutput: 'Seleccionar directorio de salida de recursos...',
|
||||
selectTypeOutput: 'Seleccionar directorio de salida de definiciones de tipo...',
|
||||
compile: 'Compilar',
|
||||
compiling: 'Compilando...',
|
||||
success: 'Compilación exitosa',
|
||||
failed: 'Compilación fallida'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Notifications
|
||||
// ========================================
|
||||
notifications: {
|
||||
fileSaved: 'Archivo guardado: {{path}}',
|
||||
fileSaveFailed: 'Error al guardar archivo',
|
||||
fileOpened: 'Archivo abierto: {{path}}',
|
||||
fileOpenFailed: 'Error al abrir archivo',
|
||||
copiedToClipboard: 'Copiado al portapapeles',
|
||||
exportSuccess: 'Exportación exitosa',
|
||||
exportFailed: 'Exportación fallida',
|
||||
validationError: 'Error de validación: {{message}}'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Dialogs
|
||||
// ========================================
|
||||
dialogs: {
|
||||
createBehaviorTree: 'Crear Recurso de Árbol de Comportamiento',
|
||||
confirmDelete: '¿Está seguro de que desea eliminar este nodo?',
|
||||
unsavedChanges: 'Tiene cambios sin guardar. ¿Desea guardar antes de cerrar?'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Panel
|
||||
// ========================================
|
||||
panel: {
|
||||
title: 'Editor de Árbol de Comportamiento',
|
||||
noFileOpen: 'No hay archivo de árbol de comportamiento abierto',
|
||||
dropToOpen: 'Arrastre un archivo .btree aquí o use el botón Abrir'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Validation Errors
|
||||
// Errores de validación
|
||||
// ========================================
|
||||
validation: {
|
||||
rootNodeMaxChildren: 'El nodo raíz solo puede conectar a un nodo hijo',
|
||||
decoratorNodeMaxChildren: 'El nodo decorador solo puede conectar a un nodo hijo',
|
||||
leafNodeNoChildren: 'El nodo hoja no puede tener hijos',
|
||||
circularReference: 'Referencia circular detectada, el nodo {{nodeId}} no puede conectarse a sí mismo o a sus descendientes',
|
||||
invalidConnection: 'Conexión inválida: {{reason}}',
|
||||
nodeIdRequired: 'El ID del nodo no puede estar vacío',
|
||||
nodeTemplateRequired: 'La plantilla del nodo no puede estar vacía',
|
||||
sourceNodeNotFound: 'Nodo fuente de conexión no encontrado: {{nodeId}}',
|
||||
targetNodeNotFound: 'Nodo destino de conexión no encontrado: {{nodeId}}',
|
||||
selfConnection: 'El nodo no puede conectarse a sí mismo',
|
||||
cycleDetected: 'Referencia circular detectada en el árbol de comportamiento'
|
||||
}
|
||||
};
|
||||
9
packages/behavior-tree-editor/src/locales/index.ts
Normal file
9
packages/behavior-tree-editor/src/locales/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Behavior Tree Editor Locales
|
||||
* 行为树编辑器多语言支持
|
||||
*/
|
||||
export { en } from './en';
|
||||
export { zh } from './zh';
|
||||
export { es } from './es';
|
||||
|
||||
export type BehaviorTreeTranslations = typeof import('./en').en;
|
||||
138
packages/behavior-tree-editor/src/locales/zh.ts
Normal file
138
packages/behavior-tree-editor/src/locales/zh.ts
Normal file
@@ -0,0 +1,138 @@
|
||||
/**
|
||||
* Chinese translations for Behavior Tree Editor
|
||||
* 行为树编辑器中文翻译
|
||||
*/
|
||||
export const zh = {
|
||||
// ========================================
|
||||
// Toolbar
|
||||
// ========================================
|
||||
toolbar: {
|
||||
openFile: '打开文件 (Ctrl+O)',
|
||||
save: '保存 (Ctrl+S)',
|
||||
saveUnsaved: '保存 (Ctrl+S) - 有未保存的更改',
|
||||
export: '导出运行时配置',
|
||||
copyToClipboard: '复制JSON到剪贴板',
|
||||
run: '运行 (Play)',
|
||||
resume: '继续',
|
||||
pause: '暂停',
|
||||
stop: '停止',
|
||||
step: '单步执行',
|
||||
resetView: '重置视图 (滚轮缩放, Alt+拖动平移)',
|
||||
undo: '撤销 (Ctrl+Z)',
|
||||
redo: '重做 (Ctrl+Shift+Z / Ctrl+Y)',
|
||||
goToRoot: '回到根节点'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Execution Status
|
||||
// ========================================
|
||||
execution: {
|
||||
idle: '空闲',
|
||||
running: '运行中',
|
||||
paused: '已暂停'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Node
|
||||
// ========================================
|
||||
node: {
|
||||
executionOrder: '执行顺序: {{order}}',
|
||||
initialValue: '初始值',
|
||||
currentValue: '当前值'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Context Menu
|
||||
// ========================================
|
||||
contextMenu: {
|
||||
delete: '删除',
|
||||
duplicate: '复制',
|
||||
copy: '复制',
|
||||
paste: '粘贴'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Quick Create Menu
|
||||
// ========================================
|
||||
quickCreate: {
|
||||
searchPlaceholder: '搜索节点...',
|
||||
uncategorized: '未分类',
|
||||
noMatchingNodes: '未找到匹配的节点'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Blackboard Panel
|
||||
// ========================================
|
||||
blackboard: {
|
||||
title: '黑板',
|
||||
variableName: '变量名',
|
||||
copy: '复制',
|
||||
edit: '编辑',
|
||||
delete: '删除',
|
||||
addVariable: '添加变量'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Compiler
|
||||
// ========================================
|
||||
compiler: {
|
||||
name: '行为树编译器',
|
||||
description: '编译行为树资产',
|
||||
selectAssetOutput: '选择资产输出目录...',
|
||||
selectTypeOutput: '选择类型定义输出目录...',
|
||||
compile: '编译',
|
||||
compiling: '编译中...',
|
||||
success: '编译成功',
|
||||
failed: '编译失败'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Notifications
|
||||
// ========================================
|
||||
notifications: {
|
||||
fileSaved: '文件已保存: {{path}}',
|
||||
fileSaveFailed: '保存文件失败',
|
||||
fileOpened: '文件已打开: {{path}}',
|
||||
fileOpenFailed: '打开文件失败',
|
||||
copiedToClipboard: '已复制到剪贴板',
|
||||
exportSuccess: '导出成功',
|
||||
exportFailed: '导出失败',
|
||||
validationError: '验证错误: {{message}}'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Dialogs
|
||||
// ========================================
|
||||
dialogs: {
|
||||
createBehaviorTree: '创建行为树资产',
|
||||
confirmDelete: '确定要删除这个节点吗?',
|
||||
unsavedChanges: '有未保存的更改。关闭前是否保存?'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Panel
|
||||
// ========================================
|
||||
panel: {
|
||||
title: '行为树编辑器',
|
||||
noFileOpen: '没有打开的行为树文件',
|
||||
dropToOpen: '拖放 .btree 文件到这里或使用打开按钮'
|
||||
},
|
||||
|
||||
// ========================================
|
||||
// Validation Errors
|
||||
// 验证错误
|
||||
// ========================================
|
||||
validation: {
|
||||
rootNodeMaxChildren: '根节点只能连接一个子节点',
|
||||
decoratorNodeMaxChildren: '装饰节点只能连接一个子节点',
|
||||
leafNodeNoChildren: '叶子节点不能有子节点',
|
||||
circularReference: '检测到循环引用,节点 {{nodeId}} 不能连接到自己或其子节点',
|
||||
invalidConnection: '无效的连接:{{reason}}',
|
||||
nodeIdRequired: '节点 ID 不能为空',
|
||||
nodeTemplateRequired: '节点模板不能为空',
|
||||
sourceNodeNotFound: '连接的源节点不存在: {{nodeId}}',
|
||||
targetNodeNotFound: '连接的目标节点不存在: {{nodeId}}',
|
||||
selfConnection: '节点不能连接到自己',
|
||||
cycleDetected: '行为树中存在循环引用'
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user