We propose adding an overload to localize that allows it to be used with tagged template literals. With tagged literals, developers use a template literal as they "normally would", but prepend it with the method call
localize`Hello ${name}!`
The associated definition for localize() would gain an overload:
export namespace l10n {
/**
* Marks a string for localization. If a localized bundle is available for the language specified by
* {@link env.language} and the bundle has a localized value for this message, then that localized
* value will be returned (with injected {@link args} values for any templated values).
*
* This signature is for use with tagged template literals. The more verbose object-based
* call should be used if comments are required.
*
* @example
* ```
* localize`Hello ${name}!`
* ```
*
* @param message - String message components.
* @param args - Replacement components in the string.
* @returns localized string with injected arguments.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals#tagged_templates
*/
export function t(parts: TemplateStringsArray, ...args: Array<string | number | boolean>): string;
Similar to https://github.com/microsoft/vscode/issues/181555 but for core strings.
We propose adding an overload to
localize
that allows it to be used with tagged template literals. With tagged literals, developers use a template literal as they "normally would", but prepend it with the method callThe associated definition for
localize()
would gain an overload: