From e6ea8d6fb88f6e910b1c24da61a4033c7630f4e6 Mon Sep 17 00:00:00 2001 From: hyrious Date: Wed, 21 May 2025 16:05:40 +0800 Subject: [PATCH] fix: missing translations of remote built-in extensions --- build/gulpfile.reh.js | 1 + src/vs/base/node/nls.ts | 10 +++++----- .../extensionManagement/common/extensionManagement.ts | 2 +- .../common/extensionManagementIpc.ts | 5 +++-- .../node/extensionManagementService.ts | 8 ++++---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/build/gulpfile.reh.js b/build/gulpfile.reh.js index c1d64c003384b..aaad56f936a4d 100644 --- a/build/gulpfile.reh.js +++ b/build/gulpfile.reh.js @@ -58,6 +58,7 @@ const serverResourceIncludes = [ // NLS 'out-build/nls.messages.json', + 'out-build/nls.keys.json', // Process monitor 'out-build/vs/base/node/cpuUsage.sh', diff --git a/src/vs/base/node/nls.ts b/src/vs/base/node/nls.ts index de830d9857812..67d97f5ea5215 100644 --- a/src/vs/base/node/nls.ts +++ b/src/vs/base/node/nls.ts @@ -108,27 +108,27 @@ export async function resolveNLSConfiguration({ userLocale, osLocale, userDataPa _corruptedFile: languagePackCorruptMarkerFile }; - if (await Promises.exists(commitLanguagePackCachePath)) { + if (await Promises.exists(languagePackMessagesFile)) { touch(commitLanguagePackCachePath).catch(() => { }); // We don't wait for this. No big harm if we can't touch mark('code/didGenerateNls'); return result; } const [ - , nlsDefaultKeys, nlsDefaultMessages, nlsPackdata ]: - [unknown, Array<[string, string[]]>, string[], { contents: Record> }] - // ^moduleId ^nlsKeys ^moduleId ^nlsKey ^nlsValue + [Array<[string, string[]]>, string[], { contents: Record> }] + // ^moduleId ^nlsKeys ^moduleId ^nlsKey ^nlsValue = await Promise.all([ - promises.mkdir(commitLanguagePackCachePath, { recursive: true }), promises.readFile(join(nlsMetadataPath, 'nls.keys.json'), 'utf-8').then(content => JSON.parse(content)), promises.readFile(join(nlsMetadataPath, 'nls.messages.json'), 'utf-8').then(content => JSON.parse(content)), promises.readFile(mainLanguagePackPath, 'utf-8').then(content => JSON.parse(content)), ]); + await promises.mkdir(commitLanguagePackCachePath, { recursive: true }); + const nlsResult: string[] = []; // We expect NLS messages to be in a flat array in sorted order as they diff --git a/src/vs/platform/extensionManagement/common/extensionManagement.ts b/src/vs/platform/extensionManagement/common/extensionManagement.ts index e91310f1cc775..8639d334079b0 100644 --- a/src/vs/platform/extensionManagement/common/extensionManagement.ts +++ b/src/vs/platform/extensionManagement/common/extensionManagement.ts @@ -615,7 +615,7 @@ export interface IExtensionManagementService { uninstall(extension: ILocalExtension, options?: UninstallOptions): Promise; uninstallExtensions(extensions: UninstallExtensionInfo[]): Promise; toggleApplicationScope(extension: ILocalExtension, fromProfileLocation: URI): Promise; - getInstalled(type?: ExtensionType, profileLocation?: URI, productVersion?: IProductVersion): Promise; + getInstalled(type?: ExtensionType, profileLocation?: URI, productVersion?: IProductVersion, language?: string): Promise; getExtensionsControlManifest(): Promise; copyExtensions(fromProfileLocation: URI, toProfileLocation: URI): Promise; updateMetadata(local: ILocalExtension, metadata: Partial, profileLocation: URI): Promise; diff --git a/src/vs/platform/extensionManagement/common/extensionManagementIpc.ts b/src/vs/platform/extensionManagement/common/extensionManagementIpc.ts index 4e30ac2c3a3cd..38178cd1fe34a 100644 --- a/src/vs/platform/extensionManagement/common/extensionManagementIpc.ts +++ b/src/vs/platform/extensionManagement/common/extensionManagementIpc.ts @@ -17,6 +17,7 @@ import { import { ExtensionType, IExtensionManifest, TargetPlatform } from '../../extensions/common/extensions.js'; import { IProductService } from '../../product/common/productService.js'; import { CommontExtensionManagementService } from './abstractExtensionManagementService.js'; +import { language } from '../../../base/common/platform.js'; function transformIncomingURI(uri: UriComponents, transformer: IURITransformer | null): URI; function transformIncomingURI(uri: UriComponents | undefined, transformer: IURITransformer | null): URI | undefined; @@ -145,7 +146,7 @@ export class ExtensionManagementChannel implements IServerChannel { return this.service.uninstallExtensions(arg.map(({ extension, options }) => ({ extension: transformIncomingExtension(extension, uriTransformer), options: transformIncomingOptions(options, uriTransformer) }))); } case 'getInstalled': { - const extensions = await this.service.getInstalled(args[0], transformIncomingURI(args[1], uriTransformer), args[2]); + const extensions = await this.service.getInstalled(args[0], transformIncomingURI(args[1], uriTransformer), args[2], args[3]); return extensions.map(e => transformOutgoingExtension(e, uriTransformer)); } case 'toggleApplicationScope': { @@ -297,7 +298,7 @@ export class ExtensionManagementChannelClient extends CommontExtensionManagement } getInstalled(type: ExtensionType | null = null, extensionsProfileResource?: URI, productVersion?: IProductVersion): Promise { - return Promise.resolve(this.channel.call('getInstalled', [type, extensionsProfileResource, productVersion])) + return Promise.resolve(this.channel.call('getInstalled', [type, extensionsProfileResource, productVersion, language])) .then(extensions => extensions.map(extension => transformIncomingExtension(extension, null))); } diff --git a/src/vs/platform/extensionManagement/node/extensionManagementService.ts b/src/vs/platform/extensionManagement/node/extensionManagementService.ts index 0a50a2edaf412..776daf1819326 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementService.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementService.ts @@ -130,8 +130,8 @@ export class ExtensionManagementService extends AbstractExtensionManagementServi } } - getInstalled(type?: ExtensionType, profileLocation: URI = this.userDataProfilesService.defaultProfile.extensionsResource, productVersion: IProductVersion = { version: this.productService.version, date: this.productService.date }): Promise { - return this.extensionsScanner.scanExtensions(type ?? null, profileLocation, productVersion); + getInstalled(type?: ExtensionType, profileLocation: URI = this.userDataProfilesService.defaultProfile.extensionsResource, productVersion: IProductVersion = { version: this.productService.version, date: this.productService.date }, language?: string): Promise { + return this.extensionsScanner.scanExtensions(type ?? null, profileLocation, productVersion, language); } scanAllUserInstalledExtensions(): Promise { @@ -554,14 +554,14 @@ export class ExtensionsScanner extends Disposable { await this.initializeExtensionSize(); } - async scanExtensions(type: ExtensionType | null, profileLocation: URI, productVersion: IProductVersion): Promise { + async scanExtensions(type: ExtensionType | null, profileLocation: URI, productVersion: IProductVersion, language?: string): Promise { try { const userScanOptions: UserExtensionsScanOptions = { includeInvalid: true, profileLocation, productVersion }; let scannedExtensions: IScannedExtension[] = []; if (type === null || type === ExtensionType.System) { let scanAllExtensionsPromise = this.scanAllExtensionPromise.get(profileLocation); if (!scanAllExtensionsPromise) { - scanAllExtensionsPromise = this.extensionsScannerService.scanAllExtensions({}, userScanOptions) + scanAllExtensionsPromise = this.extensionsScannerService.scanAllExtensions({ language }, userScanOptions) .finally(() => this.scanAllExtensionPromise.delete(profileLocation)); this.scanAllExtensionPromise.set(profileLocation, scanAllExtensionsPromise); }