Skip to content

Commit d9db419

Browse files
committed
On web, send a message to the worker containing the translations
Translations weren't working at all when running the language server in a web worker. In fact, the server was crashing immediately, since the server was trying to load them from the filesystem. This PR provides the translations to the server using the webworker message passing mechanism. Requires redhat-developer/yaml-language-server#1165 Signed-off-by: David Thompson <davthomp@redhat.com>
1 parent c126488 commit d9db419

File tree

4 files changed

+6
-2
lines changed

4 files changed

+6
-2
lines changed

.vscode/launch.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@
4242
"--extensionDevelopmentPath=${workspaceFolder}",
4343
"--extensionDevelopmentKind=web"
4444
],
45+
"sourceMaps": true,
4546
"env": {
47+
"DEBUG_VSCODE_YAML": "true",
4648
"VSCODE_REDHAT_TELEMETRY_DEBUG":"true"
4749
},
4850
"outFiles": ["${workspaceRoot}/dist/**/*.js"],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"displayName": "YAML",
44
"description": "YAML Language Support by Red Hat, with built-in Kubernetes syntax support",
55
"author": "Red Hat",
6+
"l10n": "./dist/l10n",
67
"contributors": [
78
{
89
"name": "Joshua Pinkney",

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*--------------------------------------------------------------------------------------------*/
77
'use strict';
88

9-
import { workspace, ExtensionContext, extensions, window, commands, Uri } from 'vscode';
9+
import { workspace, ExtensionContext, extensions, window, commands, Uri, l10n } from 'vscode';
1010
import {
1111
CommonLanguageClient,
1212
LanguageClientOptions,

src/webworker/yamlClientMain.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Licensed under the MIT License. See License.txt in the project root for license information.
55
*--------------------------------------------------------------------------------------------*/
66

7-
import { ExtensionContext } from 'vscode';
7+
import { ExtensionContext, l10n } from 'vscode';
88
import { LanguageClientOptions } from 'vscode-languageclient';
99
import { startClient, LanguageClientConstructor, RuntimeEnvironment } from '../extension';
1010
import { LanguageClient } from 'vscode-languageclient/browser';
@@ -19,6 +19,7 @@ export async function activate(context: ExtensionContext): Promise<SchemaExtensi
1919
});
2020
try {
2121
const worker = new Worker(serverMain.toString());
22+
worker.postMessage({ l10nBundle: l10n.bundle });
2223
const newLanguageClient: LanguageClientConstructor = (id: string, name: string, clientOptions: LanguageClientOptions) => {
2324
return new LanguageClient(id, name, clientOptions, worker);
2425
};

0 commit comments

Comments
 (0)