Skip to content

Commit 4d72e00

Browse files
committed
refactor(i18n): standardize label creation with i18nLabel
Consolidate label methods by replacing jLabel, jBLabel with unified i18nLabel for better internationalization support and consistent UI rendering. This refactoring ensures all labels are properly localized throughout the application settings UI components.
1 parent ab9e24a commit 4d72e00

File tree

6 files changed

+29
-35
lines changed

6 files changed

+29
-35
lines changed

core/src/main/kotlin/cc/unitmesh/devti/settings/SimplifiedLLMSettingComponent.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package cc.unitmesh.devti.settings
33
import cc.unitmesh.devti.llm2.GithubCopilotManager
44
import cc.unitmesh.devti.settings.locale.HUMAN_LANGUAGES
55
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback
6+
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.i18nLabel
67
import cc.unitmesh.devti.settings.model.LLMModelManager
78
import cc.unitmesh.devti.settings.ui.DeleteButtonEditor
89
import cc.unitmesh.devti.settings.ui.DeleteButtonRenderer
@@ -302,12 +303,12 @@ class SimplifiedLLMSettingComponent(private val settings: AutoDevSettingsState)
302303
private fun FormBuilder.addLLMParam(llmParam: LLMParam): FormBuilder = apply {
303304
when (llmParam.type) {
304305
LLMParam.ParamType.Text -> {
305-
addLabeledComponent(JBLabel(llmParam.label), ReactiveTextField(llmParam) {
306+
addLabeledComponent(i18nLabel(llmParam.label), ReactiveTextField(llmParam) {
306307
isEnabled = it.isEditable
307308
}, 1, false)
308309
}
309310
LLMParam.ParamType.ComboBox -> {
310-
addLabeledComponent(JBLabel(llmParam.label), ReactiveComboBox(llmParam), 1, false)
311+
addLabeledComponent(i18nLabel(llmParam.label), ReactiveComboBox(llmParam), 1, false)
311312
}
312313
else -> {
313314
addSeparator()

core/src/main/kotlin/cc/unitmesh/devti/settings/coder/AutoDevCoderConfigurable.kt

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package cc.unitmesh.devti.settings.coder
22

33
import cc.unitmesh.devti.AutoDevBundle
44
import cc.unitmesh.devti.fullWidthCell
5-
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.jLabel
5+
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.i18nLabel
66
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.tips
77
import com.intellij.openapi.components.service
88
import com.intellij.openapi.options.BoundConfigurable
@@ -13,7 +13,6 @@ import com.intellij.ui.dsl.builder.panel
1313
import com.intellij.ui.dsl.builder.toMutableProperty
1414
import org.jetbrains.builtInWebServer.BuiltInServerOptions
1515
import java.net.InetAddress
16-
import java.net.NetworkInterface
1716
import javax.swing.JCheckBox
1817
import javax.swing.JTextField
1918

@@ -39,7 +38,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
3938
val state = settings.state.copy()
4039

4140
override fun createPanel(): DialogPanel = panel {
42-
row(jLabel("settings.autodev.coder.recordingInLocal")) {
41+
row(i18nLabel("settings.autodev.coder.recordingInLocal")) {
4342
fullWidthCell(recordingInLocalCheckBox)
4443
.bind(
4544
componentGet = { it.isSelected },
@@ -48,7 +47,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
4847
)
4948
}
5049

51-
row(jLabel("settings.autodev.coder.disableAdvanceContext")) {
50+
row(i18nLabel("settings.autodev.coder.disableAdvanceContext")) {
5251
fullWidthCell(disableAdvanceContextCheckBox)
5352
.bind(
5453
componentGet = { it.isSelected },
@@ -57,7 +56,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
5756
)
5857
}
5958

60-
row(jLabel("settings.autodev.coder.noChatHistory")) {
59+
row(i18nLabel("settings.autodev.coder.noChatHistory")) {
6160
fullWidthCell(noChatHistoryCheckBox)
6261
.bind(
6362
componentGet = { it.isSelected },
@@ -66,7 +65,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
6665
)
6766
}
6867

69-
row(jLabel("settings.autodev.coder.enableExportAsMcpServer")) {
68+
row(i18nLabel("settings.autodev.coder.enableExportAsMcpServer")) {
7069
fullWidthCell(enableMcpServerCheckBox)
7170
.bind(
7271
componentGet = { it.isSelected },
@@ -84,7 +83,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
8483
cell(portLabel)
8584
}
8685

87-
row(jLabel("settings.autodev.coder.enableObserver")) {
86+
row(i18nLabel("settings.autodev.coder.enableObserver")) {
8887
fullWidthCell(enableObserver)
8988
.bind(
9089
componentGet = { it.isSelected },
@@ -93,7 +92,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
9392
)
9493
}
9594

96-
row(jLabel("settings.autodev.coder.trimCodeBeforeSend")) {
95+
row(i18nLabel("settings.autodev.coder.trimCodeBeforeSend")) {
9796
fullWidthCell(trimCodeBeforeSend)
9897
.bind(
9998
componentGet = { it.isSelected },
@@ -102,7 +101,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
102101
)
103102
}
104103

105-
row(jLabel("settings.autodev.coder.inEditorCompletion")) {
104+
row(i18nLabel("settings.autodev.coder.inEditorCompletion")) {
106105
fullWidthCell(inEditorCompletionCheckBox)
107106
.bind(
108107
componentGet = { it.isSelected },
@@ -111,7 +110,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
111110
)
112111
}
113112

114-
row(jLabel("settings.autodev.coder.enableRenameSuggestion")) {
113+
row(i18nLabel("settings.autodev.coder.enableRenameSuggestion")) {
115114
fullWidthCell(JCheckBox())
116115
.bind(
117116
componentGet = { it.isSelected },
@@ -120,7 +119,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
120119
)
121120
}
122121

123-
row(jLabel("settings.autodev.coder.enableAutoRepairDiff")) {
122+
row(i18nLabel("settings.autodev.coder.enableAutoRepairDiff")) {
124123
fullWidthCell(enableAutoRepairDiff)
125124
.bind(
126125
componentGet = { it.isSelected },
@@ -129,7 +128,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
129128
)
130129
}
131130

132-
row(jLabel("settings.autodev.coder.enableAutoRunTerminal")) {
131+
row(i18nLabel("settings.autodev.coder.enableAutoRunTerminal")) {
133132
fullWidthCell(enableAutoRunTerminal)
134133
.bind(
135134
componentGet = { it.isSelected },
@@ -138,7 +137,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
138137
)
139138
}
140139

141-
row(jLabel("settings.autodev.coder.enableAutoLintCode")) {
140+
row(i18nLabel("settings.autodev.coder.enableAutoLintCode")) {
142141
fullWidthCell(enableAutoLintCode)
143142
.bind(
144143
componentGet = { it.isSelected },
@@ -147,7 +146,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
147146
)
148147
}
149148

150-
row(jLabel("settings.autodev.coder.enableRenderWebview")) {
149+
row(i18nLabel("settings.autodev.coder.enableRenderWebview")) {
151150
fullWidthCell(enableRenderWebview)
152151
.bind(
153152
componentGet = { it.isSelected },
@@ -156,7 +155,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
156155
)
157156
}
158157

159-
row(jLabel("settings.autodev.coder.enableAutoScrollInSketch")) {
158+
row(i18nLabel("settings.autodev.coder.enableAutoScrollInSketch")) {
160159
fullWidthCell(enableAutoScrollInSketch)
161160
.bind(
162161
componentGet = { it.isSelected },
@@ -165,7 +164,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
165164
)
166165
}
167166

168-
row(jLabel("settings.autodev.coder.enableDiffViewer")) {
167+
row(i18nLabel("settings.autodev.coder.enableDiffViewer")) {
169168
fullWidthCell(JCheckBox())
170169
.bind(
171170
componentGet = { it.isSelected },
@@ -174,7 +173,7 @@ class AutoDevCoderConfigurable(private val project: Project) : BoundConfigurable
174173
)
175174
}
176175

177-
row(jLabel("settings.external.team.prompts.path")) {
176+
row(i18nLabel("settings.external.team.prompts.path")) {
178177
fullWidthCell(teamPromptsField)
179178
.bind(
180179
componentGet = { it.text },

core/src/main/kotlin/cc/unitmesh/devti/settings/customize/CustomizeConfigurable.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import cc.unitmesh.devti.fullWidthCell
99
import cc.unitmesh.devti.mcp.client.McpServicesTestDialog
1010
import cc.unitmesh.devti.provider.local.JsonTextProvider
1111
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.componentStateChanged
12-
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.jBLabel
12+
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.i18nLabel
1313
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.placeholder
1414
import com.intellij.ide.BrowserUtil
1515
import com.intellij.openapi.Disposable
@@ -28,7 +28,7 @@ class CustomizeConfigurable(val project: Project) : BoundConfigurable(AutoDevBun
2828

2929
override fun createPanel(): DialogPanel = panel {
3030
row {
31-
cell(jBLabel("settings.autodev.coder.customActions", 1))
31+
cell(i18nLabel("settings.autodev.coder.customActions", 1))
3232

3333
link(AutoDevBundle.message("custom.action"), {
3434
BrowserUtil.browse("https://ide.unitmesh.cc/custom/action")
@@ -86,7 +86,7 @@ class CustomizeConfigurable(val project: Project) : BoundConfigurable(AutoDevBun
8686
)
8787
}
8888
row {
89-
cell(jBLabel("counit.mcp.services.placeholder", 1))
89+
cell(i18nLabel("counit.mcp.services.placeholder", 1))
9090
link(AutoDevBundle.message("sketch.mcp.services.docs"), {
9191
BrowserUtil.browse("https://ide.unitmesh.cc/mcp")
9292
})

core/src/main/kotlin/cc/unitmesh/devti/settings/locale/LanguageChangedCallback.kt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ object LanguageChangedCallback : SelectionChangedCallback {
2929

3030
private val callBacks = ConcurrentHashMap<String, LanguageChangedCallback.() -> Unit>()
3131

32-
fun jLabel(key: String, index: Int = 0): JLabel {
33-
return label(key, JLabel(), index)
34-
}
35-
36-
fun jBLabel(key: String, index: Int = 0): JLabel {
32+
fun i18nLabel(key: String, index: Int = 0): JLabel {
3733
return label(key, JBLabel(), index)
3834
}
3935

core/src/main/kotlin/cc/unitmesh/devti/settings/ui/FormBuilderExtensions.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package cc.unitmesh.devti.settings.ui
33
import cc.unitmesh.devti.settings.LLMParam
44
import cc.unitmesh.devti.settings.ReactiveComboBox
55
import cc.unitmesh.devti.settings.ReactiveTextField
6-
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.jBLabel
7-
import com.intellij.ui.components.JBTextField
6+
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.i18nLabel
87
import com.intellij.util.ui.FormBuilder
98

109
/**
@@ -13,12 +12,12 @@ import com.intellij.util.ui.FormBuilder
1312
fun FormBuilder.addLLMParam(llmParam: LLMParam): FormBuilder = apply {
1413
when (llmParam.type) {
1514
LLMParam.ParamType.Text -> {
16-
addLabeledComponent(jBLabel(llmParam.label), ReactiveTextField(llmParam) {
15+
addLabeledComponent(i18nLabel(llmParam.label), ReactiveTextField(llmParam) {
1716
this.isEnabled = it.isEditable
1817
}, 1, false)
1918
}
2019
LLMParam.ParamType.ComboBox -> {
21-
addLabeledComponent(jBLabel(llmParam.label), ReactiveComboBox(llmParam), 1, false)
20+
addLabeledComponent(i18nLabel(llmParam.label), ReactiveComboBox(llmParam), 1, false)
2221
}
2322
else -> {
2423
addSeparator()

core/src/main/kotlin/cc/unitmesh/devti/settings/ui/LLMUIComponents.kt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ package cc.unitmesh.devti.settings.ui
33
import cc.unitmesh.devti.settings.LLMParam
44
import cc.unitmesh.devti.settings.ReactiveComboBox
55
import cc.unitmesh.devti.settings.ReactiveTextField
6-
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.jBLabel
7-
import com.intellij.ui.components.JBLabel
6+
import cc.unitmesh.devti.settings.locale.LanguageChangedCallback.i18nLabel
87
import com.intellij.util.ui.FormBuilder
98

109
/**
@@ -13,12 +12,12 @@ import com.intellij.util.ui.FormBuilder
1312
private fun LLMParam.addToFormBuilder(formBuilder: FormBuilder) {
1413
when (this.type) {
1514
LLMParam.ParamType.Text -> {
16-
formBuilder.addLabeledComponent(jBLabel(this.label), ReactiveTextField(this) {
15+
formBuilder.addLabeledComponent(i18nLabel(this.label), ReactiveTextField(this) {
1716
this.isEnabled = it.isEditable
1817
}, 1, false)
1918
}
2019
LLMParam.ParamType.ComboBox -> {
21-
formBuilder.addLabeledComponent(jBLabel(this.label), ReactiveComboBox(this), 1, false)
20+
formBuilder.addLabeledComponent(i18nLabel(this.label), ReactiveComboBox(this), 1, false)
2221
}
2322
else -> {
2423
formBuilder.addSeparator()

0 commit comments

Comments
 (0)