2022-03-23 04:07:14 +08:00
|
|
|
Add display language support
|
|
|
|
|
2022-06-22 05:51:46 +08:00
|
|
|
We can remove this once upstream supports all language packs.
|
|
|
|
|
|
|
|
1. Proxies language packs to the service on the backend.
|
|
|
|
2. NLS configuration is embedded into the HTML for the browser to pick up. This
|
|
|
|
code to generate this configuration is copied from the native portion.
|
2022-08-17 09:26:19 +08:00
|
|
|
3. Remove configuredLocale since we have our own thing.
|
2022-06-22 05:51:46 +08:00
|
|
|
4. Move the argv.json file to the server instead of in-browser storage. This is
|
|
|
|
where the current locale is stored and currently the server needs to be able
|
|
|
|
to read it.
|
|
|
|
5. Add the locale flag.
|
2022-08-17 09:26:19 +08:00
|
|
|
6. Remove the redundant locale verification. It does the same as the existing
|
|
|
|
one but is worse because it does not handle non-existent or empty files.
|
|
|
|
7. Replace some caching and Node requires because code-server does not restart
|
|
|
|
when changing the language unlike native Code.
|
2023-03-15 04:03:53 +08:00
|
|
|
8. Make language extensions installable like normal rather than using the
|
|
|
|
special set/clear language actions.
|
2022-03-23 04:07:14 +08:00
|
|
|
|
|
|
|
Index: code-server/lib/vscode/src/vs/server/node/serverServices.ts
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/serverServices.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/server/node/serverServices.ts
|
2023-10-19 08:50:21 +08:00
|
|
|
@@ -11,7 +11,7 @@ import * as path from 'vs/base/common/pa
|
|
|
|
import { IURITransformer } from 'vs/base/common/uriIpc';
|
2023-11-15 06:44:21 +08:00
|
|
|
import { getMachineId, getSqmMachineId } from 'vs/base/node/id';
|
2023-10-19 08:50:21 +08:00
|
|
|
import { Promises } from 'vs/base/node/pfs';
|
|
|
|
-import { ClientConnectionEvent, IMessagePassingProtocol, IPCServer, StaticRouter } from 'vs/base/parts/ipc/common/ipc';
|
|
|
|
+import { ClientConnectionEvent, IMessagePassingProtocol, IPCServer, ProxyChannel, StaticRouter } from 'vs/base/parts/ipc/common/ipc';
|
|
|
|
import { ProtocolConstants } from 'vs/base/parts/ipc/common/ipc.net';
|
|
|
|
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
|
|
|
import { ConfigurationService } from 'vs/platform/configuration/common/configurationService';
|
2023-11-15 06:44:21 +08:00
|
|
|
@@ -228,6 +228,9 @@ export async function setupServerService
|
2022-03-23 04:07:14 +08:00
|
|
|
const channel = new ExtensionManagementChannel(extensionManagementService, (ctx: RemoteAgentConnectionContext) => getUriTransformer(ctx.remoteAuthority));
|
|
|
|
socketServer.registerChannel('extensions', channel);
|
|
|
|
|
2023-10-19 08:50:21 +08:00
|
|
|
+ const languagePackChannel = ProxyChannel.fromService<RemoteAgentConnectionContext>(accessor.get(ILanguagePackService), disposables);
|
2022-06-22 05:51:46 +08:00
|
|
|
+ socketServer.registerChannel('languagePacks', languagePackChannel);
|
2022-03-23 04:07:14 +08:00
|
|
|
+
|
2023-10-19 08:50:21 +08:00
|
|
|
// clean up extensions folder
|
|
|
|
remoteExtensionsScanner.whenExtensionsReady().then(() => extensionManagementService.cleanUp());
|
2022-03-23 04:07:14 +08:00
|
|
|
|
|
|
|
Index: code-server/lib/vscode/src/vs/base/common/platform.ts
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/base/common/platform.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/base/common/platform.ts
|
2022-08-17 09:26:19 +08:00
|
|
|
@@ -2,8 +2,6 @@
|
|
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
-import * as nls from 'vs/nls';
|
|
|
|
-
|
2022-10-18 07:30:39 +08:00
|
|
|
export const LANGUAGE_DEFAULT = 'en';
|
2022-08-17 09:26:19 +08:00
|
|
|
|
|
|
|
let _isWindows = false;
|
2024-02-02 09:36:47 +08:00
|
|
|
@@ -111,17 +109,21 @@ else if (typeof navigator === 'object' &
|
2022-10-18 07:30:39 +08:00
|
|
|
_isMobile = _userAgent?.indexOf('Mobi') >= 0;
|
2022-03-23 04:07:14 +08:00
|
|
|
_isWeb = true;
|
2022-08-17 09:26:19 +08:00
|
|
|
|
|
|
|
- const configuredLocale = nls.getConfiguredDefaultLocale(
|
|
|
|
- // This call _must_ be done in the file that calls `nls.getConfiguredDefaultLocale`
|
|
|
|
- // to ensure that the NLS AMD Loader plugin has been loaded and configured.
|
|
|
|
- // This is because the loader plugin decides what the default locale is based on
|
|
|
|
- // how it's able to resolve the strings.
|
|
|
|
- nls.localize({ key: 'ensureLoaderPluginIsLoaded', comment: ['{Locked}'] }, '_')
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- _locale = configuredLocale || LANGUAGE_DEFAULT;
|
2022-06-22 05:51:46 +08:00
|
|
|
+ _locale = LANGUAGE_DEFAULT;
|
2022-03-23 04:07:14 +08:00
|
|
|
_language = _locale;
|
2023-04-11 02:28:13 +08:00
|
|
|
_platformLocale = navigator.language;
|
2022-03-23 04:07:14 +08:00
|
|
|
+ const el = typeof document !== 'undefined' && document.getElementById('vscode-remote-nls-configuration');
|
|
|
|
+ const rawNlsConfig = el && el.getAttribute('data-settings');
|
|
|
|
+ if (rawNlsConfig) {
|
|
|
|
+ try {
|
|
|
|
+ const nlsConfig: NLSConfig = JSON.parse(rawNlsConfig);
|
2023-04-11 02:28:13 +08:00
|
|
|
+ const resolved = nlsConfig.availableLanguages['*'];
|
2022-03-23 04:07:14 +08:00
|
|
|
+ _locale = nlsConfig.locale;
|
2023-04-11 02:28:13 +08:00
|
|
|
+ _platformLocale = nlsConfig.osLocale;
|
|
|
|
+ _language = resolved ? resolved : LANGUAGE_DEFAULT;
|
2022-03-23 04:07:14 +08:00
|
|
|
+ _translationsConfigFile = nlsConfig._translationsConfigFile;
|
|
|
|
+ } catch (error) { /* Oh well. */ }
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
2024-02-02 09:36:47 +08:00
|
|
|
// Unknown environment
|
2022-03-23 04:07:14 +08:00
|
|
|
Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.html
|
|
|
|
+++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
|
|
|
|
@@ -23,6 +23,9 @@
|
|
|
|
<!-- Workbench Auth Session -->
|
|
|
|
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
|
|
|
|
|
|
|
|
+ <!-- NLS Configuration -->
|
|
|
|
+ <meta id="vscode-remote-nls-configuration" data-settings="{{NLS_CONFIGURATION}}">
|
|
|
|
+
|
|
|
|
<!-- Workbench Icon/Manifest/CSS -->
|
|
|
|
<link rel="icon" href="{{BASE}}/_static/src/browser/media/favicon-dark-support.svg" />
|
2022-06-22 05:51:46 +08:00
|
|
|
<link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" type="image/x-icon" />
|
2023-12-16 05:38:01 +08:00
|
|
|
@@ -48,15 +51,27 @@
|
2023-09-21 07:33:28 +08:00
|
|
|
// Normalize locale to lowercase because translationServiceUrl is case-sensitive.
|
|
|
|
// ref: https://github.com/microsoft/vscode/issues/187795
|
2023-12-16 05:38:01 +08:00
|
|
|
const locale = localStorage.getItem('vscode.nls.locale') || navigator.language.toLowerCase();
|
2022-06-22 05:51:46 +08:00
|
|
|
- if (!locale.startsWith('en')) {
|
|
|
|
- nlsConfig['vs/nls'] = {
|
|
|
|
- availableLanguages: {
|
|
|
|
- '*': locale
|
|
|
|
- },
|
2022-08-17 09:26:19 +08:00
|
|
|
- translationServiceUrl: '{{WORKBENCH_NLS_BASE_URL}}'
|
2022-06-22 05:51:46 +08:00
|
|
|
- };
|
|
|
|
- }
|
2023-12-16 05:38:01 +08:00
|
|
|
|
2022-03-23 04:07:14 +08:00
|
|
|
+ try {
|
2022-06-22 05:51:46 +08:00
|
|
|
+ nlsConfig['vs/nls'] = JSON.parse(document.getElementById("vscode-remote-nls-configuration").getAttribute("data-settings"))
|
|
|
|
+ if (nlsConfig['vs/nls']._resolvedLanguagePackCoreLocation) {
|
2022-03-23 04:07:14 +08:00
|
|
|
+ const bundles = Object.create(null)
|
2022-06-22 05:51:46 +08:00
|
|
|
+ nlsConfig['vs/nls'].loadBundle = (bundle, _language, cb) => {
|
2022-03-23 04:07:14 +08:00
|
|
|
+ const result = bundles[bundle]
|
|
|
|
+ if (result) {
|
|
|
|
+ return cb(undefined, result)
|
|
|
|
+ }
|
2022-06-22 05:51:46 +08:00
|
|
|
+ const path = nlsConfig['vs/nls']._resolvedLanguagePackCoreLocation + "/" + bundle.replace(/\//g, "!") + ".nls.json"
|
2022-07-16 02:00:05 +08:00
|
|
|
+ fetch(`{{WORKBENCH_WEB_BASE_URL}}/../vscode-remote-resource?path=${encodeURIComponent(path)}`)
|
2022-03-23 04:07:14 +08:00
|
|
|
+ .then((response) => response.json())
|
|
|
|
+ .then((json) => {
|
|
|
|
+ bundles[bundle] = json
|
|
|
|
+ cb(undefined, json)
|
|
|
|
+ })
|
|
|
|
+ .catch(cb)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } catch (error) { /* Probably fine. */ }
|
2022-06-22 05:51:46 +08:00
|
|
|
require.config({
|
|
|
|
baseUrl: `${baseUrl}/out`,
|
2022-08-17 09:26:19 +08:00
|
|
|
recordStats: true,
|
2022-03-23 04:07:14 +08:00
|
|
|
Index: code-server/lib/vscode/src/vs/platform/environment/common/environmentService.ts
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/platform/environment/common/environmentService.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/platform/environment/common/environmentService.ts
|
2023-04-11 02:28:13 +08:00
|
|
|
@@ -101,7 +101,7 @@ export abstract class AbstractNativeEnvi
|
2022-03-23 04:07:14 +08:00
|
|
|
return URI.file(join(vscodePortable, 'argv.json'));
|
|
|
|
}
|
|
|
|
|
|
|
|
- return joinPath(this.userHome, this.productService.dataFolderName, 'argv.json');
|
|
|
|
+ return joinPath(this.appSettingsHome, 'argv.json');
|
|
|
|
}
|
|
|
|
|
|
|
|
@memoize
|
|
|
|
Index: code-server/lib/vscode/src/vs/server/node/remoteLanguagePacks.ts
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/remoteLanguagePacks.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/server/node/remoteLanguagePacks.ts
|
2023-03-15 04:03:53 +08:00
|
|
|
@@ -32,6 +32,12 @@ export function getNLSConfiguration(lang
|
2022-03-23 04:07:14 +08:00
|
|
|
if (InternalNLSConfiguration.is(value)) {
|
|
|
|
value._languagePackSupport = true;
|
|
|
|
}
|
|
|
|
+ // If the configuration has no results keep trying since code-server
|
|
|
|
+ // doesn't restart when a language is installed so this result would
|
|
|
|
+ // persist (the plugin might not be installed yet for example).
|
|
|
|
+ if (value.locale !== 'en' && value.locale !== 'en-us' && Object.keys(value.availableLanguages).length === 0) {
|
|
|
|
+ _cache.delete(key);
|
|
|
|
+ }
|
|
|
|
return value;
|
|
|
|
});
|
|
|
|
_cache.set(key, result);
|
2023-03-15 04:03:53 +08:00
|
|
|
@@ -46,3 +52,43 @@ export namespace InternalNLSConfiguratio
|
2022-03-23 04:07:14 +08:00
|
|
|
return candidate && typeof candidate._languagePackId === 'string';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * The code below is copied from from src/main.js.
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+export const getLocaleFromConfig = async (argvResource: string): Promise<string> => {
|
|
|
|
+ try {
|
|
|
|
+ const content = stripComments(await fs.promises.readFile(argvResource, 'utf8'));
|
|
|
|
+ return JSON.parse(content).locale;
|
|
|
|
+ } catch (error) {
|
|
|
|
+ if (error.code !== "ENOENT") {
|
|
|
|
+ console.warn(error)
|
|
|
|
+ }
|
|
|
|
+ return 'en';
|
|
|
|
+ }
|
|
|
|
+};
|
|
|
|
+
|
|
|
|
+const stripComments = (content: string): string => {
|
|
|
|
+ const regexp = /('(?:[^\\']*(?:\\.)?)*')|('(?:[^\\']*(?:\\.)?)*')|(\/\*(?:\r?\n|.)*?\*\/)|(\/{2,}.*?(?:(?:\r?\n)|$))/g;
|
|
|
|
+
|
|
|
|
+ return content.replace(regexp, (match, _m1, _m2, m3, m4) => {
|
|
|
|
+ // Only one of m1, m2, m3, m4 matches
|
|
|
|
+ if (m3) {
|
|
|
|
+ // A block comment. Replace with nothing
|
|
|
|
+ return '';
|
|
|
|
+ } else if (m4) {
|
|
|
|
+ // A line comment. If it ends in \r?\n then keep it.
|
|
|
|
+ const length_1 = m4.length;
|
|
|
|
+ if (length_1 > 2 && m4[length_1 - 1] === '\n') {
|
|
|
|
+ return m4[length_1 - 2] === '\r' ? '\r\n' : '\n';
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ // We match a string
|
|
|
|
+ return match;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
|
2023-09-21 07:33:28 +08:00
|
|
|
@@ -27,6 +27,7 @@ import { URI } from 'vs/base/common/uri'
|
2022-03-23 04:07:14 +08:00
|
|
|
import { streamToBuffer } from 'vs/base/common/buffer';
|
|
|
|
import { IProductConfiguration } from 'vs/base/common/product';
|
|
|
|
import { isString } from 'vs/base/common/types';
|
|
|
|
+import { getLocaleFromConfig, getNLSConfiguration } from 'vs/server/node/remoteLanguagePacks';
|
2022-06-22 05:51:46 +08:00
|
|
|
import { CharCode } from 'vs/base/common/charCode';
|
|
|
|
import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts';
|
2023-07-20 06:00:31 +08:00
|
|
|
import { IExtensionManifest } from 'vs/platform/extensions/common/extensions';
|
2023-12-08 05:10:22 +08:00
|
|
|
@@ -345,6 +346,8 @@ export class WebClientServer {
|
2023-05-16 07:44:03 +08:00
|
|
|
callbackRoute: this._callbackRoute
|
|
|
|
};
|
2022-03-23 04:07:14 +08:00
|
|
|
|
|
|
|
+ const locale = this._environmentService.args.locale || await getLocaleFromConfig(this._environmentService.argvResource.fsPath);
|
|
|
|
+ const nlsConfiguration = await getNLSConfiguration(locale, this._environmentService.userDataPath)
|
2023-05-16 07:44:03 +08:00
|
|
|
const nlsBaseUrl = this._productService.extensionsGallery?.nlsBaseUrl;
|
|
|
|
const values: { [key: string]: string } = {
|
|
|
|
WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
|
2023-12-08 05:10:22 +08:00
|
|
|
@@ -353,6 +356,7 @@ export class WebClientServer {
|
2022-08-17 09:26:19 +08:00
|
|
|
WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${!nlsBaseUrl.endsWith('/') ? '/' : ''}${this._productService.commit}/${this._productService.version}/` : ''),
|
2022-06-22 05:51:46 +08:00
|
|
|
BASE: base,
|
|
|
|
VS_BASE: vscodeBase,
|
|
|
|
+ NLS_CONFIGURATION: asJSON(nlsConfiguration),
|
|
|
|
};
|
|
|
|
|
2023-07-20 06:00:31 +08:00
|
|
|
if (useTestResolver) {
|
2022-03-23 04:07:14 +08:00
|
|
|
Index: code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/server/node/serverEnvironmentService.ts
|
2023-12-16 05:38:01 +08:00
|
|
|
@@ -18,6 +18,7 @@ export const serverOptions: OptionDescri
|
2022-03-23 04:07:14 +08:00
|
|
|
'auth': { type: 'string' },
|
2022-06-22 05:51:46 +08:00
|
|
|
'disable-file-downloads': { type: 'boolean' },
|
2023-12-16 05:38:01 +08:00
|
|
|
'disable-file-uploads': { type: 'boolean' },
|
2022-03-23 04:07:14 +08:00
|
|
|
+ 'locale': { type: 'string' },
|
|
|
|
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
|
2024-02-02 09:36:47 +08:00
|
|
|
@@ -102,6 +103,7 @@ export interface ServerParsedArgs {
|
2022-03-23 04:07:14 +08:00
|
|
|
'auth'?: string
|
2022-06-22 05:51:46 +08:00
|
|
|
'disable-file-downloads'?: boolean;
|
2023-12-16 05:38:01 +08:00
|
|
|
'disable-file-uploads'?: boolean;
|
2022-03-23 04:07:14 +08:00
|
|
|
+ 'locale'?: string
|
|
|
|
|
|
|
|
/* ----- server setup ----- */
|
|
|
|
|
2022-06-22 05:51:46 +08:00
|
|
|
Index: code-server/lib/vscode/src/vs/workbench/workbench.web.main.ts
|
2022-03-23 04:07:14 +08:00
|
|
|
===================================================================
|
2022-06-22 05:51:46 +08:00
|
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/workbench.web.main.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/workbench/workbench.web.main.ts
|
2023-10-19 08:50:21 +08:00
|
|
|
@@ -50,7 +50,7 @@ import 'vs/workbench/services/dialogs/br
|
2023-03-15 04:03:53 +08:00
|
|
|
import 'vs/workbench/services/host/browser/browserHostService';
|
|
|
|
import 'vs/workbench/services/lifecycle/browser/lifecycleService';
|
|
|
|
import 'vs/workbench/services/clipboard/browser/clipboardService';
|
|
|
|
-import 'vs/workbench/services/localization/browser/localeService';
|
|
|
|
+import 'vs/workbench/services/localization/electron-sandbox/localeService';
|
|
|
|
import 'vs/workbench/services/path/browser/pathService';
|
|
|
|
import 'vs/workbench/services/themes/browser/browserHostColorSchemeService';
|
|
|
|
import 'vs/workbench/services/encryption/browser/encryptionService';
|
2023-11-15 06:44:21 +08:00
|
|
|
@@ -116,8 +116,9 @@ registerSingleton(ILanguagePackService,
|
2023-05-16 07:44:03 +08:00
|
|
|
// Logs
|
|
|
|
import 'vs/workbench/contrib/logs/browser/logs.contribution';
|
2022-06-22 05:51:46 +08:00
|
|
|
|
2022-08-17 09:26:19 +08:00
|
|
|
-// Localization
|
|
|
|
-import 'vs/workbench/contrib/localization/browser/localization.contribution';
|
|
|
|
+// Localization. This does not actually import anything specific to Electron so
|
|
|
|
+// it should be safe.
|
2022-06-22 05:51:46 +08:00
|
|
|
+import 'vs/workbench/contrib/localization/electron-sandbox/localization.contribution';
|
|
|
|
|
2022-08-17 09:26:19 +08:00
|
|
|
// Performance
|
|
|
|
import 'vs/workbench/contrib/performance/browser/performance.web.contribution';
|
2022-06-22 05:51:46 +08:00
|
|
|
Index: code-server/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
|
|
|
|
===================================================================
|
2022-08-17 09:26:19 +08:00
|
|
|
--- code-server.orig/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
|
2022-06-22 05:51:46 +08:00
|
|
|
+++ code-server/lib/vscode/src/vs/platform/languagePacks/browser/languagePacks.ts
|
2023-03-15 04:03:53 +08:00
|
|
|
@@ -5,18 +5,24 @@
|
|
|
|
|
2022-11-10 06:10:03 +08:00
|
|
|
import { CancellationTokenSource } from 'vs/base/common/cancellation';
|
|
|
|
import { URI } from 'vs/base/common/uri';
|
2022-03-23 04:07:14 +08:00
|
|
|
+import { ProxyChannel } from 'vs/base/parts/ipc/common/ipc';
|
2022-11-10 06:10:03 +08:00
|
|
|
import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
|
|
|
|
import { IExtensionResourceLoaderService } from 'vs/platform/extensionResourceLoader/common/extensionResourceLoader';
|
|
|
|
-import { ILanguagePackItem, LanguagePackBaseService } from 'vs/platform/languagePacks/common/languagePacks';
|
|
|
|
+import { ILanguagePackItem, ILanguagePackService, LanguagePackBaseService } from 'vs/platform/languagePacks/common/languagePacks';
|
|
|
|
import { ILogService } from 'vs/platform/log/common/log';
|
2022-03-23 04:07:14 +08:00
|
|
|
+import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
|
2022-08-17 09:26:19 +08:00
|
|
|
|
|
|
|
export class WebLanguagePacksService extends LanguagePackBaseService {
|
|
|
|
+ private readonly languagePackService: ILanguagePackService;
|
2022-03-23 04:07:14 +08:00
|
|
|
+
|
2022-11-10 06:10:03 +08:00
|
|
|
constructor(
|
2022-03-23 04:07:14 +08:00
|
|
|
+ @IRemoteAgentService remoteAgentService: IRemoteAgentService,
|
2022-11-10 06:10:03 +08:00
|
|
|
@IExtensionResourceLoaderService private readonly extensionResourceLoaderService: IExtensionResourceLoaderService,
|
|
|
|
@IExtensionGalleryService extensionGalleryService: IExtensionGalleryService,
|
|
|
|
@ILogService private readonly logService: ILogService
|
|
|
|
) {
|
|
|
|
super(extensionGalleryService);
|
|
|
|
+ this.languagePackService = ProxyChannel.toService<ILanguagePackService>(remoteAgentService.getConnection()!.getChannel('languagePacks'))
|
|
|
|
}
|
|
|
|
|
2023-03-15 04:03:53 +08:00
|
|
|
async getBuiltInExtensionTranslationsUri(id: string, language: string): Promise<URI | undefined> {
|
|
|
|
@@ -72,6 +78,6 @@ export class WebLanguagePacksService ext
|
2022-11-10 06:10:03 +08:00
|
|
|
|
|
|
|
// Web doesn't have a concept of language packs, so we just return an empty array
|
2022-08-17 09:26:19 +08:00
|
|
|
getInstalledLanguages(): Promise<ILanguagePackItem[]> {
|
|
|
|
- return Promise.resolve([]);
|
|
|
|
+ return this.languagePackService.getInstalledLanguages()
|
|
|
|
}
|
|
|
|
}
|
2023-03-15 04:03:53 +08:00
|
|
|
Index: code-server/lib/vscode/src/vs/workbench/services/localization/electron-sandbox/localeService.ts
|
2022-08-17 09:26:19 +08:00
|
|
|
===================================================================
|
2023-03-15 04:03:53 +08:00
|
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/services/localization/electron-sandbox/localeService.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/workbench/services/localization/electron-sandbox/localeService.ts
|
|
|
|
@@ -51,7 +51,8 @@ class NativeLocaleService implements ILo
|
2022-08-17 09:26:19 +08:00
|
|
|
@IProductService private readonly productService: IProductService
|
|
|
|
) { }
|
|
|
|
|
|
|
|
- private async validateLocaleFile(): Promise<boolean> {
|
|
|
|
+ // Make public just so we do not have to patch all the unused code out.
|
|
|
|
+ public async validateLocaleFile(): Promise<boolean> {
|
|
|
|
try {
|
|
|
|
const content = await this.textFileService.read(this.environmentService.argvResource, { encoding: 'utf8' });
|
|
|
|
|
2023-03-15 04:03:53 +08:00
|
|
|
@@ -78,9 +79,6 @@ class NativeLocaleService implements ILo
|
2022-08-17 09:26:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private async writeLocaleValue(locale: string | undefined): Promise<boolean> {
|
|
|
|
- if (!(await this.validateLocaleFile())) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
await this.jsonEditingService.write(this.environmentService.argvResource, [{ path: ['locale'], value: locale }], true);
|
|
|
|
return true;
|
|
|
|
}
|
2023-03-15 04:03:53 +08:00
|
|
|
Index: code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
|
|
|
|
===================================================================
|
|
|
|
--- code-server.orig/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
|
|
|
|
+++ code-server/lib/vscode/src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
|
2024-02-02 09:36:47 +08:00
|
|
|
@@ -338,9 +338,6 @@ export class InstallAction extends Exten
|
2023-03-15 04:03:53 +08:00
|
|
|
if (this.extension.isBuiltin) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
- if (this.extensionsWorkbenchService.canSetLanguage(this.extension)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
if (this.extension.state === ExtensionState.Uninstalled && await this.extensionsWorkbenchService.canInstall(this.extension)) {
|
2023-04-11 02:28:13 +08:00
|
|
|
this.enabled = this.options.installPreReleaseVersion ? this.extension.hasPreReleaseVersion : this.extension.hasReleaseVersion;
|
2023-03-15 04:03:53 +08:00
|
|
|
this.updateLabel();
|
2024-02-02 09:36:47 +08:00
|
|
|
@@ -608,7 +605,7 @@ export abstract class InstallInOtherServ
|
2023-03-15 04:03:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (isLanguagePackExtension(this.extension.local.manifest)) {
|
|
|
|
- return true;
|
|
|
|
+ return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Prefers to run on UI
|
2024-02-02 09:36:47 +08:00
|
|
|
@@ -1780,17 +1777,6 @@ export class SetLanguageAction extends E
|
2023-03-15 04:03:53 +08:00
|
|
|
update(): void {
|
|
|
|
this.enabled = false;
|
|
|
|
this.class = SetLanguageAction.DisabledClass;
|
|
|
|
- if (!this.extension) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (!this.extensionsWorkbenchService.canSetLanguage(this.extension)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (this.extension.gallery && language === getLocale(this.extension.gallery)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this.enabled = true;
|
|
|
|
- this.class = SetLanguageAction.EnabledClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
override async run(): Promise<any> {
|
2024-02-02 09:36:47 +08:00
|
|
|
@@ -1807,7 +1793,6 @@ export class ClearLanguageAction extends
|
2023-03-15 04:03:53 +08:00
|
|
|
private static readonly DisabledClass = `${ClearLanguageAction.EnabledClass} disabled`;
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
- @IExtensionsWorkbenchService private readonly extensionsWorkbenchService: IExtensionsWorkbenchService,
|
|
|
|
@ILocaleService private readonly localeService: ILocaleService,
|
|
|
|
) {
|
|
|
|
super(ClearLanguageAction.ID, ClearLanguageAction.TITLE.value, ClearLanguageAction.DisabledClass, false);
|
2024-02-02 09:36:47 +08:00
|
|
|
@@ -1817,17 +1802,6 @@ export class ClearLanguageAction extends
|
2023-03-15 04:03:53 +08:00
|
|
|
update(): void {
|
|
|
|
this.enabled = false;
|
|
|
|
this.class = ClearLanguageAction.DisabledClass;
|
|
|
|
- if (!this.extension) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (!this.extensionsWorkbenchService.canSetLanguage(this.extension)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- if (this.extension.gallery && language !== getLocale(this.extension.gallery)) {
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
- this.enabled = true;
|
|
|
|
- this.class = ClearLanguageAction.EnabledClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
override async run(): Promise<any> {
|