mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-10-29 18:52:45 +08:00
refactor(vscode): simplify autocomplete i18n locale lookup
This commit is contained in:
@@ -181,7 +181,7 @@ export class AutocompleteServiceManager {
|
||||
)
|
||||
|
||||
this.config = vscode.workspace.onDidChangeConfiguration((event) => {
|
||||
if (event.affectsConfiguration("kilo-code.language") || event.affectsConfiguration("kilo-code.new.language")) {
|
||||
if (event.affectsConfiguration("kilo-code.new.language")) {
|
||||
this.updateStatusBar()
|
||||
}
|
||||
})
|
||||
|
||||
@@ -61,9 +61,8 @@ export function resolveLocale(lang: string | undefined): string {
|
||||
}
|
||||
|
||||
export function selectedLocale(vscode: typeof import("vscode")): string {
|
||||
const cfg = vscode.workspace.getConfiguration("kilo-code")
|
||||
const next = vscode.workspace.getConfiguration("kilo-code.new")
|
||||
const lang = next.get<string>("language") || cfg.get<string>("language")
|
||||
const cfg = vscode.workspace.getConfiguration("kilo-code.new")
|
||||
const lang = cfg.get<string>("language")
|
||||
return resolveLocale(lang || vscode.env.language)
|
||||
}
|
||||
|
||||
|
||||
@@ -115,26 +115,26 @@ import { dict as cliNl } from "../../src/services/cli-backend/i18n/nl"
|
||||
import { dict as cliUk } from "../../src/services/cli-backend/i18n/uk"
|
||||
import { dict as cliIt } from "../../src/services/cli-backend/i18n/it"
|
||||
|
||||
import { dict as hostEn, autocompleteDict as acEn } from "../../src/services/i18n/en"
|
||||
import { dict as hostZh, autocompleteDict as acZh } from "../../src/services/i18n/zh"
|
||||
import { dict as hostZht, autocompleteDict as acZht } from "../../src/services/i18n/zht"
|
||||
import { dict as hostDe, autocompleteDict as acDe } from "../../src/services/i18n/de"
|
||||
import { dict as hostEs, autocompleteDict as acEs } from "../../src/services/i18n/es"
|
||||
import { dict as hostFr, autocompleteDict as acFr } from "../../src/services/i18n/fr"
|
||||
import { dict as hostDa, autocompleteDict as acDa } from "../../src/services/i18n/da"
|
||||
import { dict as hostJa, autocompleteDict as acJa } from "../../src/services/i18n/ja"
|
||||
import { dict as hostKo, autocompleteDict as acKo } from "../../src/services/i18n/ko"
|
||||
import { dict as hostPl, autocompleteDict as acPl } from "../../src/services/i18n/pl"
|
||||
import { dict as hostRu, autocompleteDict as acRu } from "../../src/services/i18n/ru"
|
||||
import { dict as hostAr, autocompleteDict as acAr } from "../../src/services/i18n/ar"
|
||||
import { dict as hostNo, autocompleteDict as acNo } from "../../src/services/i18n/no"
|
||||
import { dict as hostBr, autocompleteDict as acBr } from "../../src/services/i18n/br"
|
||||
import { dict as hostTh, autocompleteDict as acTh } from "../../src/services/i18n/th"
|
||||
import { dict as hostBs, autocompleteDict as acBs } from "../../src/services/i18n/bs"
|
||||
import { dict as hostTr, autocompleteDict as acTr } from "../../src/services/i18n/tr"
|
||||
import { dict as hostNl, autocompleteDict as acNl } from "../../src/services/i18n/nl"
|
||||
import { dict as hostUk, autocompleteDict as acUk } from "../../src/services/i18n/uk"
|
||||
import { dict as hostIt, autocompleteDict as acIt } from "../../src/services/i18n/it"
|
||||
import { dict as hostEn } from "../../src/services/i18n/en"
|
||||
import { dict as hostZh } from "../../src/services/i18n/zh"
|
||||
import { dict as hostZht } from "../../src/services/i18n/zht"
|
||||
import { dict as hostDe } from "../../src/services/i18n/de"
|
||||
import { dict as hostEs } from "../../src/services/i18n/es"
|
||||
import { dict as hostFr } from "../../src/services/i18n/fr"
|
||||
import { dict as hostDa } from "../../src/services/i18n/da"
|
||||
import { dict as hostJa } from "../../src/services/i18n/ja"
|
||||
import { dict as hostKo } from "../../src/services/i18n/ko"
|
||||
import { dict as hostPl } from "../../src/services/i18n/pl"
|
||||
import { dict as hostRu } from "../../src/services/i18n/ru"
|
||||
import { dict as hostAr } from "../../src/services/i18n/ar"
|
||||
import { dict as hostNo } from "../../src/services/i18n/no"
|
||||
import { dict as hostBr } from "../../src/services/i18n/br"
|
||||
import { dict as hostTh } from "../../src/services/i18n/th"
|
||||
import { dict as hostBs } from "../../src/services/i18n/bs"
|
||||
import { dict as hostTr } from "../../src/services/i18n/tr"
|
||||
import { dict as hostNl } from "../../src/services/i18n/nl"
|
||||
import { dict as hostUk } from "../../src/services/i18n/uk"
|
||||
import { dict as hostIt } from "../../src/services/i18n/it"
|
||||
|
||||
// ── Locale maps ─────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -232,29 +232,6 @@ const cliLocales: Record<string, Record<string, string>> = {
|
||||
it: cliIt,
|
||||
}
|
||||
|
||||
const acLocales: Record<string, Record<string, string>> = {
|
||||
en: acEn,
|
||||
zh: acZh,
|
||||
zht: acZht,
|
||||
de: acDe,
|
||||
es: acEs,
|
||||
fr: acFr,
|
||||
da: acDa,
|
||||
ja: acJa,
|
||||
ko: acKo,
|
||||
pl: acPl,
|
||||
ru: acRu,
|
||||
ar: acAr,
|
||||
no: acNo,
|
||||
br: acBr,
|
||||
th: acTh,
|
||||
bs: acBs,
|
||||
tr: acTr,
|
||||
nl: acNl,
|
||||
uk: acUk,
|
||||
it: acIt,
|
||||
}
|
||||
|
||||
const hostLocales: Record<string, Record<string, string>> = {
|
||||
en: hostEn,
|
||||
zh: hostZh,
|
||||
@@ -505,17 +482,6 @@ describe("i18n locale completeness — every English key exists in all locales",
|
||||
expect(missing).toEqual([])
|
||||
})
|
||||
|
||||
it("autocomplete: every English key has a translation in all locales", () => {
|
||||
const missing = findMissingLocaleKeys(acEn, acLocales)
|
||||
if (missing.length > 0) {
|
||||
expect(
|
||||
missing,
|
||||
`Found ${missing.length} missing autocomplete translation(s):\n${formatLocaleReport(missing)}`,
|
||||
).toEqual([])
|
||||
}
|
||||
expect(missing).toEqual([])
|
||||
})
|
||||
|
||||
it("extension host: every English key has a translation in all locales", () => {
|
||||
const missing = findMissingLocaleKeys(hostEn, hostLocales)
|
||||
if (missing.length > 0) {
|
||||
|
||||
@@ -90,19 +90,6 @@ describe("extension host i18n", () => {
|
||||
expect(selectedLocale(vscode)).toBe("de")
|
||||
})
|
||||
|
||||
it("falls back to legacy Kilo language setting", () => {
|
||||
const vscode = {
|
||||
env: { language: "en" },
|
||||
workspace: {
|
||||
getConfiguration: (section: string) => ({
|
||||
get: () => (section === "kilo-code" ? "nl" : undefined),
|
||||
}),
|
||||
},
|
||||
} as unknown as typeof import("vscode")
|
||||
|
||||
expect(selectedLocale(vscode)).toBe("nl")
|
||||
})
|
||||
|
||||
it("uses VS Code language when Kilo language setting is automatic", () => {
|
||||
const vscode = {
|
||||
env: { language: "nl" },
|
||||
|
||||
Reference in New Issue
Block a user