Skip to content

Commit 14a474e

Browse files
committed
Fix display languages
1 parent 1798d5e commit 14a474e

File tree

1 file changed

+61
-26
lines changed

1 file changed

+61
-26
lines changed

patches/display-language.diff

Lines changed: 61 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ We can remove this once upstream supports all language packs.
55
1. Proxies language packs to the service on the backend.
66
2. NLS configuration is embedded into the HTML for the browser to pick up. This
77
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.
119
4. Move the argv.json file to the server instead of in-browser storage. This is
1210
where the current locale is stored and currently the server needs to be able
1311
to read it.
1412
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.
1515

1616
Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
1717
===================================================================
@@ -31,8 +31,29 @@ Index: code-server/lib/vscode/src/vs/base/common/platform.ts
3131
===================================================================
3232
--- code-server.orig/lib/vscode/src/vs/base/common/platform.ts
3333
+++ 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;
3657

3758
_language = _locale;
3859
+ 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
225246
===================================================================
226247
--- code-server.orig/lib/vscode/src/vs/workbench/workbench.web.main.ts
227248
+++ 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';
229252

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.
235257
+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';
240258

259+
// Performance
260+
import 'vs/workbench/contrib/performance/browser/performance.web.contribution';
241261
Index: code-server/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
242262
===================================================================
243263
--- code-server.orig/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
244264
+++ code-server/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
245-
@@ -4,7 +4,24 @@
265+
@@ -4,10 +4,23 @@
246266
*--------------------------------------------------------------------------------------------*/
247267

248268
import { ILanguagePackItem, LanguagePackBaseService } from 'vs/platform/languagePacks/common/languagePacks';
249269
+import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
250-
+import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
251270
+import { ILanguagePackService } from 'vs/platform/languagePacks/common/languagePacks';
252271
+import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
272+
+import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
253273

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;
258277
+
259278
+ constructor(
260279
+ @IRemoteAgentService remoteAgentService: IRemoteAgentService,
280+
+ @IExtensionGalleryService extensionGalleryService: IExtensionGalleryService
261281
+ ) {
262-
+ return ProxyChannel.toService<ILanguagePackService>(remoteAgentService.getConnection()!.getChannel('languagePacks'));
282+
+ super(extensionGalleryService)
283+
+ this.languagePackService = ProxyChannel.toService<ILanguagePackService>(remoteAgentService.getConnection()!.getChannel('languagePacks'));
263284
+ }
264-
+}
265285
+
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
269286
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

Comments
 (0)