Namespace for localization-related functionality in the extension API. To use this properly, you must have l10n defined in your extension manifest and have bundle.l10n..json files. For more information on how to generate bundle.l10n..json files, check out the vscode-l10n repo.

Note: Built-in extensions (for example, Git, TypeScript Language Features, GitHub Authentication) are excluded from the l10n property requirement. In other words, they do not need to specify a l10n in the extension manifest because their translated strings come from Language Packs.

Variables

finalbundle:Null<DynamicAccess<String>>

The bundle of localized strings that have been loaded for the extension. It's undefined if no bundle has been loaded. The bundle is typically not loaded if there was no bundle found or when we are running with the default language.

finaluri:Null<Uri>

The URI of the localization bundle that has been loaded for the extension. It's undefined if no bundle has been loaded. The bundle is typically not loaded if there was no bundle found or when we are running with the default language.

Methods

t(message:String, args:Rest<Array<EitherType<String, EitherType<Float, EitherType<Int, Bool>>>>>):String

t(options:{message:String, comment:EitherType<String, Array<String>>, args:Null<EitherType<Array<EitherType<String, EitherType<Float, EitherType<Int, Bool>>>>, Record<String, Any>>>}):String

t(message:String, args:Record<String, Any>):String

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).

@link args} array. @example l10n.t('Hello {0}!', 'World');

Parameters:

message
  • The message to localize. Supports index templating where strings like {0} and {1} are replaced by the item at that index in the {
args
  • The arguments to be used in the localized string. The index of the argument is used to match the template placeholder in the localized string.

Returns:

localized string with injected arguments.