Repository navigation
Add localization to Python Extension - #2742
Rich Chiodo (rchiodo) wants to merge 11 commits into
Conversation
| private isInitialized: boolean = false; | ||
| private bannerMessage: string = 'Can you please take 2 minutes to tell us how the Python Language Server is working for you?'; | ||
| private bannerLabels: string[] = ['Yes, take survey now', 'No, thanks']; | ||
| private bannerMessage: string = localize.LanguageServiceSurveyBanner.bannerMessage; |
There was a problem hiding this comment.
LanguageServiceSurveyBanner [](start = 45, length = 27)
I picked this as the first thing to localize because it seemed like an okay spot to mess it up if it didn't work. #ByDesign
| await activationService.activate(); | ||
|
|
||
| // Setup up the localization service | ||
| serviceManager.get<ILocalizationService>(ILocalizationService); |
There was a problem hiding this comment.
You might want to add a method such as initialize, this way its obvious why we're initializing this class.
Also, code analysis tools will also see this as a noop and recommend removing this line.
#Pending
There was a problem hiding this comment.
| @@ -0,0 +1,85 @@ | |||
| // Copyright (c) Microsoft Corporation. All rights reserved. | |||
There was a problem hiding this comment.
Damn, didn't realize we had a utils directory outside of src/client. Ideally everything should be under src/client. Will fix this in a later PR. I know how this got in there, it shouldn't have been moved outside of client. My bad, I reviewed the PR, but didn't realize it was out.
Rich Chiodo (@rchiodo)
Going forward, please remember, all files will need to go under src/client/....
Having it in the root doesn't make sense as there's nothing shared with server, and that was originally required for the extension to work.
If re-structuring, we might as well move all folders from client into src. But later.
#WontFix
|
|
||
| constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) | ||
| { | ||
| this.workspace = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService); |
There was a problem hiding this comment.
All of this can be moved into initialize|activate|... method (as described earlier - in extension.ts file). #Pending
There was a problem hiding this comment.
I left the injectable constructor so that the service container isn't needed to call init, but otherwise should be what you asked for.
In reply to: 221763771 [](ancestors = 221763771)
|
All good, Brett Cannon (@brettcannon) Rich Chiodo (@rchiodo) |
|
Switching to doing loc ourselves so as not to require mucking with the final js output |
Adding the ability to localize strings for the Python Extension
Design is based on the https://github.com/Microsoft/vscode-extension-samples/tree/master/i18n-sample
There's a new global location to put strings to be localized, src/utils/localize.ts.
This file is postprocessed after compiling to wire up translations found in i18n//out/src/utils/localize.i18n.json
New strings are added to both the "load" function in the localize.ts file and into the appropriate i18n json files.
package.jsonare pinned (e.g."1.2.3", not"^1.2.3"for the specified version)package-lock.jsonhas been regenerated by runningnpm install(if dependencies have changed)