Add sample on how to localize in VS Code#21
Add sample on how to localize in VS Code#21dbaeumer merged 3 commits intomicrosoft:masterfrom vazexqi:master
Conversation
| package.nls.json and the vscode-nls library for localization. For this sample, | ||
| it shows two commands: Hello and Bye in English and Japanese. | ||
|
|
||
| **Assumptions** |
There was a problem hiding this comment.
Are these assumptions valid?
i18n-sample/README.md
Outdated
| Then, create the corresponding package.nls.{your_language}.json files for each language to localize. | ||
|
|
||
| 2. It is also possible to use your own library for localizing text in your | ||
| source file. You would use the value of `process.env.VSCODE_NLS_CONFIG` |
There was a problem hiding this comment.
Is this environment variable part of the API?
i18n-sample/gulpfile.js
Outdated
| const output = input | ||
| .pipe(tsFilter) | ||
| .pipe(compilation()) | ||
| .pipe(build ? nlsDev.rewriteLocalizeCalls() : es.through()) |
There was a problem hiding this comment.
Is usingvscode-nls-dev always going to require the use of gulp in the build pipeline?
|
@vazexqi none of the files do have a copyright statement. Do you want to add some or can I add the standard MS one. |
|
@vazexqi I worked on the PR and made a couple of changes, mainly around structure and things that have changed in our thinking around nls in the meantime. The demo.gif got outdated through that. Could you please generate a new one. The change I made are available here: https://github.com/Microsoft/vscode-extension-samples/tree/vazexqi-master |
|
@dbaeumer - Thanks for the review and changes.
I should be able to do this over the weekend and have an updated PR in by Monday. |
|
@dbaeumer I've rebased master of https://github.com/vazexqi/vscode-extension-samples onto the latest master of https://github.com/Microsoft/vscode-extension-samples and cherry-picked your changes over since I don't have access to push to vazexqi-master on this repo. I've also regenerated the gif so that it shows using I noticed that you removed two files (i18n-sample/i18n/jpn/out/command/sayBye.i18n.json and i18n-sample/i18n/jpn/out/extension.i18n.json). This might have been because your .gitignore is too strict. If you don't have those files, then when you run I've added them back in. |
|
So, that was my mistake. I will tweak the git ignore and add the files back. |
|
Thanks again. Merge into master |
What does this PR do?
As far as I can tell, there is not much documentation on how extension authors can localize their VS Code extensions. VS Code itself (and extensions that are bundled with it, are properly localized) but there are not many examples of how to do it (short of reading the source code). There have been several questions on this:
package.jsonvscode-nls#11This is a small extension that shows several things:
vscode-nlsandvscode-nls-devpackages.What is not in the scope of this PR?
This PR does not talk about Transifex and different file formats for localization. The
vscode-nls-devmodule supports it but I intentionally left it out since the implementation seems very specific to the way Microsoft is doing it. This PR makes it simple by assuming that you have the required structure in the i18n folder (you either did it by hand or imported it using some other means)It also tries to demystify a lot of the magic that
vscode-nlsis doing by suggesting manual but simpler ways for accomplishing the same thing.Disclosure
Another reason I am doing this is also to learn how localization works in VS Code and also validate some of my assumptions on what is save to use (API stable). We are creating several extensions and localization is something that we have been asked to look into. Even if this PR is not accepted, comments on the assumptions in my code is appreciated so that we can understand what we should or should not rely on.