Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions packages/ui/src/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"ui": {
"panel": {
"ready": "Ready",
"thinking": "Thinking...",
"taskInput": "Enter new task, describe steps in detail, press Enter to submit",
"userAnswerPrompt": "Please answer the question above, press Enter to submit",
"taskTerminated": "Task terminated",
"taskCompleted": "Task completed",
"userAnswer": "User answer: {{input}}",
"question": "Question: {{question}}",
"waitingPlaceholder": "Waiting for task to start...",
"stop": "Stop",
"close": "Close",
"expand": "Expand history",
"collapse": "Collapse history",
"step": "Step {{number}}"
},
"tools": {
"clicking": "Clicking element [{{index}}]...",
"inputting": "Inputting text to element [{{index}}]...",
"selecting": "Selecting option \"{{text}}\"...",
"scrolling": "Scrolling page...",
"waiting": "Waiting {{seconds}} seconds...",
"askingUser": "Asking user...",
"done": "Task done",
"clicked": "🖱️ Clicked element [{{index}}]",
"inputted": "⌨️ Inputted text \"{{text}}\"",
"selected": "☑️ Selected option \"{{text}}\"",
"scrolled": "🛞 Page scrolled",
"waited": "⌛️ Wait completed",
"executing": "Executing {{toolName}}...",
"resultSuccess": "success",
"resultFailure": "failed",
"resultError": "error"
},
"errors": {
"elementNotFound": "No interactive element found at index {{index}}",
"taskRequired": "Task description is required",
"executionFailed": "Task execution failed",
"notInputElement": "Element is not an input or textarea",
"notSelectElement": "Element is not a select element",
"optionNotFound": "Option \"{{text}}\" not found"
}
}
}
105 changes: 4 additions & 101 deletions packages/ui/src/i18n/locales.ts
Original file line number Diff line number Diff line change
@@ -1,105 +1,8 @@
// English translations (base/reference language)
const enUS = {
ui: {
panel: {
ready: 'Ready',
thinking: 'Thinking...',
taskInput: 'Enter new task, describe steps in detail, press Enter to submit',
userAnswerPrompt: 'Please answer the question above, press Enter to submit',
taskTerminated: 'Task terminated',
taskCompleted: 'Task completed',
userAnswer: 'User answer: {{input}}',
question: 'Question: {{question}}',
waitingPlaceholder: 'Waiting for task to start...',
stop: 'Stop',
close: 'Close',
expand: 'Expand history',
collapse: 'Collapse history',
step: 'Step {{number}}',
},
tools: {
clicking: 'Clicking element [{{index}}]...',
inputting: 'Inputting text to element [{{index}}]...',
selecting: 'Selecting option "{{text}}"...',
scrolling: 'Scrolling page...',
waiting: 'Waiting {{seconds}} seconds...',
askingUser: 'Asking user...',
done: 'Task done',
clicked: '🖱️ Clicked element [{{index}}]',
inputted: '⌨️ Inputted text "{{text}}"',
selected: '☑️ Selected option "{{text}}"',
scrolled: '🛞 Page scrolled',
waited: '⌛️ Wait completed',
executing: 'Executing {{toolName}}...',
resultSuccess: 'success',
resultFailure: 'failed',
resultError: 'error',
},
errors: {
elementNotFound: 'No interactive element found at index {{index}}',
taskRequired: 'Task description is required',
executionFailed: 'Task execution failed',
notInputElement: 'Element is not an input or textarea',
notSelectElement: 'Element is not a select element',
optionNotFound: 'Option "{{text}}" not found',
},
},
} as const

