Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Commands and settings in the package.json are localized through files called
package.nls.<locale>.json
at the root of the project. They are picked up automatically by vscode. The default filepackage.nls.json
is loaded when the file for the current locale is missing.The package.json file references to string keys like
%command.action%
, which are replaced with the localized string contained in the package json file corresponding to the current locale, or the default one if missing.The localized commands and settings need to be maintained manually, adding a string key and the actual string in the .json file when adding new commands/settings, and removing them when necessary.
Source code (ts/tsx) strings are localized through the vscode-l10n package, which works via the
vscode.l10n.t()
function.Localized strings are placed under the
l10n
directory at the root of the project (configured in package.json), and the files inside are calledbundle.l10n.<locale>.json
. The default filebundle.l10n.json
is just a placeholder and never actually used.The
vscode.l10n.t()
function requires the default string itself, and not a key representing the string like for commands and settings. When the bundle file for the current locale isn't found, the string passed to t() will be used as the actual displayed string.E.g.,
vscode.l10n.t("hello") -> ...it-it locale, bundle found -> "ciao"
vscode.l10n.t("hello") -> ...fr-fr locale, bundle not found -> "hello"
The localized strings are maintained running the command
npm run npx
, which updates the placeholderbundle.l10n.json
in thel10n
folder with all the strings that are passed to avscode.l10n.t()
function.After adding/removing/modifying localized strings, just run that command to update the bundle file.
The actual translation is a process that needs to be set up and ran externally.
Trick to make the webview working:
The webview environment doesn't have the localization bundle loaded, I guess because they are running separately by the extension host.
As a solution, I've embedded in the html files (
reactView.html
andreactWebview.html
) the localization bundle, injected by their controllers (getHtmlForView.ts
andabtractWebview.ts
) and successively loaded by the root webviewJiraExplorerPanel.tsx
.There are some strings that don't look correctly localized, which means that either that is not the root webview, or there are multiple independent webviews that should hold that logic. In either case, this needs a fix.