@@ -5,13 +5,13 @@ We can remove this once upstream supports all language packs.
5
5
1. Proxies language packs to the service on the backend.
6
6
2. NLS configuration is embedded into the HTML for the browser to pick up. This
7
7
code to generate this configuration is copied from the native portion.
8
- 3. Remove navigator.language default since that will prevent the argv file from
9
- being created if you are changing the language to whatever your browser
10
- default happens to be.
8
+ 3. Remove configuredLocale since we have our own thing.
11
9
4. Move the argv.json file to the server instead of in-browser storage. This is
12
10
where the current locale is stored and currently the server needs to be able
13
11
to read it.
14
12
5. Add the locale flag.
13
+ 6. Remove the redundant locale verification. It does the same as the existing
14
+ one but is worse because it does not handle non-existent or empty files.
15
15
16
16
Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
17
17
===================================================================
@@ -31,8 +31,29 @@ Index: code-server/lib/vscode/src/vs/base/common/platform.ts
31
31
===================================================================
32
32
--- code-server.orig/lib/vscode/src/vs/base/common/platform.ts
33
33
+++ code-server/lib/vscode/src/vs/base/common/platform.ts
34
- @@ -92,6 +92,16 @@ if (typeof navigator === 'object' && !is
35
- _locale = configuredLocale || LANGUAGE_DEFAULT;
34
+ @@ -2,8 +2,6 @@
35
+ * Copyright (c) Microsoft Corporation. All rights reserved.
36
+ * Licensed under the MIT License. See License.txt in the project root for license information.
37
+ *--------------------------------------------------------------------------------------------*/
38
+ - import * as nls from 'vs/nls';
39
+ -
40
+ const LANGUAGE_DEFAULT = 'en';
41
+
42
+ let _isWindows = false;
43
+ @@ -81,17 +79,19 @@ if (typeof navigator === 'object' && !is
44
+ _isLinux = _userAgent.indexOf('Linux') >= 0;
45
+ _isWeb = true;
46
+
47
+ - const configuredLocale = nls.getConfiguredDefaultLocale(
48
+ - // This call _must_ be done in the file that calls `nls.getConfiguredDefaultLocale`
49
+ - // to ensure that the NLS AMD Loader plugin has been loaded and configured.
50
+ - // This is because the loader plugin decides what the default locale is based on
51
+ - // how it's able to resolve the strings.
52
+ - nls.localize({ key: 'ensureLoaderPluginIsLoaded', comment: ['{Locked}'] }, '_')
53
+ - );
54
+ -
55
+ - _locale = configuredLocale || LANGUAGE_DEFAULT;
56
+ + _locale = LANGUAGE_DEFAULT;
36
57
37
58
_language = _locale;
38
59
+ const el = typeof document !== 'undefined' && document.getElementById('vscode-remote-nls-configuration');
@@ -225,45 +246,59 @@ Index: code-server/lib/vscode/src/vs/workbench/workbench.web.main.ts
225
246
===================================================================
226
247
--- code-server.orig/lib/vscode/src/vs/workbench/workbench.web.main.ts
227
248
+++ code-server/lib/vscode/src/vs/workbench/workbench.web.main.ts
228
- @@ -113,6 +113,12 @@ registerSingleton(ILanguagePackService,
249
+ @@ -122,8 +122,9 @@ import 'vs/workbench/contrib/logs/browse
250
+ // Explorer
251
+ import 'vs/workbench/contrib/files/browser/files.web.contribution';
229
252
230
- //#region --- workbench contributions
231
-
232
- + // Localization. These do not actually import anything specific to Electron so
233
- + // they should be safe.
234
- + import 'vs/workbench/contrib/localization/electron-sandbox/localeService';
253
+ - // Localization
254
+ - import 'vs/workbench/contrib/localization/browser/localization.contribution';
255
+ + // Localization. This does not actually import anything specific to Electron so
256
+ + // it should be safe.
235
257
+ import 'vs/workbench/contrib/localization/electron-sandbox/localization.contribution';
236
- + import 'vs/platform/languagePacks/browser/languagePacks';
237
- +
238
- // Output
239
- import 'vs/workbench/contrib/output/common/outputChannelModelService';
240
258
259
+ // Performance
260
+ import 'vs/workbench/contrib/performance/browser/performance.web.contribution';
241
261
Index: code-server/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
242
262
===================================================================
243
263
--- code-server.orig/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
244
264
+++ code-server/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
245
- @@ -4,7 +4,24 @@
265
+ @@ -4,10 +4,23 @@
246
266
*--------------------------------------------------------------------------------------------*/
247
267
248
268
import { ILanguagePackItem, LanguagePackBaseService } from 'vs/platform/languagePacks/common/languagePacks';
249
269
+ import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
250
- + import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
251
270
+ import { ILanguagePackService } from 'vs/platform/languagePacks/common/languagePacks';
252
271
+ import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
272
+ + import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
253
273
254
- + // @ts-ignore: interface is implemented via proxy
255
- + export class LanguagePackService implements ILanguagePackService {
256
- +
257
- + declare readonly _serviceBrand: undefined;
274
+ export class WebLanguagePacksService extends LanguagePackBaseService {
275
+ - // Web doesn't have a concept of language packs, so we just return an empty array
276
+ + private readonly languagePackService: ILanguagePackService;
258
277
+
259
278
+ constructor(
260
279
+ @IRemoteAgentService remoteAgentService: IRemoteAgentService,
280
+ + @IExtensionGalleryService extensionGalleryService: IExtensionGalleryService
261
281
+ ) {
262
- + return ProxyChannel.toService<ILanguagePackService>(remoteAgentService.getConnection()!.getChannel('languagePacks'));
282
+ + super(extensionGalleryService)
283
+ + this.languagePackService = ProxyChannel.toService<ILanguagePackService>(remoteAgentService.getConnection()!.getChannel('languagePacks'));
263
284
+ }
264
- + }
265
285
+
266
- + registerSingleton(ILanguagePackService, LanguagePackService, true);
267
- export class WebLanguagePacksService extends LanguagePackBaseService {
268
- // Web doesn't have a concept of language packs, so we just return an empty array
269
286
getInstalledLanguages(): Promise<ILanguagePackItem[]> {
287
+ - return Promise.resolve([]);
288
+ + return this.languagePackService.getInstalledLanguages()
289
+ }
290
+ }
291
+ Index: code-server/lib/vscode/src/vs/workbench/contrib/localization/electron-sandbox/localeService.ts
292
+ ===================================================================
293
+ --- code-server.orig/lib/vscode/src/vs/workbench/contrib/localization/electron-sandbox/localeService.ts
294
+ +++ code-server/lib/vscode/src/vs/workbench/contrib/localization/electron-sandbox/localeService.ts
295
+ @@ -68,9 +68,6 @@ export class NativeLocaleService impleme
296
+ }
297
+
298
+ private async writeLocaleValue(locale: string | undefined): Promise<boolean> {
299
+ - if (!(await this.validateLocaleFile())) {
300
+ - return false;
301
+ - }
302
+ await this.jsonEditingService.write(this.environmentService.argvResource, [{ path: ['locale'], value: locale }], true);
303
+ return true;
304
+ }
0 commit comments