fix: missing translations of remote built-in extensions (#249430)

This commit is contained in:
hyrious 2025-06-27 21:23:23 +08:00 committed by GitHub
parent 36f78736b9
commit 7dd2343e5b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 22 additions and 19 deletions

View File

@ -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',

View File

@ -108,22 +108,20 @@ 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<string, Record<string, string>> }]
// ^moduleId ^nlsKeys ^moduleId ^nlsKey ^nlsValue
[Array<[string, string[]]>, string[], { contents: Record<string, Record<string, string>> }]
// ^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)),
@ -145,6 +143,8 @@ export async function resolveNLSConfiguration({ userLocale, osLocale, userDataPa
}
}
await promises.mkdir(commitLanguagePackCachePath, { recursive: true });
await Promise.all([
promises.writeFile(languagePackMessagesFile, JSON.stringify(nlsResult), 'utf-8'),
promises.writeFile(translationsConfigFile, JSON.stringify(languagePack.translations), 'utf-8')

View File

@ -616,7 +616,7 @@ export interface IExtensionManagementService {
uninstall(extension: ILocalExtension, options?: UninstallOptions): Promise<void>;
uninstallExtensions(extensions: UninstallExtensionInfo[]): Promise<void>;
toggleApplicationScope(extension: ILocalExtension, fromProfileLocation: URI): Promise<ILocalExtension>;
getInstalled(type?: ExtensionType, profileLocation?: URI, productVersion?: IProductVersion): Promise<ILocalExtension[]>;
getInstalled(type?: ExtensionType, profileLocation?: URI, productVersion?: IProductVersion, language?: string): Promise<ILocalExtension[]>;
getExtensionsControlManifest(): Promise<IExtensionsControlManifest>;
copyExtensions(fromProfileLocation: URI, toProfileLocation: URI): Promise<void>;
updateMetadata(local: ILocalExtension, metadata: Partial<Metadata>, profileLocation: URI): Promise<ILocalExtension>;

View File

@ -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<ILocalExtension[]> {
return Promise.resolve(this.channel.call<ILocalExtension[]>('getInstalled', [type, extensionsProfileResource, productVersion]))
return Promise.resolve(this.channel.call<ILocalExtension[]>('getInstalled', [type, extensionsProfileResource, productVersion, language]))
.then(extensions => extensions.map(extension => transformIncomingExtension(extension, null)));
}

View File

@ -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<ILocalExtension[]> {
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<ILocalExtension[]> {
return this.extensionsScanner.scanExtensions(type ?? null, profileLocation, productVersion, language);
}
scanAllUserInstalledExtensions(): Promise<ILocalExtension[]> {
@ -563,24 +563,25 @@ export class ExtensionsScanner extends Disposable {
await this.initializeExtensionSize();
}
async scanExtensions(type: ExtensionType | null, profileLocation: URI, productVersion: IProductVersion): Promise<ILocalExtension[]> {
async scanExtensions(type: ExtensionType | null, profileLocation: URI, productVersion: IProductVersion, language?: string): Promise<ILocalExtension[]> {
try {
const userScanOptions: UserExtensionsScanOptions = { includeInvalid: true, profileLocation, productVersion };
const cacheKey: URI = profileLocation.with({ query: language });
const userScanOptions: UserExtensionsScanOptions = { includeInvalid: true, profileLocation, productVersion, language };
let scannedExtensions: IScannedExtension[] = [];
if (type === null || type === ExtensionType.System) {
let scanAllExtensionsPromise = this.scanAllExtensionPromise.get(profileLocation);
let scanAllExtensionsPromise = this.scanAllExtensionPromise.get(cacheKey);
if (!scanAllExtensionsPromise) {
scanAllExtensionsPromise = this.extensionsScannerService.scanAllExtensions({}, userScanOptions)
.finally(() => this.scanAllExtensionPromise.delete(profileLocation));
this.scanAllExtensionPromise.set(profileLocation, scanAllExtensionsPromise);
scanAllExtensionsPromise = this.extensionsScannerService.scanAllExtensions({ language }, userScanOptions)
.finally(() => this.scanAllExtensionPromise.delete(cacheKey));
this.scanAllExtensionPromise.set(cacheKey, scanAllExtensionsPromise);
}
scannedExtensions.push(...await scanAllExtensionsPromise);
} else if (type === ExtensionType.User) {
let scanUserExtensionsPromise = this.scanUserExtensionsPromise.get(profileLocation);
let scanUserExtensionsPromise = this.scanUserExtensionsPromise.get(cacheKey);
if (!scanUserExtensionsPromise) {
scanUserExtensionsPromise = this.extensionsScannerService.scanUserExtensions(userScanOptions)
.finally(() => this.scanUserExtensionsPromise.delete(profileLocation));
this.scanUserExtensionsPromise.set(profileLocation, scanUserExtensionsPromise);
.finally(() => this.scanUserExtensionsPromise.delete(cacheKey));
this.scanUserExtensionsPromise.set(cacheKey, scanUserExtensionsPromise);
}
scannedExtensions.push(...await scanUserExtensionsPromise);
}