-
Notifications
You must be signed in to change notification settings - Fork 338
Localize using vscode-nls #10361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Localize using vscode-nls #10361
Conversation
@@ -77,25 +80,28 @@ export namespace GitHubIssue { | |||
'Please provide a descriptive title summarizing your issue.' | |||
); | |||
export const titlePlaceholder = localize( | |||
'GitHubIssue.titlePlaceholder', | |||
{ key: 'GitHubIssue.titlePlaceholder', comment: ['{Locked="kernel"}'] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we want to keep kernel
as is and not change it from language to language.
'E.g.: Unable to start a local kernel session' | ||
); | ||
export const pleaseFillThisOut = localize( | ||
'GitHubIssue.pleaseFillThisOut', | ||
'Please fill this section out and delete this comment before submitting an issue!' | ||
); | ||
export const missingFields = localize( | ||
'GitHubIssue.missingFields', | ||
{ key: 'GitHubIssue.missingFields', comment: ['{Locked="Issue"}'] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we want to keep the uppercase Issue
as is and not change it from language to language.
} | ||
|
||
export namespace Logging { | ||
export const currentWorkingDirectory = localize('Logging.CurrentWorkingDirectory', 'cwd:'); | ||
export const currentWorkingDirectory = () => 'cwd:'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming cwd:
never changes.
'DataScienceRendererExtension.installingExtension', | ||
{ | ||
key: 'DataScienceRendererExtension.installingExtension', | ||
comment: ['{Locked="Notebook Renderers"}'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we want to keep Notebook Renderers
as is and not change it from language to language.
@@ -162,7 +183,7 @@ export namespace ExtensionSurveyBanner { | |||
export namespace DataScience { | |||
export const installingModule = localize('products.installingModule', 'Installing {0}'); | |||
export const warnWhenSelectingKernelWithUnSupportedPythonVersion = localize( | |||
'DataScience.warnWhenSelectingKernelWithUnSupportedPythonVersion', | |||
{ key: 'DataScience.warnWhenSelectingKernelWithUnSupportedPythonVersion', comment: ['{Locked="kernel"}'] }, | |||
'The version of Python associated with the selected kernel is no longer supported. Please consider selecting a different kernel.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we want to keep kernel
as is and not change it from language to language.
'DataScience.checkingIfImportIsSupported', | ||
'Checking if import is supported' | ||
{ key: 'DataScience.checkingIfImportIsSupported', comment: ['{Locked="import"}'] }, | ||
'Checking if "import" is supported' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we want to keep import
as is and not change it from language to language.
'Validating kernel dependencies' | ||
); | ||
export const performingExport = localize('DataScience.performingExport', 'Performing Export'); | ||
export const convertingToPDF = localize('DataScience.convertingToPDF', 'Converting to PDF'); | ||
export const exportNotebookToPython = localize( | ||
'DataScience.exportNotebookToPython', | ||
{ key: 'DataScience.exportNotebookToPython', comment: ['{Locked="Notebook"}'] }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we want to keep uppercase Notebook
as is and not change it from language to language.
However, I am also assuming that sometimes it's ok to translate notebook
, since it might help with context.
Let me know if I should keep all of the notebook
instances as Locked
.
'Raw kernel process exited before connecting.' | ||
); | ||
export const unknownMimeTypeFormat = localize( | ||
'DataScience.unknownMimeTypeFormat', | ||
{ key: 'DataScience.unknownMimeTypeFormat', comment: ['{Locked="Mime type"}'] }, | ||
'Mime type {0} is not currently supported' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not assume Mime type
needs to be translated.
@@ -362,39 +398,48 @@ export namespace DataScience { | |||
export const jupyterSelfCertClose = localize('DataScience.jupyterSelfCertClose', 'No, close the connection'); | |||
export const pythonInteractiveHelpLink = localize( | |||
'DataScience.pythonInteractiveHelpLink', | |||
'See [https://aka.ms/pyaiinstall] for help on installing jupyter.' | |||
'See <https://aka.ms/pyaiinstall> for help on installing jupyter.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The older one seemed to be prone to bugs, in my opinion.
); | ||
export const markdownHelpInstallingMissingDependencies = localize( | ||
'DataScience.markdownHelpInstallingMissingDependencies', | ||
'See [https://aka.ms/pyaiinstall](https://aka.ms/pyaiinstall) for help on installing Jupyter and related dependencies.' | ||
'See <https://aka.ms/pyaiinstall> for help on installing Jupyter and related dependencies.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems equivalent for me.
@@ -319,7 +355,7 @@ export namespace DataScience { | |||
); | |||
export const jupyterInstall = localize('DataScience.jupyterInstall', 'Install'); | |||
export const currentlySelectedJupyterInterpreterForPlaceholder = localize( | |||
'Datascience.currentlySelectedJupyterInterpreterForPlaceholder', | |||
'DataScience.currentlySelectedJupyterInterpreterForPlaceholder', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took the liberty to do some small improvements. Feedback appreciated!
export const svgFilter = localize('DataScience.svgFilter', 'SVG'); | ||
export const pdfFilter = () => 'PDF'; | ||
export const pngFilter = () => 'PNG'; | ||
export const svgFilter = () => 'SVG'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these should be localized. Am I wrong?
if (typeof key !== 'string') { | ||
key = key.key; | ||
} | ||
return getString(key as string, defaultValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does add a small performance impact, however it should be just constant, since the vscode-nls
localize function is constant, as far as I understand.
{ key: 'DataScience.importDialogTitle', comment: ['{Locked="Notebook"}'] }, | ||
'Import Jupyter Notebook' | ||
); | ||
export const importDialogFilter = () => 'Jupyter Notebooks'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming this would never change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Jupyter
cannot change here, then it should be locked everywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think Jupyter needs to be locked since it's an alteration, not a real word. It's also a subject name. I would assume it will be obvious that it shouldn't be translated.
Codecov Report
@@ Coverage Diff @@
## main #10361 +/- ##
=======================================
- Coverage 69% 69% -1%
=======================================
Files 479 479
Lines 29453 29727 +274
Branches 5037 5040 +3
=======================================
+ Hits 20544 20652 +108
- Misses 7008 7175 +167
+ Partials 1901 1900 -1
|
package.nls.json
Outdated
@@ -62,11 +62,11 @@ | |||
"jupyter.command.jupyter.runLinting.title": "Run Linting", | |||
"jupyter.command.jupyter.runFileInteractive.title": "Run Current File in Interactive Window", | |||
"jupyter.command.jupyter.debugFileInteractive.title": "Debug Current File in Interactive Window", | |||
"jupyter.command.jupyter.runallcells.title": "Run All Cells", | |||
"jupyter.command.jupyter.runAllCells.title": "Run All Cells", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is camel case required? Wondering why these changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll unchanged them, it just seemed like a good improvement to me. But it's not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I found plenty of others that you hadn't changed e.g. the line below the above one wasn't updated. If chaning I'd change it everywhere, or leave as is - or change in a seprate PR with a linter to ensure we are consistent (which I know we aren't)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll make an issue to make these consistent!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue: #10381
* Localization-tolerant gulp clean * a bit more general * much cleaner
@@ -111,3 +112,4 @@ typings/** | |||
types/** | |||
test-results* | |||
*.zip | |||
!**/*nls.*.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the challenges I had was that the *nls.*.json
files were missing in the final .VSIX
. This change, and another change in the gulpfile.js
were the solution.
@@ -1251,7 +1251,7 @@ No properties for event | |||
[src/notebooks/controllers/notebookControllerManager.ts](https://github.com/microsoft/vscode-jupyter/tree/main/src/notebooks/controllers/notebookControllerManager.ts) | |||
```typescript | |||
} | |||
// We know that this fails when we have xeus kernels installed (untill that's resolved thats one instance when we can have duplicates). | |||
// We know that this fails when we have xeus kernels installed (until that's resolved thats one instance when we can have duplicates). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took the liberty to fix some typos.
@@ -22,6 +22,8 @@ resources: | |||
extends: | |||
template: azure-pipelines/extension/pre-release.yml@templates | |||
parameters: | |||
locTsConfigs: $(Build.SourcesDirectory)/tsconfig.json | |||
locBundleDestination: $(Build.SourcesDirectory)/out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a reminder for future reviews of this PR, this should match the output path:
in the webpack config: https://github.com/microsoft/vscode-jupyter/blob/main/build/webpack/webpack.extension.node.config.js#L142
@@ -18,6 +18,8 @@ extends: | |||
template: azure-pipelines/extension/stable.yml@templates | |||
parameters: | |||
publishExtension: true | |||
locTsConfigs: $(Build.SourcesDirectory)/tsconfig.json | |||
locBundleDestination: $(Build.SourcesDirectory)/out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a reminder for future reviews of this PR, this should match the output path:
in the webpack config: https://github.com/microsoft/vscode-jupyter/blob/main/build/webpack/webpack.extension.node.config.js#L142
options: { | ||
base: constants.ExtensionRootDir | ||
} | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll need to add this in the web
webpack once there's web support.
@@ -143,7 +143,7 @@ gulp.task('output:clean', () => del(['coverage'])); | |||
|
|||
gulp.task('clean:cleanExceptTests', () => del(['clean:vsix', 'out', '!out/test'])); | |||
gulp.task('clean:vsix', () => del(['*.vsix'])); | |||
gulp.task('clean:out', () => del(['out/**', '!out', '!out/client_renderer/**'])); | |||
gulp.task('clean:out', () => del(['out/**', '!out', '!out/client_renderer/**', '!**/*nls.*.json'])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One of the challenges I had was that the *nls.*.json
files were missing in the final .VSIX
. This change, and another change in the .vscodeignore
were the solution.
'Common.clickHereForMoreInfoWithHtml', | ||
"Click <a href='{0}'>here</a> for more info." | ||
); | ||
export const bannerLabelYes = () => localize('Common.bannerLabelYes', 'Yes'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed these to be functions to allow keeping the old behavior in the browser. At first, I had this change within a replacement of the localize
function itself, but that broke the matching mechanism used by vscode-nls-dev
. I've got to allow the Node logic to assume localize
is unchanged, and thus to keep the signature in the other files, these properties now are lambdas.
I will fix this once vscode-nls
supports the web.
@@ -1262,6 +1436,8 @@ function getString(key: string, defValue?: string) { | |||
collection = loadedCollection; | |||
} | |||
let result = collection[key]; | |||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | |||
result = (result as any)?.message || result; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since package.nls.json
now can return objects, we should retrieve the message from those objects in such cases.
@rchiodo , @DonJayamanne This PR is ready 😆 fully tested. One last review appreciated 🙏 |
I'm getting some weird errors in the build, like:
Investigating... |
@@ -110,7 +110,7 @@ suite('DataScience - VSCode Notebook - (Conda Execution) (slow)', function () { | |||
); | |||
verifyVariables(envVarsOurselves!, '(ourselves)'); | |||
}); | |||
test('Acitvate conda environment using conda run and activation commands', async () => { | |||
test('Activate conda environment using conda run and activation commands', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this typo fix be affecting a recording or a CI setting of some sort?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't think so. Have you checked some recent runs from main / other PRs to see if that test is failing in them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is a common failure. I'm trying to fix this here:
#10429
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oooh
This PR adds
vscode-nls
as a dependency, following the guidelines to make use of this tool to bring the standard VS Code localization to the vscode-jupyter extension.For more information:
IMPORTANT CONSIDERATIONS:
Given that
vscode-nls
does not yet support theweb
environment, I haven't removed the existing localization approach, I have slightly changed it to supportvscode-nls
's API. Thelocalize
function will be usingvscode-nls
on Node.js, but on the web the custom approach we have been using so far is kept functionally intact.Once
vscode-nls
supports the web, I will be able to remove the non-standard localization tool we currently have. I have made an issue to follow up: #10367If this PR is merged:
Fixes #9676