mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-19 08:08:39 +01:00
initial cut of vscode.l10n (#158328)
This commit is contained in:
committed by
GitHub
parent
07d06e89e5
commit
ccddb94f98
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user