Path: blob/main/src/vs/workbench/api/browser/mainThreadLocalization.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { MainContext, MainThreadLocalizationShape } from '../common/extHost.protocol.js';6import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';7import { URI, UriComponents } from '../../../base/common/uri.js';8import { IFileService } from '../../../platform/files/common/files.js';9import { Disposable } from '../../../base/common/lifecycle.js';10import { ILanguagePackService } from '../../../platform/languagePacks/common/languagePacks.js';1112@extHostNamedCustomer(MainContext.MainThreadLocalization)13export class MainThreadLocalization extends Disposable implements MainThreadLocalizationShape {1415constructor(16extHostContext: IExtHostContext,17@IFileService private readonly fileService: IFileService,18@ILanguagePackService private readonly languagePackService: ILanguagePackService19) {20super();21}2223async $fetchBuiltInBundleUri(id: string, language: string): Promise<URI | undefined> {24try {25const uri = await this.languagePackService.getBuiltInExtensionTranslationsUri(id, language);26return uri;27} catch (e) {28return undefined;29}30}3132async $fetchBundleContents(uriComponents: UriComponents): Promise<string> {33const contents = await this.fileService.readFile(URI.revive(uriComponents));34return contents.value.toString();35}36}373839