// Chinese translations (must match the structure of enUS)
const zhCN = {
ui: {
panel: {
ready: '准备就绪',
thinking: '正在思考...',
taskInput: '输入新任务,详细描述步骤,回车提交',
userAnswerPrompt: '请回答上面问题,回车提交',
taskTerminated: '任务已终止',
taskCompleted: '任务结束',
userAnswer: '用户回答: {{input}}',
question: '询问: {{question}}',
waitingPlaceholder: '等待任务开始...',
stop: '终止',
close: '关闭',
expand: '展开历史',
collapse: '收起历史',
step: '步骤 {{number}}',
},
tools: {
clicking: '正在点击元素 [{{index}}]...',
inputting: '正在输入文本到元素 [{{index}}]...',
selecting: '正在选择选项 "{{text}}"...',
scrolling: '正在滚动页面...',
waiting: '等待 {{seconds}} 秒...',
askingUser: '正在询问用户...',
done: '结束任务',
clicked: '🖱️ 已点击元素 [{{index}}]',
inputted: '⌨️ 已输入文本 "{{text}}"',
selected: '☑️ 已选择选项 "{{text}}"',
scrolled: '🛞 页面滚动完成',
waited: '⌛️ 等待完成',
executing: '正在执行 {{toolName}}...',
resultSuccess: '成功',
resultFailure: '失败',
resultError: '错误',
},
errors: {
elementNotFound: '未找到索引为 {{index}} 的交互元素',
taskRequired: '任务描述不能为空',
executionFailed: '任务执行失败',
notInputElement: '元素不是输入框或文本域',
notSelectElement: '元素不是选择框',
optionNotFound: '未找到选项 "{{text}}"',
},
},
} as const

// Type definitions generated from English base structure (but with string values)
type DeepStringify<T> = {
[K in keyof T]: T[K] extends string ? string : T[K] extends object ? DeepStringify<T[K]> : T[K]
}
// JSON locale imports
import enUS from './en.json'
import zhCN from './zh.json'

export type TranslationSchema = DeepStringify<typeof enUS>
export type TranslationSchema = typeof enUS

// Utility type: Extract all nested paths from translation object
type NestedKeyOf<ObjectType extends object> = {
Expand Down
46 changes: 46 additions & 0 deletions packages/ui/src/i18n/zh.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"ui": {
"panel": {
"ready": "准备就绪",
"thinking": "正在思考...",
"taskInput": "输入新任务,详细描述步骤,回车提交",
"userAnswerPrompt": "请回答上面问题,回车提交",
"taskTerminated": "任务已终止",
"taskCompleted": "任务结束",
"userAnswer": "用户回答: {{input}}",
"question": "询问: {{question}}",
"waitingPlaceholder": "等待任务开始...",
"stop": "终止",
"close": "关闭",
"expand": "展开历史",
"collapse": "收起历史",
"step": "步骤 {{number}}"
},
"tools": {
"clicking": "正在点击元素 [{{index}}]...",
"inputting": "正在输入文本到元素 [{{index}}]...",
"selecting": "正在选择选项 \"{{text}}\"...",
"scrolling": "正在滚动页面...",
"waiting": "等待 {{seconds}} 秒...",
"askingUser": "正在询问用户...",
"done": "结束任务",
"clicked": "🖱️ 已点击元素 [{{index}}]",
"inputted": "⌨️ 已输入文本 \"{{text}}\"",
"selected": "☑️ 已选择选项 \"{{text}}\"",
"scrolled": "🛞 页面滚动完成",
"waited": "⌛️ 等待完成",
"executing": "正在执行 {{toolName}}...",
"resultSuccess": "成功",
"resultFailure": "失败",
"resultError": "错误"
},
"errors": {
"elementNotFound": "未找到索引为 {{index}} 的交互元素",
"taskRequired": "任务描述不能为空",
"executionFailed": "任务执行失败",
"notInputElement": "元素不是输入框或文本域",
"notSelectElement": "元素不是选择框",
"optionNotFound": "未找到选项 \"{{text}}\""
}
}
}
5 changes: 3 additions & 2 deletions packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo"
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.tsbuildinfo",
"resolveJsonModule": true
},
"include": ["**/*.ts", "**/*.js"],
"include": ["**/*.ts", "**/*.js", "**/*.json"],
"exclude": ["dist", "node_modules"]
}