Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/api/browser/mainThreadLocalization.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { MainContext, MainThreadLocalizationShape } from '../common/extHost.protocol.js';
7
import { extHostNamedCustomer, IExtHostContext } from '../../services/extensions/common/extHostCustomers.js';
8
import { URI, UriComponents } from '../../../base/common/uri.js';
9
import { IFileService } from '../../../platform/files/common/files.js';
10
import { Disposable } from '../../../base/common/lifecycle.js';
11
import { ILanguagePackService } from '../../../platform/languagePacks/common/languagePacks.js';
12
13
@extHostNamedCustomer(MainContext.MainThreadLocalization)
14
export class MainThreadLocalization extends Disposable implements MainThreadLocalizationShape {
15
16
constructor(
17
extHostContext: IExtHostContext,
18
@IFileService private readonly fileService: IFileService,
19
@ILanguagePackService private readonly languagePackService: ILanguagePackService
20
) {
21
super();
22
}
23
24
async $fetchBuiltInBundleUri(id: string, language: string): Promise<URI | undefined> {
25
try {
26
const uri = await this.languagePackService.getBuiltInExtensionTranslationsUri(id, language);
27
return uri;
28
} catch (e) {
29
return undefined;
30
}
31
}
32
33
async $fetchBundleContents(uriComponents: UriComponents): Promise<string> {
34
const contents = await this.fileService.readFile(URI.revive(uriComponents));
35
return contents.value.toString();
36
}
37
}
38
39