Skip to content

Locale Testing

ExTester supports launching the test VS Code instance in a non-English display language. This lets you verify that your extension’s UI strings, commands, and interactions behave correctly when VS Code itself is localized — for example, when running in Russian, Chinese, or French.


VS Code’s display language is controlled by two files that must exist in its user-data directory before launch:

  • User/locale.json — declares which locale to use (e.g. { "locale": "ru", "osLocale": "ru" })
  • languagepacks.json — registry mapping locale codes to installed language pack extensions

When you pass the --locale / -L flag, ExTester writes User/locale.json automatically. languagepacks.json works differently: it is generated by the VS Code CLI when the language pack is installed into the test instance (via -i or an install-from-marketplace step). ExTester preserves that file across its settings-directory reset, but never generates it itself — which is why the language pack must be installed through ExTester rather than with a system code binary. ExTester also passes --locale=<locale> on the VS Code command line, which covers display-language behavior when languagepacks.json is missing.

All you need to do is declare the language pack as an extension dependency so it gets installed into the test instance.


Step 1 — Declare the language pack as a dependency

Section titled “Step 1 — Declare the language pack as a dependency”

Add the language pack extension ID to extensionDependencies in your extension’s package.json:

{
"extensionDependencies": ["ms-ceintl.vscode-language-pack-es"]
}

Language pack extension IDs follow the pattern ms-ceintl.vscode-language-pack-<locale>. Some common ones:

Locale Extension ID
Russian ms-ceintl.vscode-language-pack-ru
Simplified Chinese ms-ceintl.vscode-language-pack-zh-hans
Traditional Chinese ms-ceintl.vscode-language-pack-zh-hant
French ms-ceintl.vscode-language-pack-fr
German ms-ceintl.vscode-language-pack-de
Japanese ms-ceintl.vscode-language-pack-ja
Korean ms-ceintl.vscode-language-pack-ko
Spanish ms-ceintl.vscode-language-pack-es
Portuguese (Brazil) ms-ceintl.vscode-language-pack-pt-br
Italian ms-ceintl.vscode-language-pack-it

Find the full list on the VS Code Marketplace.

Important: extensionDependencies must only contain extensions that are available on the VS Code Marketplace. For offline or private setups see the Programmatic API section below.


Pass both flags together to setup-and-run (or run-tests):

Terminal window
extest setup-and-run './out/test/**/*.test.js' \
-i \
-L ru \
-e ./test-extensions \
-r .
Flag Purpose
-i / --install_dependencies Installs all extensionDependencies (including the language pack) into the test VS Code instance
-L <locale> / --locale <locale> Launches VS Code with the given display language
-e <dir> / --extensions_dir <dir> Directory where extensions are installed (optional)

Note: -L requires the language pack to already be installed into the test instance — otherwise VS Code falls back to English. Passing -i alongside -L is the convenient way to do that via extensionDependencies, but extest install-from-marketplace or the programmatic installFromMarketplace work equally well. Without -L, VS Code starts in English even if the pack is installed.

-e is optional. If you split setup and run into two commands, pass the same -e to both.


{
"scripts": {
"ui-test": "extest setup-and-run './out/test/**/*.test.js' -i -L ru -e ./test-extensions -r .",
"ui-test:en": "extest setup-and-run './out/test/**/*.test.js' -i -e ./test-extensions -r ."
}
}

It is good practice to keep your default ui-test script language-neutral and add a separate locale-specific variant only where needed, rather than hardcoding a locale for all test runs.


Use the locale field in RunOptions:

import { ExTester } from "vscode-extension-tester";
const exTester = new ExTester();
await exTester.setupAndRunTests(
"./out/test/**/*.test.js",
"latest",
{
installDependencies: true, // installs extensionDependencies, including the language pack
},
{
resources: ["."],
locale: "ru", // launches VS Code in Russian
},
);

Or install the language pack explicitly without using extensionDependencies:

await exTester.installFromMarketplace("ms-ceintl.vscode-language-pack-es");
await exTester.runTests("./out/test/**/*.test.js", {
resources: ["."],
locale: "ru",
});

No extra install step is needed in CI. The -i flag handles installation through the test VS Code binary, which is the correct isolated instance:

- name: 🔍 Run localized tests
run: extest setup-and-run './out/test/**/*.test.js' -i -L ru -e ./test-extensions -r .

Do not use code --install-extension in CI to install language packs — that installs into whatever system VS Code binary is on the PATH, not the isolated test instance that ExTester downloads and manages.


VS Code still launches in English after setting -L ru

  1. Make sure the language pack is installed into the test instance — via -i, extest install-from-marketplace, or the programmatic installFromMarketplace.
  2. Make sure -e <dir> is consistent between setup and run — both the install command and the launch command must reference the same extensions directory.
  3. Check that the language pack was actually downloaded: look for a ms-ceintl.vscode-language-pack-<locale>-* directory inside your -e folder after setup runs.

Language pack is installed but locale code doesn’t match

The locale code passed to -L must match the locale string the language pack declares. Russian is ru, Simplified Chinese is zh-cn (not zh-hans). Check the extension’s package.jsoncontributes.localizations[0].languageId for the exact string.