Skip to content

Commit 179fddc

Browse files
committed
refactor(devti): internationalize patch application and diff viewing
- Add localized messages for patch application and diff viewing- Update logger warnings and errors to use localized messages - Replace hardcoded strings in diff requests with localized alternatives
1 parent a57a13a commit 179fddc

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/ui/patch/SingleFileDiffSketch.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class SingleFileDiffSketch(
7474
val apply = GenericPatchApplier.apply(oldCode, patch.hunks)
7575
apply
7676
} catch (e: Exception) {
77-
logger<SingleFileDiffSketch>().warn("Failed to apply patch: ${patch.beforeFileName}", e)
77+
logger<SingleFileDiffSketch>().warn(AutoDevBundle.message("sketch.patch.failed.apply", patch.beforeFileName ?: ""), e)
7878
null
7979
}
8080

@@ -224,7 +224,7 @@ class SingleFileDiffSketch(
224224
val newDocContent = diffFactory.create(newCode)
225225

226226
val diffRequest =
227-
SimpleDiffRequest("Diff", currentDocContent, newDocContent, "Original", "AI suggestion")
227+
SimpleDiffRequest("Diff", currentDocContent, newDocContent, AutoDevBundle.message("sketch.diff.original"), AutoDevBundle.message("sketch.diff.aiSuggestion"))
228228
return diffRequest
229229
}
230230

@@ -233,7 +233,7 @@ class SingleFileDiffSketch(
233233
val newDocContent = diffFactory.create(newCode)
234234

235235
val diffRequest =
236-
SimpleDiffRequest("Diff", EmptyContent(), newDocContent, "", "AI suggestion")
236+
SimpleDiffRequest("Diff", EmptyContent(), newDocContent, "", AutoDevBundle.message("sketch.diff.aiSuggestion"))
237237
return diffRequest
238238
}
239239

@@ -280,7 +280,7 @@ class SingleFileDiffSketch(
280280

281281
val document = FileDocumentManager.getInstance().getDocument(file)
282282
if (document == null) {
283-
logger<SingleFileDiffSketch>().error("Document is null for file: ${file.path}")
283+
logger<SingleFileDiffSketch>().error(AutoDevBundle.message("sketch.patch.document.null", file.path))
284284
return@addActionListener
285285
}
286286

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ sketch.patch.repaired=Repaired
181181
sketch.patch.repair=Repair
182182
sketch.patch.apply=Apply
183183
sketch.patch.view=View
184+
sketch.diff.original=Original
185+
sketch.diff.aiSuggestion=AI suggestion
186+
sketch.patch.failed.read=Failed to read file: {0}
187+
sketch.patch.failed.apply=Failed to apply patch: {0}
188+
sketch.patch.document.null=Document is null for file: {0}
184189
autodev.save.as.file=Save File As
185190
autodev.save.as.file.description=Choose location to save the file
186191
sketch.terminal.show.hide=Show or hide the terminal

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,11 @@ sketch.patch.repaired=已修复
173173
sketch.patch.repair=修复
174174
sketch.patch.apply=采用
175175
sketch.patch.view=查看
176+
sketch.diff.original=原始代码
177+
sketch.diff.aiSuggestion=AI 建议
178+
sketch.patch.failed.read=读取文件失败: {0}
179+
sketch.patch.failed.apply=应用补丁失败: {0}
180+
sketch.patch.document.null=文件 {0} 的文档为空
176181
autodev.save.as.file=保存文件
177182
autodev.save.as.file.description=选择待保存文件位置
178183
sketch.terminal.show.hide=显示或隐藏终端

0 commit comments

Comments
 (0)