mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-19 08:08:39 +01:00
Support format2 (#162785)
This commit is contained in:
committed by
GitHub
parent
3f21113b39
commit
0f8068478e
@@ -1171,12 +1171,16 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
|
||||
// namespace: l10n
|
||||
const l10n: typeof vscode.l10n = {
|
||||
t(...params: [message: string, ...args: any[]] | [{ message: string; args?: any[]; comment: string[] }]): string {
|
||||
t(...params: [message: string, ...args: Array<string | number>] | [message: string, args: Record<string, any>] | [{ message: string; args?: Array<string | number> | Record<string, any>; 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 any[] | undefined });
|
||||
|
||||
// We have either rest args which are Array<string | number> or an array with a single Record<string, any>. This ensures we get a
|
||||
// Record<string | number> which will be formatted correctly.
|
||||
const argsFormatted = !params || typeof params[0] !== 'object' ? params : params[0];
|
||||
return extHostLocalization.getMessage(extension.identifier.value, { message: key, args: argsFormatted as Record<string | number, any> | undefined });
|
||||
}
|
||||
|
||||
return extHostLocalization.getMessage(extension.identifier.value, params[0]);
|
||||
|
||||
Reference in New Issue
Block a user