Skip to content

Commit 8af6f6c

Browse files
committed
update display language
1 parent 54c75c3 commit 8af6f6c

File tree

1 file changed

+71
-42
lines changed

1 file changed

+71
-42
lines changed

patches/display-language.patch

Lines changed: 71 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,20 @@ Index: sagemaker-code-editor/vscode/src/vs/code/browser/workbench/workbench.html
8484
+
8585
<!-- Workbench Auth Session -->
8686
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
87-
88-
@@ -33,8 +36,53 @@
87+
88+
@@ -25,6 +28,6 @@
89+
<!-- Workbench Icon/Manifest/CSS -->
90+
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/favicon.ico" type="image/x-icon" />
91+
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json" crossorigin="use-credentials" />
92+
- <link rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.css">
93+
+ <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.css">
94+
95+
</head>
96+
97+
@@ -32,18 +35,61 @@
98+
<body aria-label="">
99+
</body>
100+
89101
<!-- Startup (do not modify order of script tags!) -->
90102
+ <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
91103
+ <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
@@ -140,6 +152,15 @@ Index: sagemaker-code-editor/vscode/src/vs/code/browser/workbench/workbench.html
140152
<script>
141153
performance.mark('code/willLoadWorkbenchMain');
142154
</script>
155+
- <!-- always ensure built in english NLS messages -->
156+
- <script type="module" src="{{WORKBENCH_NLS_FALLBACK_URL}}"></script>
157+
- <!-- attempt to load NLS messages in case non-english -->
158+
- <script type="module" src="{{WORKBENCH_NLS_URL}}"></script>
159+
- <script type="module" src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.js"></script>
160+
+ <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.nls.js"></script>
161+
+ <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.js"></script>
162+
+ <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.js"></script>
163+
</html>
143164

