Skip to content

Add localization to Python Extension - #2742

Closed
Rich Chiodo (rchiodo) wants to merge 11 commits into
microsoft:masterfrom
rchiodo:master
Closed

Rich Chiodo (rchiodo) wants to merge 11 commits into
microsoft:masterfrom
rchiodo:master

Conversation

@rchiodo

@rchiodo Rich Chiodo (rchiodo) commented Oct 1, 2018 •

Copy link
Copy Markdown

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.

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR)
  • Title summarizes what is changing
  • ~Has a news entry file (remember to thank yourself!)
  • Unit tests & system/integration tests are added/updated
  • Any new/changed dependencies in package.json are pinned (e.g. "1.2.3", not "^1.2.3" for the specified version)
  • package-lock.json has been regenerated by running npm install (if dependencies have changed)
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;

@rchiodo Rich Chiodo (rchiodo) Oct 1, 2018 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/client/extension.ts Outdated
await activationService.activate();

// Setup up the localization service
serviceManager.get<ILocalizationService>(ILocalizationService);

@DonJayamanne Don Jayamanne (DonJayamanne) Oct 1, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, thanks


In reply to: 221759734 [](ancestors = 221759734)

Comment thread src/utils/localize.ts
@@ -0,0 +1,85 @@
// Copyright (c) Microsoft Corporation. All rights reserved.

@DonJayamanne Don Jayamanne (DonJayamanne) Oct 1, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread src/utils/localize.ts

constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer)
{
this.workspace = this.serviceContainer.get<IWorkspaceService>(IWorkspaceService);

@DonJayamanne Don Jayamanne (DonJayamanne) Oct 1, 2018 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All of this can be moved into initialize|activate|... method (as described earlier - in extension.ts file). #Pending

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@DonJayamanne

Copy link
Copy Markdown

All good, Brett Cannon (@brettcannon) Rich Chiodo (@rchiodo)
Will not merge this, as we're a day away from release.
Will merge tomorrow after the release.

@rchiodo

Copy link
Copy Markdown
Author

Switching to doing loc ourselves so as not to require mucking with the final js output

@lock lock Bot locked as resolved and limited conversation to collaborators Jul 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

3 participants