diff --git a/spx-gui/src/components/editor/code-editor/code-editor.ts b/spx-gui/src/components/editor/code-editor/code-editor.ts index 6cdfbee00..a36642f9e 100644 --- a/spx-gui/src/components/editor/code-editor/code-editor.ts +++ b/spx-gui/src/components/editor/code-editor/code-editor.ts @@ -728,6 +728,18 @@ export class CodeEditor extends Disposable { this.hoverProvider = new HoverProvider(this.lspClient, this.documentBase) } + async setLocale(locale: string) { + await this.lspClient.initialize( + { signal: new AbortController().signal }, + { + processId: null, + rootUri: null, + capabilities: {}, + locale + } + ) + } + private registerMCPTools(): void { // Register tools for code editor this.registry.registerTools( diff --git a/spx-gui/src/components/editor/code-editor/lsp/index.ts b/spx-gui/src/components/editor/code-editor/lsp/index.ts index f32f06474..22e4ee1a7 100644 --- a/spx-gui/src/components/editor/code-editor/lsp/index.ts +++ b/spx-gui/src/components/editor/code-editor/lsp/index.ts @@ -232,6 +232,10 @@ export class SpxLSPClient extends Disposable { }) } + async initialize(ctx: RequestContext, params: lsp.InitializeParams): Promise { + return this.request(ctx, lsp.InitializeRequest.method, params) + } + async workspaceExecuteCommandSpxGetDefinitions( ctx: RequestContext, ...params: spxGetDefinitions.Arguments diff --git a/spx-gui/src/components/editor/code-editor/ui/CodeEditorUI.vue b/spx-gui/src/components/editor/code-editor/ui/CodeEditorUI.vue index 3ee82c3d3..317d11799 100644 --- a/spx-gui/src/components/editor/code-editor/ui/CodeEditorUI.vue +++ b/spx-gui/src/components/editor/code-editor/ui/CodeEditorUI.vue @@ -214,10 +214,19 @@ watch( signal.addEventListener('abort', () => { codeEditorCtx.mustEditor().detachUI(ui) }) + + await codeEditorCtx.mustEditor().setLocale(i18n.lang.value) }, { immediate: true } ) +watch( + () => i18n.lang.value, + async (newLang) => { + await codeEditorCtx.mustEditor().setLocale(newLang) + } +) + const codeEditorUICtx = computedShallowReactive(() => ({ ui: uiRef.value }))