initial cut of vscode.l10n (#158328)

This commit is contained in:
Tyler James Leonhardt
2022-09-14 16:48:25 -07:00
committed by GitHub
parent 07d06e89e5
commit ccddb94f98
16 changed files with 227 additions and 50 deletions

View File

@@ -93,6 +93,7 @@ import { combinedDisposable } from 'vs/base/common/lifecycle';
import { checkProposedApiEnabled, ExtensionIdentifierSet, isProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
import { DebugConfigurationProviderTriggerKind } from 'vs/workbench/contrib/debug/common/debug';
import { IExtHostTelemetryLogService } from 'vs/workbench/api/common/extHostTelemetryLogService';
import { IExtHostLocalizationService } from 'vs/workbench/api/common/extHostLocalizationService';
export interface IExtensionRegistries {
mine: ExtensionDescriptionRegistry;
@@ -151,6 +152,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
const extHostSearch = rpcProtocol.set(ExtHostContext.ExtHostSearch, accessor.get(IExtHostSearch));
const extHostTask = rpcProtocol.set(ExtHostContext.ExtHostTask, accessor.get(IExtHostTask));
const extHostOutputService = rpcProtocol.set(ExtHostContext.ExtHostOutputService, accessor.get(IExtHostOutputService));
const extHostLocalization = rpcProtocol.set(ExtHostContext.ExtHostLocalization, accessor.get(IExtHostLocalizationService));
// manually create and register addressable instances
const extHostUrls = rpcProtocol.set(ExtHostContext.ExtHostUrls, new ExtHostUrls(rpcProtocol));
@@ -1167,6 +1169,28 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
}
};
// namespace: l10n
const l10n: typeof vscode.l10n = {
t(...params: [message: string, ...args: string[]] | [{ message: string; args: string[]; comment: string[] }]): string {
checkProposedApiEnabled(extension, 'localization');
if (typeof params[0] === 'string') {
const key = params.shift() as string;
return extHostLocalization.getMessage(extension.identifier.value, { message: key, args: params as string[] });
}
return extHostLocalization.getMessage(extension.identifier.value, params[0]);
},
get bundle() {
checkProposedApiEnabled(extension, 'localization');
return extHostLocalization.getBundle(extension.identifier.value);
},
get uri() {
checkProposedApiEnabled(extension, 'localization');
return extHostLocalization.getBundleUri(extension.identifier.value);
}
};
return <typeof vscode>{
version: initData.version,
// namespaces
@@ -1176,6 +1200,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
debug,
env,
extensions,
l10n,
languages,
notebooks,
scm,