144165
Index: sagemaker-code-editor/vscode/src/vs/platform/environment/common/environmentService.ts
145166
===================================================================
@@ -197,8 +218,7 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/remoteLanguagePacks.ts
197218
===================================================================
198219
--- sagemaker-code-editor.orig/vscode/src/vs/server/node/remoteLanguagePacks.ts
199220
+++ sagemaker-code-editor/vscode/src/vs/server/node/remoteLanguagePacks.ts
200-
@@ -0,38 +0,80 @@ import { FileAccess } from 'vs/base/comm
201-
/*---------------------------------------------------------------------------------------------
221+
@@ -1,38 +1,80 @@
202222
* Copyright (c) Microsoft Corporation. All rights reserved.
203223
* Licensed under the MIT License. See License.txt in the project root for license information.
204224
*--------------------------------------------------------------------------------------------*/
@@ -209,16 +229,12 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/remoteLanguagePacks.ts
209229
-import { resolveNLSConfiguration } from '../../base/node/nls.js';
210230
-import { Promises } from '../../base/node/pfs.js';
211231
-import product from '../../platform/product/common/product.js';
212-
+import * as path from '../../base/common/path.js';
213-
+import * as lp from '../../base/node/languagePacks.js';
214-
232+
-
215233
-const nlsMetadataPath = join(FileAccess.asFileUri('').fsPath);
216234
-const defaultMessagesFile = join(nlsMetadataPath, 'nls.messages.json');
217235
-const nlsConfigurationCache = new Map<string, Promise<INLSConfiguration>>();
218-
+const metaData = path.join(FileAccess.asFileUri('').fsPath, 'nls.metadata.json');
219-
+const _cache: Map<string, Promise<lp.NLSConfiguration>> = new Map();
220-
221-
-export async function getNLSConfiguration(language: string, userDataPath: string): Promise<lp.NLSConfiguration> {
236+
-
237+
-export async function getNLSConfiguration(language: string, userDataPath: string): Promise<INLSConfiguration> {
222238
- if (!product.commit || !(await Promises.exists(defaultMessagesFile))) {
223239
- return {
224240
- userLocale: 'en',
@@ -237,6 +253,17 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/remoteLanguagePacks.ts
237253
- if (!result) {
238254
- result = resolveNLSConfiguration({ userLocale: language, osLocale: language, commit: product.commit, userDataPath, nlsMetadataPath });
239255
- nlsConfigurationCache.set(cacheKey, result);
256+
- }
257+
-
258+
- return result;
259+
-}
260+
+import * as fs from 'fs';
261+
+import * as path from '../../base/common/path.js';
262+
+import * as lp from '../../base/node/languagePacks.js';
263+
+
264+
+const metaData = path.join(FileAccess.asFileUri('').fsPath, 'nls.metadata.json');
265+
+const _cache: Map<string, Promise<lp.NLSConfiguration>> = new Map();
266+
+
240267
+export function getNLSConfiguration(language: string, userDataPath: string): Promise<lp.NLSConfiguration> {
241268
+ const key = `${language}||${userDataPath}`;
242269
+ let result = _cache.get(key);
@@ -255,10 +282,9 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/remoteLanguagePacks.ts
255282
+ return value;
256283
+ });
257284
+ _cache.set(key, result);
258-
}
259-
-
260-
return result;
261-
}
285+
+ }
286+
+ return result;
287+
+}
262288
+
263289
+export namespace InternalNLSConfiguration {
264290
+ export function is(value: lp.NLSConfiguration): value is lp.InternalNLSConfiguration {
@@ -306,7 +332,6 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/remoteLanguagePacks.ts
306332
+ }
307333
+ });
308334
+};
309-
\ No newline at end of file
310335
Index: sagemaker-code-editor/vscode/src/vs/server/node/serverEnvironmentService.ts
311336
===================================================================
312337
--- sagemaker-code-editor.orig/vscode/src/vs/server/node/serverEnvironmentService.ts
@@ -358,37 +383,32 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
358383
===================================================================
359384
--- sagemaker-code-editor.orig/vscode/src/vs/server/node/webClientServer.ts
360385
+++ sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
361-
@@ -0,8 +0,10 @@
362-
/*---------------------------------------------------------------------------------------------
363-
* Copyright (c) Microsoft Corporation. All rights reserved.
364-
* Licensed under the MIT License. See License.txt in the project root for license information.
365-
*--------------------------------------------------------------------------------------------*/
366-
367-
-import { createReadStream, promises } from 'fs';
368-
+import { createReadStream } from 'fs';
369-
+import { Promises } from '../../base/node/pfs.js';
370-
+import * as path from 'path';
371-
import * as http from 'http';
386+
@@ -8,6 +8,7 @@
372387
import * as url from 'url';
373388
import * as cookie from 'cookie';
374-
@@ -30,9 +32,9 @@ import { URI } from '../../base/common/uri.js'
389+
import * as crypto from 'crypto';
390+
+import * as path from 'path';
391+
import { isEqualOrParent } from '../../base/common/extpath.js';
392+
import { getMediaMime } from '../../base/common/mime.js';
393+
import { isLinux } from '../../base/common/platform.js';
394+
@@ -25,9 +26,9 @@
375395
import { streamToBuffer } from '../../base/common/buffer.js';
376396
import { IProductConfiguration } from '../../base/common/product.js';
377-
import { isString } from '../../base/common/types.js';
397+
import { isString, Mutable } from '../../base/common/types.js';
378398
+import { getLocaleFromConfig, getNLSConfiguration } from '../../server/node/remoteLanguagePacks.js';
379399
import { CharCode } from '../../base/common/charCode.js';
380400
import { IExtensionManifest } from '../../platform/extensions/common/extensions.js';
381401
-import { ICSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js';
382402

383403
const textMimeType: { [ext: string]: string | undefined } = {
384404
'.html': 'text/html',
385-
@@ -393,25 +394,19 @@ export class WebClientServer {
405+
'.js': 'text/javascript',
406+
@@ -393,26 +394,20 @@ export class WebClientServer {
386407
workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
387408
productConfiguration,
388409
- callbackRoute: callbackRoute
389-
+ callbackRoute: this._callbackRoute
390-
};
391-
410+
- };
411+
-
392412
- const cookies = cookie.parse(req.headers.cookie || '');
393413
- const locale = cookies['vscode.nls.locale'] || req.headers['accept-language']?.split(',')[0]?.toLowerCase() || 'en';
394414
- let WORKBENCH_NLS_BASE_URL: string | undefined;
@@ -399,23 +419,32 @@ Index: sagemaker-code-editor/vscode/src/vs/server/node/webClientServer.ts
399419
- } else {
400420
- WORKBENCH_NLS_URL = ''; // fallback will apply
401421
- }
402-
+ const locale = this._environmentService.args.locale || await getLocaleFromConfig(this._environmentService.argvResource.fsPath);
403-
+ const nlsConfiguration = await getNLSConfiguration(locale, this._environmentService.userDataPath)
404-
const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl;
405-
const values: { [key: string]: string } = {
406-
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
407-
WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
422+
-
423+
- const values: { [key: string]: string } = {
424+
- WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
425+
- WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
408426
- WORKBENCH_WEB_BASE_URL: staticRoute,
409427
- WORKBENCH_NLS_URL,
410-
- ORKBENCH_NLS_FALLBACK_URL: `${staticRoute}/out/nls.messages.js`
428+
- WORKBENCH_NLS_FALLBACK_URL: `${staticRoute}/out/nls.messages.js`
429+
- };
430+
+ callbackRoute: this._callbackRoute
431+
+ };
432+
+
433+
+ const locale = this._environmentService.args.locale || await getLocaleFromConfig(this._environmentService.argvResource.fsPath);
434+
+ const nlsConfiguration = await getNLSConfiguration(locale, this._environmentService.userDataPath)
435+
+ const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl;
436+
+ const values: { [key: string]: string } = {
437+
+ WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
438+
+ WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
411439
+ WORKBENCH_WEB_BASE_URL: this._staticRoute,
412440
+ WORKBENCH_NLS_BASE_URL: nlsBaseUrl ? `${nlsBaseUrl}${!nlsBaseUrl.endsWith('/') ? '/' : ''}${this._productService.commit}/${this._productService.version}/` : '',
413441
+ BASE: base,
414442
+ VS_BASE: vscodeBase,
415443
+ NLS_CONFIGURATION: asJSON(nlsConfiguration),
416-
};
444+
+ };
417445

418-
if (useTestResolver) {
446+
// DEV ---------------------------------------------------------------------------------------
447+
// DEV: This is for development and enables loading CSS via import-statements via import-maps.
419448
@@ -401,7 +405,7 @@ export class WebClientServer {
420449
`frame-src 'self' https://*.vscode-cdn.net data:;`,
421450
'worker-src \'self\' data: blob:;',

0 commit comments

Comments
 (0)