Skip to content

Commit bfb7c2d

Browse files
committed
feat(editor): internationalize MCP preview editor UI elements and messages
1 parent 8cb0f83 commit bfb7c2d

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

core/src/main/kotlin/cc/unitmesh/devti/mcp/editor/McpPreviewEditor.kt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package cc.unitmesh.devti.mcp.editor
22

33
import cc.unitmesh.devti.AutoDevIcons
4+
import cc.unitmesh.devti.AutoDevBundle
45
import cc.unitmesh.devti.AutoDevNotifications
56
import cc.unitmesh.devti.llm2.model.LlmConfig
67
import cc.unitmesh.devti.llms.custom.CustomLLMProvider
@@ -80,7 +81,7 @@ open class McpPreviewEditor(
8081
private fun createUI() {
8182
val headerPanel = panel {
8283
row {
83-
val label = JBLabel("MCP tools").apply {
84+
val label = JBLabel(AutoDevBundle.message("mcp.preview.editor.title")).apply {
8485
font = JBUI.Fonts.label(14.0f).asBold()
8586
border = JBUI.Borders.emptyLeft(8)
8687
isOpaque = true
@@ -89,7 +90,7 @@ open class McpPreviewEditor(
8990
cell(label).align(Align.FILL).resizableColumn()
9091

9192
searchField = SearchTextField().apply {
92-
textEditor.emptyText.text = "Search tools..."
93+
textEditor.emptyText.text = AutoDevBundle.message("mcp.preview.editor.search.placeholder")
9394
textEditor.document.addDocumentListener(object : DocumentListener {
9495
override fun insertUpdate(e: DocumentEvent) = filterTools()
9596
override fun removeUpdate(e: DocumentEvent) = filterTools()
@@ -142,7 +143,7 @@ open class McpPreviewEditor(
142143
background = UIUtil.getPanelBackground()
143144
}
144145

145-
val chatbotLabel = JBLabel("Model")
146+
val chatbotLabel = JBLabel(AutoDevBundle.message("mcp.preview.editor.model.label"))
146147

147148
val llmConfigs = LlmConfig.load()
148149
val modelNames = if (llmConfigs.isEmpty()) {
@@ -152,7 +153,7 @@ open class McpPreviewEditor(
152153
}
153154

154155
chatbotSelector = com.intellij.openapi.ui.ComboBox(modelNames)
155-
configButton = JButton("Configure").apply {
156+
configButton = JButton(AutoDevBundle.message("mcp.preview.editor.configure.button")).apply {
156157
isFocusPainted = false
157158
addActionListener {
158159
showConfigDialog()
@@ -191,7 +192,7 @@ open class McpPreviewEditor(
191192
testButton = ActionButton(
192193
DumbAwareAction.create { sendMessage() },
193194
sendPresentation,
194-
"McpSendAction",
195+
"McpSendAction",
195196
Dimension(JBUI.scale(30), JBUI.scale(30))
196197
)
197198
val sendButtonPanel = JPanel(FlowLayout(FlowLayout.CENTER, 0, 0)).apply {
@@ -247,7 +248,7 @@ open class McpPreviewEditor(
247248
}
248249

249250
if (chatInput.text.isEmpty()) {
250-
AutoDevNotifications.warn(project, "Please enter a message to send.")
251+
AutoDevNotifications.warn(project, AutoDevBundle.message("mcp.preview.editor.empty.message.warning"))
251252
return
252253
}
253254

@@ -263,7 +264,7 @@ open class McpPreviewEditor(
263264
val stream: Flow<String> = llmProvider.stream(message, systemPrompt = systemPrompt)
264265

265266
resultPanel.reset()
266-
resultPanel.setText("Loading response...")
267+
resultPanel.setText(AutoDevBundle.message("mcp.preview.editor.loading.response"))
267268
resultPanel.isVisible = true
268269
mainPanel.revalidate()
269270
mainPanel.repaint()

core/src/main/resources/messages/AutoDevBundle_en.properties

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,12 @@ mcp.tool.detail.dialog.verify=Verify (Auto Generate)
255255
mcp.tool.detail.dialog.result=Result
256256
mcp.tool.detail.dialog.execute=Execute
257257

258+
259+
# McpPreviewEditor
260+
mcp.preview.editor.title=MCP Tools
261+
mcp.preview.editor.search.placeholder=Search tools...
262+
mcp.preview.editor.model.label=Model
263+
mcp.preview.editor.configure.button=Configure
264+
mcp.preview.editor.test.button.tooltip=Test Called tools
265+
mcp.preview.editor.empty.message.warning=Please enter a message to send.
266+
mcp.preview.editor.loading.response=Loading response...

core/src/main/resources/messages/AutoDevBundle_zh.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,11 @@ mcp.tool.detail.dialog.parameters=参数
244244
mcp.tool.detail.dialog.verify=验证(自动生成)
245245
mcp.tool.detail.dialog.result=结果
246246
mcp.tool.detail.dialog.execute=执行
247+
# McpPreviewEditor
248+
mcp.preview.editor.title=MCP 工具
249+
mcp.preview.editor.search.placeholder=搜索工具...
250+
mcp.preview.editor.model.label=模型
251+
mcp.preview.editor.configure.button=配置
252+
mcp.preview.editor.test.button.tooltip=测试调用工具
253+
mcp.preview.editor.empty.message.warning=请输入要发送的消息
254+
mcp.preview.editor.loading.response=Loading response...

0 commit comments

Comments
 (0)