From fbdd7cf25bfe4cc5d7653b7d9857004a8da91e4f Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 4 Oct 2022 21:05:11 -0700 Subject: [PATCH 01/11] use new localization --- .github/workflows/build.yml | 1 - .github/workflows/pr-check.yml | 1 - .gitignore | 4 +- build/azure-pipeline.pre-release.yml | 3 +- build/azure-pipeline.stable.yml | 5 +- build/webpack/common.js | 13 - build/webpack/webpack.extension.config.js | 1 - package-lock.json | 425 ------------- package.json | 3 +- .../checks/macPythonInterpreter.ts | 8 +- .../checks/powerShellActivation.ts | 8 +- .../diagnostics/checks/pythonInterpreter.ts | 13 +- src/client/browser/extension.ts | 1 - src/client/browser/localize.ts | 13 +- src/client/common/experiments/service.ts | 14 +- .../common/installer/moduleInstaller.ts | 7 +- .../common/installer/productInstaller.ts | 30 +- src/client/common/net/fileDownloader.ts | 10 +- src/client/common/utils/localize.ts | 599 +++++++----------- .../debugger/extension/adapter/factory.ts | 6 +- .../extension/attachQuickPick/provider.ts | 7 +- .../configuration/providers/pyramidLaunch.ts | 8 +- .../hooks/childProcessAttachService.ts | 9 +- src/client/extension.ts | 1 - src/client/formatters/blackFormatter.ts | 5 +- .../commands/setInterpreter.ts | 7 +- .../configuration/pythonPathUpdaterService.ts | 7 +- src/client/interpreter/display/index.ts | 10 +- src/client/languageServer/watcher.ts | 7 +- src/client/linters/errorHandlers/standard.ts | 6 +- src/client/linters/linterCommands.ts | 8 +- src/client/tensorBoard/tensorBoardSession.ts | 6 +- .../tensorBoard/tensorBoardSessionProvider.ts | 8 +- src/client/terminals/codeExecution/helper.ts | 11 +- src/client/testing/common/debugLauncher.ts | 11 +- src/setupNls.ts | 8 - types/vscode.proposed.localization.d.ts | 27 + 37 files changed, 315 insertions(+), 996 deletions(-) delete mode 100644 src/setupNls.ts create mode 100644 types/vscode.proposed.localization.d.ts diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b0118c430bcf..f26f13ce50f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,6 @@ env: # Use the mocha-multi-reporters and send output to both console (spec) and JUnit (mocha-junit-reporter). # Also enables a reporter which exits the process running the tests if it haven't already. MOCHA_REPORTER_JUNIT: true - DISABLE_TRANSLATIONS: true jobs: setup: diff --git a/.github/workflows/pr-check.yml b/.github/workflows/pr-check.yml index e654cdc36f97..ab615f33b888 100644 --- a/.github/workflows/pr-check.yml +++ b/.github/workflows/pr-check.yml @@ -14,7 +14,6 @@ env: ARTIFACT_NAME_VSIX: ms-python-insiders-vsix VSIX_NAME: ms-python-insiders.vsix TEST_RESULTS_DIRECTORY: . - DISABLE_TRANSLATIONS: true # Force a path with spaces and to test extension works in these scenarios # Unicode characters are causing 2.7 failures so skip that for now. special-working-directory: './path with spaces' diff --git a/.gitignore b/.gitignore index 296d7b2dbdf8..0fc4c34d7127 100644 --- a/.gitignore +++ b/.gitignore @@ -44,5 +44,5 @@ nodeLanguageServer.*/** dist/** # translation files *.xlf -*.nls.*.json -*.i18n.json +package.nls.*.json +l10n/ diff --git a/build/azure-pipeline.pre-release.yml b/build/azure-pipeline.pre-release.yml index a609b8c58ead..a5b95c91af9a 100644 --- a/build/azure-pipeline.pre-release.yml +++ b/build/azure-pipeline.pre-release.yml @@ -21,8 +21,7 @@ resources: extends: template: azure-pipelines/extension/pre-release.yml@templates parameters: - locTsConfigs: $(Build.SourcesDirectory)/tsconfig.json - locBundleDestination: $(Build.SourcesDirectory)/out/client + l10nSourcePaths: ./src/client buildSteps: - task: NodeTool@0 inputs: diff --git a/build/azure-pipeline.stable.yml b/build/azure-pipeline.stable.yml index df249bb89c10..76e1e0061ebf 100644 --- a/build/azure-pipeline.stable.yml +++ b/build/azure-pipeline.stable.yml @@ -24,10 +24,7 @@ extends: template: azure-pipelines/extension/stable.yml@templates parameters: publishExtension: ${{ parameters.publishExtension }} - - locTsConfigs: $(Build.SourcesDirectory)/tsconfig.json - locBundleDestination: $(Build.SourcesDirectory)/out/client - + l10nSourcePaths: ./src/client buildSteps: - task: NodeTool@0 inputs: diff --git a/build/webpack/common.js b/build/webpack/common.js index 3264b76365d3..5ce66883bb41 100644 --- a/build/webpack/common.js +++ b/build/webpack/common.js @@ -52,16 +52,3 @@ function getListOfExistingModulesInOutDir() { return files.map((filePath) => `./${filePath.slice(0, -3)}`); } exports.getListOfExistingModulesInOutDir = getListOfExistingModulesInOutDir; -function getTranlationsLoader() { - const loaders = []; - if (process.env.DISABLE_TRANSLATIONS !== 'true') { - loaders.push({ - loader: 'vscode-nls-dev/lib/webpack-loader', - options: { - base: constants.ExtensionRootDir, - }, - }); - } - return loaders; -} -exports.getTranlationsLoader = getTranlationsLoader; diff --git a/build/webpack/webpack.extension.config.js b/build/webpack/webpack.extension.config.js index 88587806c4a6..b1b3922126d6 100644 --- a/build/webpack/webpack.extension.config.js +++ b/build/webpack/webpack.extension.config.js @@ -26,7 +26,6 @@ const config = { }, module: { rules: [ - ...common.getTranlationsLoader(), { test: /\.ts$/, use: [ diff --git a/package-lock.json b/package-lock.json index d9fff46fcea6..5af7c48df6f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -42,7 +42,6 @@ "vscode-languageclient": "8.0.2-next.5", "vscode-languageserver": "8.0.2-next.5", "vscode-languageserver-protocol": "3.17.2-next.6", - "vscode-nls": "^5.0.1", "vscode-tas-client": "^0.1.63", "which": "^2.0.2", "winreg": "^1.2.4", @@ -119,7 +118,6 @@ "uuid": "^8.3.2", "vsce": "^2.6.6", "vscode-debugadapter-testsupport": "^1.27.0", - "vscode-nls-dev": "^4.0.0", "webpack": "^5.70.0", "webpack-bundle-analyzer": "^4.5.0", "webpack-cli": "^4.9.2", @@ -5550,21 +5548,6 @@ "node": ">=0.10.0" } }, - "node_modules/event-stream": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.5.tgz", - "integrity": "sha512-vyibDcu5JL20Me1fP734QBH/kenBGLZap2n0+XXM7mvuUPzJ20Ydqj1aKcIeMdri1p+PU+4yAKugjN8KCVst+g==", - "dev": true, - "dependencies": { - "duplexer": "^0.1.1", - "from": "^0.1.7", - "map-stream": "0.0.7", - "pause-stream": "^0.0.11", - "split": "^1.0.1", - "stream-combiner": "^0.2.2", - "through": "^2.3.8" - } - }, "node_modules/events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -6370,12 +6353,6 @@ "node": ">=0.10.0" } }, - "node_modules/from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", - "dev": true - }, "node_modules/from2": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", @@ -7666,15 +7643,6 @@ "node": ">=0.10.0" } }, - "node_modules/is": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/is/-/is-3.3.0.tgz", - "integrity": "sha512-nW24QBoPcFGGHJGUwnfpI7Yc5CdqWNdsyHQszVE/z2pKHXzh7FZ5GWhJqSyaQ9wMkQnsTx+kAI8bHlCX4tKdbg==", - "dev": true, - "engines": { - "node": "*" - } - }, "node_modules/is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", @@ -9211,12 +9179,6 @@ "node": ">=0.10.0" } }, - "node_modules/map-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz", - "integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=", - "dev": true - }, "node_modules/map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", @@ -11185,15 +11147,6 @@ "node": "*" } }, - "node_modules/pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "dev": true, - "dependencies": { - "through": "~2.3" - } - }, "node_modules/pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", @@ -12775,18 +12728,6 @@ "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, - "node_modules/split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "dependencies": { - "through": "2" - }, - "engines": { - "node": "*" - } - }, "node_modules/split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -12877,16 +12818,6 @@ "readable-stream": "^2.0.2" } }, - "node_modules/stream-combiner": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz", - "integrity": "sha1-rsjLrBd7Vrb0+kec7YwZEs7lKFg=", - "dev": true, - "dependencies": { - "duplexer": "~0.1.1", - "through": "~2.3.4" - } - }, "node_modules/stream-exhaust": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", @@ -14710,172 +14641,6 @@ "resolved": "https://registry.npmjs.org/vscode-languageserver-types/-/vscode-languageserver-types-3.17.2-next.2.tgz", "integrity": "sha512-TiAkLABgqkVWdAlC3XlOfdhdjIAdVU4YntPUm9kKGbXr+MGwpVnKz2KZMNBcvG0CFx8Hi8qliL0iq+ndPB720w==" }, - "node_modules/vscode-nls": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.0.1.tgz", - "integrity": "sha512-hHQV6iig+M21lTdItKPkJAaWrxALQb/nqpVffakO4knJOh3DrU2SXOMzUzNgo1eADPzu3qSsJY1weCzvR52q9A==" - }, - "node_modules/vscode-nls-dev": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/vscode-nls-dev/-/vscode-nls-dev-4.0.0.tgz", - "integrity": "sha512-2JcEOy1EQKcF8JhtYfFdwAkzxFKrB2ZbHoQwKkzEFOc/RlLAPqO3laBvO2wK4k6G4XUCno/XLQjuDM33/+baRg==", - "dev": true, - "dependencies": { - "ansi-colors": "^4.1.1", - "clone": "^2.1.2", - "event-stream": "^3.3.4", - "fancy-log": "^1.3.3", - "glob": "^7.2.0", - "iconv-lite": "^0.6.3", - "is": "^3.3.0", - "source-map": "^0.6.1", - "typescript": "^4.5.4", - "vinyl": "^2.2.1", - "xml2js": "^0.4.23", - "yargs": "^17.3.0" - }, - "bin": { - "vscl": "lib/vscl.js" - } - }, - "node_modules/vscode-nls-dev/node_modules/ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true, - "engines": { - "node": ">=6" - } - }, - "node_modules/vscode-nls-dev/node_modules/ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "dependencies": { - "color-convert": "^2.0.1" - }, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/chalk/ansi-styles?sponsor=1" - } - }, - "node_modules/vscode-nls-dev/node_modules/cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "dependencies": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "node_modules/vscode-nls-dev/node_modules/color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "dependencies": { - "color-name": "~1.1.4" - }, - "engines": { - "node": ">=7.0.0" - } - }, - "node_modules/vscode-nls-dev/node_modules/color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "node_modules/vscode-nls-dev/node_modules/get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true, - "engines": { - "node": "6.* || 8.* || >= 10.*" - } - }, - "node_modules/vscode-nls-dev/node_modules/is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/vscode-nls-dev/node_modules/string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "dependencies": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/vscode-nls-dev/node_modules/wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "dependencies": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "engines": { - "node": ">=10" - }, - "funding": { - "url": "https://github.com/chalk/wrap-ansi?sponsor=1" - } - }, - "node_modules/vscode-nls-dev/node_modules/y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true, - "engines": { - "node": ">=10" - } - }, - "node_modules/vscode-nls-dev/node_modules/yargs": { - "version": "17.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz", - "integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==", - "dev": true, - "dependencies": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" - }, - "engines": { - "node": ">=12" - } - }, - "node_modules/vscode-nls-dev/node_modules/yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", - "dev": true, - "engines": { - "node": ">=12" - } - }, "node_modules/vscode-tas-client": { "version": "0.1.63", "resolved": "https://registry.npmjs.org/vscode-tas-client/-/vscode-tas-client-0.1.63.tgz", @@ -20040,21 +19805,6 @@ "integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==", "dev": true }, - "event-stream": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/event-stream/-/event-stream-3.3.5.tgz", - "integrity": "sha512-vyibDcu5JL20Me1fP734QBH/kenBGLZap2n0+XXM7mvuUPzJ20Ydqj1aKcIeMdri1p+PU+4yAKugjN8KCVst+g==", - "dev": true, - "requires": { - "duplexer": "^0.1.1", - "from": "^0.1.7", - "map-stream": "0.0.7", - "pause-stream": "^0.0.11", - "split": "^1.0.1", - "stream-combiner": "^0.2.2", - "through": "^2.3.8" - } - }, "events": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", @@ -20680,12 +20430,6 @@ "map-cache": "^0.2.2" } }, - "from": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/from/-/from-0.1.7.tgz", - "integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=", - "dev": true - }, "from2": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", @@ -21693,12 +21437,6 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=", "dev": true }, - "is": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/is/-/is-3.3.0.tgz", - "integrity": "sha512-nW24QBoPcFGGHJGUwnfpI7Yc5CdqWNdsyHQszVE/z2pKHXzh7FZ5GWhJqSyaQ9wMkQnsTx+kAI8bHlCX4tKdbg==", - "dev": true - }, "is-absolute": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-absolute/-/is-absolute-1.0.0.tgz", @@ -22903,12 +22641,6 @@ "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", "dev": true }, - "map-stream": { - "version": "0.0.7", - "resolved": "https://registry.npmjs.org/map-stream/-/map-stream-0.0.7.tgz", - "integrity": "sha1-ih8HiW2CsQkmvTdEokIACfiJdKg=", - "dev": true - }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", @@ -24453,15 +24185,6 @@ "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", "dev": true }, - "pause-stream": { - "version": "0.0.11", - "resolved": "https://registry.npmjs.org/pause-stream/-/pause-stream-0.0.11.tgz", - "integrity": "sha1-/lo0sMvOErWqaitAPuLnO2AvFEU=", - "dev": true, - "requires": { - "through": "~2.3" - } - }, "pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", @@ -25700,15 +25423,6 @@ "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, - "split": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", - "integrity": "sha512-mTyOoPbrivtXnwnIxZRFYRrPNtEFKlpB2fvjSnCQUiAA6qAZzqwna5envK4uk6OIeP17CsdF3rSBGYVBsU0Tkg==", - "dev": true, - "requires": { - "through": "2" - } - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -25781,16 +25495,6 @@ "readable-stream": "^2.0.2" } }, - "stream-combiner": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/stream-combiner/-/stream-combiner-0.2.2.tgz", - "integrity": "sha1-rsjLrBd7Vrb0+kec7YwZEs7lKFg=", - "dev": true, - "requires": { - "duplexer": "~0.1.1", - "through": "~2.3.4" - } - }, "stream-exhaust": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/stream-exhaust/-/stream-exhaust-1.0.2.tgz", @@ -27237,135 +26941,6 @@ } } }, - "vscode-nls": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.0.1.tgz", - "integrity": "sha512-hHQV6iig+M21lTdItKPkJAaWrxALQb/nqpVffakO4knJOh3DrU2SXOMzUzNgo1eADPzu3qSsJY1weCzvR52q9A==" - }, - "vscode-nls-dev": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/vscode-nls-dev/-/vscode-nls-dev-4.0.0.tgz", - "integrity": "sha512-2JcEOy1EQKcF8JhtYfFdwAkzxFKrB2ZbHoQwKkzEFOc/RlLAPqO3laBvO2wK4k6G4XUCno/XLQjuDM33/+baRg==", - "dev": true, - "requires": { - "ansi-colors": "^4.1.1", - "clone": "^2.1.2", - "event-stream": "^3.3.4", - "fancy-log": "^1.3.3", - "glob": "^7.2.0", - "iconv-lite": "^0.6.3", - "is": "^3.3.0", - "source-map": "^0.6.1", - "typescript": "^4.5.4", - "vinyl": "^2.2.1", - "xml2js": "^0.4.23", - "yargs": "^17.3.0" - }, - "dependencies": { - "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", - "dev": true - }, - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", - "dev": true, - "requires": { - "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", - "wrap-ansi": "^7.0.0" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - }, - "get-caller-file": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", - "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, - "wrap-ansi": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - } - }, - "y18n": { - "version": "5.0.8", - "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", - "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true - }, - "yargs": { - "version": "17.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.4.1.tgz", - "integrity": "sha512-WSZD9jgobAg3ZKuCQZSa3g9QOJeCCqLoLAykiWgmXnDo9EPnn4RPf5qVTtzgOx66o6/oqhcA5tHtJXpG8pMt3g==", - "dev": true, - "requires": { - "cliui": "^7.0.2", - "escalade": "^3.1.1", - "get-caller-file": "^2.0.5", - "require-directory": "^2.1.1", - "string-width": "^4.2.3", - "y18n": "^5.0.5", - "yargs-parser": "^21.0.0" - } - }, - "yargs-parser": { - "version": "21.0.1", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.0.1.tgz", - "integrity": "sha512-9BK1jFpLzJROCI5TzwZL/TU4gqjK5xiHV/RfWLOahrjAko/e4DJkRDZQXfvqAsiZzzYhgAzbgz6lg48jcm4GLg==", - "dev": true - } - } - }, "vscode-tas-client": { "version": "0.1.63", "resolved": "https://registry.npmjs.org/vscode-tas-client/-/vscode-tas-client-0.1.63.tgz", diff --git a/package.json b/package.json index 3fc1adb7fbdf..8deb663d1889 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ ], "main": "./out/client/extension", "browser": "./dist/extension.browser.js", + "l10n": "./l10n", "contributes": { "walkthroughs": [ { @@ -1838,7 +1839,6 @@ "vscode-languageclient": "8.0.2-next.5", "vscode-languageserver": "8.0.2-next.5", "vscode-languageserver-protocol": "3.17.2-next.6", - "vscode-nls": "^5.0.1", "vscode-tas-client": "^0.1.63", "winreg": "^1.2.4", "xml2js": "^0.4.19", @@ -1915,7 +1915,6 @@ "uuid": "^8.3.2", "vsce": "^2.6.6", "vscode-debugadapter-testsupport": "^1.27.0", - "vscode-nls-dev": "^4.0.0", "webpack": "^5.70.0", "webpack-bundle-analyzer": "^4.5.0", "webpack-cli": "^4.9.2", diff --git a/src/client/application/diagnostics/checks/macPythonInterpreter.ts b/src/client/application/diagnostics/checks/macPythonInterpreter.ts index d6ad3b259615..19ccc2f8beb9 100644 --- a/src/client/application/diagnostics/checks/macPythonInterpreter.ts +++ b/src/client/application/diagnostics/checks/macPythonInterpreter.ts @@ -3,9 +3,8 @@ // eslint-disable-next-line max-classes-per-file import { inject, injectable } from 'inversify'; -import { DiagnosticSeverity } from 'vscode'; +import { DiagnosticSeverity, l10n } from 'vscode'; import '../../../common/extensions'; -import * as nls from 'vscode-nls'; import { IPlatformService } from '../../../common/platform/types'; import { IConfigurationService, @@ -23,11 +22,8 @@ import { DiagnosticCommandPromptHandlerServiceId, MessageCommandPrompt } from '. import { DiagnosticScope, IDiagnostic, IDiagnosticCommand, IDiagnosticHandlerService } from '../types'; import { Common } from '../../../common/utils/localize'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - const messages = { - [DiagnosticCodes.MacInterpreterSelected]: localize( - 'DiagnosticCodes.MacInterpreterSelected', + [DiagnosticCodes.MacInterpreterSelected]: l10n.t( 'The selected macOS system install of Python is not recommended, some functionality in the extension will be limited. [Install another version of Python](https://www.python.org/downloads) or select a different interpreter for the best experience. [Learn more](https://aka.ms/AA7jfor).', ), }; diff --git a/src/client/application/diagnostics/checks/powerShellActivation.ts b/src/client/application/diagnostics/checks/powerShellActivation.ts index 4ffdf21a9173..85f68db0d6a4 100644 --- a/src/client/application/diagnostics/checks/powerShellActivation.ts +++ b/src/client/application/diagnostics/checks/powerShellActivation.ts @@ -3,9 +3,8 @@ // eslint-disable-next-line max-classes-per-file import { inject, injectable } from 'inversify'; -import { DiagnosticSeverity } from 'vscode'; +import { DiagnosticSeverity, l10n } from 'vscode'; import '../../../common/extensions'; -import * as nls from 'vscode-nls'; import { useCommandPromptAsDefaultShell } from '../../../common/terminal/commandPrompt'; import { IConfigurationService, ICurrentProcess, IDisposableRegistry, Resource } from '../../../common/types'; import { Common } from '../../../common/utils/localize'; @@ -19,10 +18,7 @@ import { DiagnosticCodes } from '../constants'; import { DiagnosticCommandPromptHandlerServiceId, MessageCommandPrompt } from '../promptHandler'; import { DiagnosticScope, IDiagnostic, IDiagnosticHandlerService } from '../types'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - -const PowershellActivationNotSupportedWithBatchFilesMessage = localize( - 'powershelActivationMsg', +const PowershellActivationNotSupportedWithBatchFilesMessage = l10n.t( 'Activation of the selected Python environment is not supported in PowerShell. Consider changing your shell to Command Prompt.', ); diff --git a/src/client/application/diagnostics/checks/pythonInterpreter.ts b/src/client/application/diagnostics/checks/pythonInterpreter.ts index 87ba83cbbc66..45a758c9f283 100644 --- a/src/client/application/diagnostics/checks/pythonInterpreter.ts +++ b/src/client/application/diagnostics/checks/pythonInterpreter.ts @@ -3,9 +3,8 @@ // eslint-disable-next-line max-classes-per-file import { inject, injectable } from 'inversify'; -import { DiagnosticSeverity } from 'vscode'; +import { DiagnosticSeverity, l10n } from 'vscode'; import '../../../common/extensions'; -import * as nls from 'vscode-nls'; import * as path from 'path'; import { IDisposableRegistry, IInterpreterPathService, Resource } from '../../../common/types'; import { IInterpreterService } from '../../../interpreter/contracts'; @@ -30,15 +29,11 @@ import { IExtensionSingleActivationService } from '../../../activation/types'; import { cache } from '../../../common/utils/decorators'; import { noop } from '../../../common/utils/misc'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - const messages = { - [DiagnosticCodes.NoPythonInterpretersDiagnostic]: localize( - 'DiagnosticCodes.NoPythonInterpretersDiagnostic', + [DiagnosticCodes.NoPythonInterpretersDiagnostic]: l10n.t( 'No Python interpreter is selected. Please select a Python interpreter to enable features such as IntelliSense, linting, and debugging.', ), - [DiagnosticCodes.InvalidPythonInterpreterDiagnostic]: localize( - 'DiagnosticCodes.NoCurrentlySelectedPythonInterpreterDiagnostic', + [DiagnosticCodes.InvalidPythonInterpreterDiagnostic]: l10n.t( 'An Invalid Python interpreter is selected{0}, please try changing it to enable features such as IntelliSense, linting, and debugging.', ), }; @@ -59,7 +54,7 @@ export class InvalidPythonInterpreterDiagnostic extends BaseDiagnostic { // Specify folder name in case of multiroot scenarios const folder = workspaceService.getWorkspaceFolder(resource); if (folder) { - formatArg = ` ${localize('Common.forWorkspace', 'for workspace')} ${path.basename(folder.uri.fsPath)}`; + formatArg = ` ${l10n.t('for workspace')} ${path.basename(folder.uri.fsPath)}`; } } super(code, messages[code].format(formatArg), DiagnosticSeverity.Error, scope, resource, undefined, 'always'); diff --git a/src/client/browser/extension.ts b/src/client/browser/extension.ts index 7727beb43a5e..c9ecf8ac1212 100644 --- a/src/client/browser/extension.ts +++ b/src/client/browser/extension.ts @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -import '../../setupNls'; import * as vscode from 'vscode'; import TelemetryReporter from '@vscode/extension-telemetry'; import { LanguageClientOptions } from 'vscode-languageclient'; diff --git a/src/client/browser/localize.ts b/src/client/browser/localize.ts index 24f2cde53c9a..fd50dbcc7093 100644 --- a/src/client/browser/localize.ts +++ b/src/client/browser/localize.ts @@ -3,21 +3,20 @@ 'use strict'; +import { l10n } from 'vscode'; + /* eslint-disable @typescript-eslint/no-namespace */ // IMPORTANT: Do not import any node fs related modules here, as they do not work in browser. -import * as nls from 'vscode-nls'; - -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); export namespace LanguageService { export const statusItem = { - name: localize('LanguageService.statusItem.name', 'Python IntelliSense Status'), - text: localize('LanguageService.statusItem.text', 'Partial Mode'), - detail: localize('LanguageService.statusItem.detail', 'Limited IntelliSense provided by Pylance'), + name: l10n.t('Python IntelliSense Status'), + text: l10n.t('Partial Mode'), + detail: l10n.t('Limited IntelliSense provided by Pylance'), }; } export namespace Common { - export const learnMore = localize('Common.learnMore', 'Learn more'); + export const learnMore = l10n.t('Learn more'); } diff --git a/src/client/common/experiments/service.ts b/src/client/common/experiments/service.ts index 9f76d8347046..39319ab2a363 100644 --- a/src/client/common/experiments/service.ts +++ b/src/client/common/experiments/service.ts @@ -4,8 +4,8 @@ 'use strict'; import { inject, injectable } from 'inversify'; +import { l10n } from 'vscode'; import { getExperimentationService, IExperimentationService } from 'vscode-tas-client'; -import * as nls from 'vscode-nls'; import { traceLog } from '../../logging'; import { sendTelemetryEvent } from '../../telemetry'; import { EventName } from '../../telemetry/constants'; @@ -14,8 +14,6 @@ import { PVSC_EXTENSION_ID } from '../constants'; import { IExperimentService, IPersistentStateFactory } from '../types'; import { ExperimentationTelemetry } from './telemetry'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - const EXP_MEMENTO_KEY = 'VSCode.ABExp.FeatureData'; const EXP_CONFIG_ID = 'vscode'; @@ -174,7 +172,7 @@ export class ExperimentService implements IExperimentService { if (this._optOutFrom.includes('All')) { // We prioritize opt out first - traceLog(localize('Experiments.optedOutOf', "Experiment '{0}' is inactive", 'All')); + traceLog(l10n.t("Experiment '{0}' is inactive", 'All')); // Since we are in the Opt Out all case, this means when checking for experiment we // short circuit and return. So, printing out additional experiment info might cause @@ -183,7 +181,7 @@ export class ExperimentService implements IExperimentService { } if (this._optInto.includes('All')) { // Only if 'All' is not in optOut then check if it is in Opt In. - traceLog(localize('Experiments.inGroup', "Experiment '{0}' is active", 'All')); + traceLog(l10n.t("Experiment '{0}' is active", 'All')); // Similar to the opt out case. If user is opting into to all experiments we short // circuit the experiment checks. So, skip printing any additional details to the logs. @@ -194,14 +192,14 @@ export class ExperimentService implements IExperimentService { this._optOutFrom .filter((exp) => exp !== 'All' && exp.toLowerCase().startsWith('python')) .forEach((exp) => { - traceLog(localize('Experiments.manuallyOptedOutOf', "Experiment '{0}' is inactive", exp)); + traceLog(l10n.t("Experiment '{0}' is inactive", exp)); }); // Log experiments that users manually opt into, these are experiments which are added using the exp framework. this._optInto .filter((exp) => exp !== 'All' && exp.toLowerCase().startsWith('python')) .forEach((exp) => { - traceLog(localize('Experiments.manuallyOptIntoExperiments', "Experiment '{0}' is active", exp)); + traceLog(l10n.t("Experiment '{0}' is active", exp)); }); if (!experimentsDisabled) { @@ -214,7 +212,7 @@ export class ExperimentService implements IExperimentService { !this._optOutFrom.includes(exp) && !this._optInto.includes(exp) ) { - traceLog(localize('Experiments.autoOptIntoExperiments', "Experiment '{0}' is active", exp)); + traceLog(l10n.t("Experiment '{0}' is active", exp)); } }); } diff --git a/src/client/common/installer/moduleInstaller.ts b/src/client/common/installer/moduleInstaller.ts index 1f600053d02e..4049edb8ec0d 100644 --- a/src/client/common/installer/moduleInstaller.ts +++ b/src/client/common/installer/moduleInstaller.ts @@ -3,7 +3,7 @@ import { injectable } from 'inversify'; import * as path from 'path'; -import { CancellationToken, ProgressLocation, ProgressOptions } from 'vscode'; +import { CancellationToken, l10n, ProgressLocation, ProgressOptions } from 'vscode'; import { IInterpreterService } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { traceError, traceLog } from '../../logging'; @@ -21,9 +21,6 @@ import { ExecutionInfo, IConfigurationService, IOutputChannel, Product } from '. import { isResource } from '../utils/misc'; import { ProductNames } from './productNames'; import { IModuleInstaller, InstallOptions, InterpreterUri, ModuleInstallFlags } from './types'; -import * as nls from 'vscode-nls'; - -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); @injectable() export abstract class ModuleInstaller implements IModuleInstaller { @@ -139,7 +136,7 @@ export abstract class ModuleInstaller implements IModuleInstaller { const options: ProgressOptions = { location: ProgressLocation.Notification, cancellable: true, - title: localize('products.installingModule', 'Installing {0}', name), + title: l10n.t('Installing {0}', name), }; await shell.withProgress(options, async (_, token: CancellationToken) => install(wrapCancellationTokens(token, cancel)), diff --git a/src/client/common/installer/productInstaller.ts b/src/client/common/installer/productInstaller.ts index 223769842101..10e36f1ad229 100644 --- a/src/client/common/installer/productInstaller.ts +++ b/src/client/common/installer/productInstaller.ts @@ -2,9 +2,8 @@ import { inject, injectable } from 'inversify'; import * as semver from 'semver'; -import { CancellationToken, Uri } from 'vscode'; +import { CancellationToken, l10n, Uri } from 'vscode'; import '../extensions'; -import * as nls from 'vscode-nls'; import { IInterpreterService } from '../../interpreter/contracts'; import { IServiceContainer } from '../../ioc/types'; import { LinterId } from '../../linters/types'; @@ -42,8 +41,6 @@ import { isParentPath } from '../platform/fs-paths'; export { Product } from '../types'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - // Products which may not be available to install from certain package registries, keyed by product name // Installer implementations can check this to determine a suitable installation channel for a product // This is temporary and can be removed when https://github.com/microsoft/vscode-jupyter/issues/5034 is unblocked @@ -252,12 +249,11 @@ export class FormatterInstaller extends BaseInstaller { const formatterNames = formatters.map((formatter) => ProductNames.get(formatter)!); const productName = ProductNames.get(product)!; formatterNames.splice(formatterNames.indexOf(productName), 1); - const useOptions = formatterNames.map((name) => localize('products.useFormatter', 'Use {0}', name)); + const useOptions = formatterNames.map((name) => l10n.t('Use {0}', name)); const yesChoice = Common.bannerLabelYes; const options = [...useOptions, Common.doNotShowAgain]; - let message = localize( - 'products.formatterNotInstalled', + let message = l10n.t( 'Formatter {0} is not installed. Install?', productName, ); @@ -265,8 +261,7 @@ export class FormatterInstaller extends BaseInstaller { options.splice(0, 0, yesChoice); } else { const executable = this.getExecutableNameFromSettings(product, resource); - message = localize( - 'products.invalidFormatterPath', + message = l10n.t( 'Path to the {0} formatter is invalid ({1})', productName, executable, @@ -339,13 +334,12 @@ export class LinterInstaller extends BaseInstaller { const options = [selectLinter, doNotShowAgain]; - let message = localize('Linter.notInstalled', 'Linter {0} is not installed.', productName); + let message = l10n.t('Linter {0} is not installed.', productName); if (this.isExecutableAModule(product, resource)) { options.splice(0, 0, install); } else { const executable = this.getExecutableNameFromSettings(product, resource); - message = localize( - 'Linter.invalidPath', + message = l10n.t( 'Path to the {0} linter is invalid ({1})', productName, executable, @@ -404,8 +398,7 @@ export class TestFrameworkInstaller extends BaseInstaller { const productName = ProductNames.get(product)!; const options: string[] = []; - let message = localize( - 'TestFramework.notIstalled', + let message = l10n.t( 'Test framework {0} is not installed. Install?', productName, ); @@ -413,8 +406,7 @@ export class TestFrameworkInstaller extends BaseInstaller { options.push(...[Common.bannerLabelYes, Common.bannerLabelNo]); } else { const executable = this.getExecutableNameFromSettings(product, resource); - message = localize( - 'TestFramework.invalidPath', + message = l10n.t( 'Path to the {0} test framework is invalid ({1})', productName, executable, @@ -529,8 +521,7 @@ export class DataScienceInstaller extends BaseInstaller { if (!installerModule) { this.appShell .showErrorMessage( - localize( - 'Installer.couldNotInstallLibrary', + l10n.t( 'Could not install {0}. If pip is not available, please use the package manager of your choice to manually install this library into your Python environment.', moduleName, ), @@ -575,8 +566,7 @@ export class DataScienceInstaller extends BaseInstaller { ): Promise { const productName = ProductNames.get(product)!; const item = await this.appShell.showErrorMessage( - localize( - 'Installer.dataScienceInstallPrompt', + l10n.t( 'Data Science library {0} is not installed. Install?', productName, ), diff --git a/src/client/common/net/fileDownloader.ts b/src/client/common/net/fileDownloader.ts index 5c54ae247911..6ddd06bcc940 100644 --- a/src/client/common/net/fileDownloader.ts +++ b/src/client/common/net/fileDownloader.ts @@ -4,9 +4,8 @@ 'use strict'; import { inject, injectable } from 'inversify'; -import * as nls from 'vscode-nls'; import * as requestTypes from 'request'; -import { Progress } from 'vscode'; +import { l10n, Progress } from 'vscode'; import { traceLog } from '../../logging'; import { IApplicationShell } from '../application/types'; import { Octicons } from '../constants'; @@ -14,8 +13,6 @@ import { IFileSystem, WriteStream } from '../platform/types'; import { DownloadOptions, IFileDownloader, IHttpClient } from '../types'; import { noop } from '../utils/misc'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - @injectable() export class FileDownloader implements IFileDownloader { constructor( @@ -24,7 +21,7 @@ export class FileDownloader implements IFileDownloader { @inject(IApplicationShell) private readonly appShell: IApplicationShell, ) {} public async downloadFile(uri: string, options: DownloadOptions): Promise { - traceLog(localize('downloading.file', 'Downloading {0}...', uri)); + traceLog(l10n.t('Downloading {0}...', uri)); const tempFile = await this.fs.createTemporaryFile(options.extension); await this.downloadFileWithStatusBarProgress(uri, options.progressMessagePrefix, tempFile.filePath).then( @@ -99,8 +96,7 @@ function formatProgressMessageWithState(progressMessagePrefix: string, state: Re const total = Math.round(state.size.total / 1024); const percentage = Math.round(100 * state.percent); - return localize( - 'downloading.file.progress', + return l10n.t( '{0}{1} of {2} KB ({3}%)', progressMessagePrefix, received.toString(), diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index a8c5d186d1f0..d1fbb7aec977 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -3,623 +3,454 @@ 'use strict'; -import * as nls from 'vscode-nls'; - -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); +import { l10n } from 'vscode'; /* eslint-disable @typescript-eslint/no-namespace, no-shadow */ // External callers of localize use these tables to retrieve localized values. export namespace Diagnostics { - export const warnSourceMaps = localize( - 'diagnostics.warnSourceMaps', - 'Source map support is enabled in the Python Extension, this will adversely impact performance of the extension.', - ); - export const disableSourceMaps = localize('diagnostics.disableSourceMaps', 'Disable Source Map Support'); - export const warnBeforeEnablingSourceMaps = localize( - 'diagnostics.warnBeforeEnablingSourceMaps', + export const warnBeforeEnablingSourceMaps = l10n.t( 'Enabling source map support in the Python Extension will adversely impact performance of the extension.', ); - export const enableSourceMapsAndReloadVSC = localize( - 'diagnostics.enableSourceMapsAndReloadVSC', - 'Enable and reload Window.', - ); - export const lsNotSupported = localize( - 'diagnostics.lsNotSupported', + export const enableSourceMapsAndReloadVSC = l10n.t('Enable and reload Window.'); + export const lsNotSupported = l10n.t( 'Your operating system does not meet the minimum requirements of the Python Language Server. Reverting to the alternative autocompletion provider, Jedi.', ); - export const invalidPythonPathInDebuggerSettings = localize( - 'diagnostics.invalidPythonPathInDebuggerSettings', - 'You need to select a Python interpreter before you start debugging.\n\nTip: click on "Select Interpreter" in the status bar.', + export const removedPythonPathFromSettings = l10n.t( + 'The "python.pythonPath" setting in your settings.json is no longer used by the Python extension. If you want, you can use a new setting called "python.defaultInterpreterPath" instead. Keep in mind that you need to change the value of this setting manually as the Python extension doesn\'t modify it when you change interpreters. [Learn more](https://aka.ms/AA7jfor).', ); - export const invalidPythonPathInDebuggerLaunch = localize( - 'diagnostics.invalidPythonPathInDebuggerLaunch', - 'The Python path in your debug configuration is invalid.', + export const invalidPythonPathInDebuggerSettings = l10n.t( + 'You need to select a Python interpreter before you start debugging.\n\nTip: click on "Select Interpreter" in the status bar.', ); - export const invalidDebuggerTypeDiagnostic = localize( - 'diagnostics.invalidDebuggerTypeDiagnostic', + export const invalidPythonPathInDebuggerLaunch = l10n.t('The Python path in your debug configuration is invalid.'); + export const invalidDebuggerTypeDiagnostic = l10n.t( 'Your launch.json file needs to be updated to change the "pythonExperimental" debug configurations to use the "python" debugger type, otherwise Python debugging may not work. Would you like to automatically update your launch.json file now?', ); - export const consoleTypeDiagnostic = localize( - 'diagnostics.consoleTypeDiagnostic', + export const consoleTypeDiagnostic = l10n.t( 'Your launch.json file needs to be updated to change the console type string from "none" to "internalConsole", otherwise Python debugging may not work. Would you like to automatically update your launch.json file now?', ); - export const justMyCodeDiagnostic = localize( - 'diagnostics.justMyCodeDiagnostic', + export const justMyCodeDiagnostic = l10n.t( 'Configuration "debugStdLib" in launch.json is no longer supported. It\'s recommended to replace it with "justMyCode", which is the exact opposite of using "debugStdLib". Would you like to automatically update your launch.json file to do that?', ); - export const yesUpdateLaunch = localize('diagnostics.yesUpdateLaunch', 'Yes, update launch.json'); - export const invalidTestSettings = localize( - 'diagnostics.invalidTestSettings', + export const yesUpdateLaunch = l10n.t('Yes, update launch.json'); + export const invalidTestSettings = l10n.t( 'Your settings needs to be updated to change the setting "python.unitTest." to "python.testing.", otherwise testing Python code using the extension may not work. Would you like to automatically update your settings now?', ); - export const updateSettings = localize('diagnostics.updateSettings', 'Yes, update settings'); - export const checkIsort5UpgradeGuide = localize( - 'diagnostics.checkIsort5UpgradeGuide', + export const updateSettings = l10n.t('Yes, update settings'); + export const checkIsort5UpgradeGuide = l10n.t( 'We found outdated configuration for sorting imports in this workspace. Check the [isort upgrade guide](https://aka.ms/AA9j5x4) to update your settings.', ); - export const pylanceDefaultMessage = localize( - 'diagnostics.pylanceDefaultMessage', + export const pylanceDefaultMessage = l10n.t( "The Python extension now includes Pylance to improve completions, code navigation, overall performance and much more! You can learn more about the update and learn how to change your language server [here](https://aka.ms/new-python-bundle).\n\nRead Pylance's license [here](https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license).", ); + export const warnSourceMaps = l10n.t( + 'Source map support is enabled in the Python Extension, this will adversely impact performance of the extension.', + ); + export const disableSourceMaps = l10n.t('Disable Source Map Support'); } export namespace Common { - export const bannerLabelYes = localize('Common.bannerLabelYes', 'Yes'); - export const bannerLabelNo = localize('Common.bannerLabelNo', 'No'); - export const yesPlease = localize('Common.yesPlease', 'Yes, please'); - export const canceled = localize('Common.canceled', 'Canceled'); - export const cancel = localize('Common.cancel', 'Cancel'); - export const ok = localize('Common.ok', 'Ok'); - export const error = localize('Common.error', 'Error'); - export const gotIt = localize('Common.gotIt', 'Got it!'); - export const install = localize('Common.install', 'Install'); - export const loadingExtension = localize('Common.loadingPythonExtension', 'Python extension loading...'); - export const openOutputPanel = localize('Common.openOutputPanel', 'Show output'); - export const noIWillDoItLater = localize('Common.noIWillDoItLater', 'No, I will do it later'); - export const notNow = localize('Common.notNow', 'Not now'); - export const doNotShowAgain = localize('Common.doNotShowAgain', 'Do not show again'); - export const reload = localize('Common.reload', 'Reload'); - export const moreInfo = localize('Common.moreInfo', 'More Info'); - export const learnMore = localize('Common.learnMore', 'Learn more'); - export const and = localize('Common.and', 'and'); - export const reportThisIssue = localize('Common.reportThisIssue', 'Report this issue'); - export const recommended = localize('Common.recommended', 'Recommended'); - export const clearAll = localize('Common.clearAll', 'Clear all'); - export const alwaysIgnore = localize('Common.alwaysIgnore', 'Always Ignore'); - export const ignore = localize('Common.ignore', 'Ignore'); - export const selectPythonInterpreter = localize('Common.selectPythonInterpreter', 'Select Python Interpreter'); - export const openLaunch = localize('Common.openLaunch', 'Open launch.json'); - export const useCommandPrompt = localize('Common.useCommandPrompt', 'Use Command Prompt'); - export const download = localize('Common.download', 'Download'); - export const showLogs = localize('Common.showLogs', 'Show logs'); export const openFolder = localize('Common.openFolder', 'Open Folder...'); + export const bannerLabelYes = l10n.t('Yes'); + export const bannerLabelNo = l10n.t('No'); + export const yesPlease = l10n.t('Yes, please'); + export const canceled = l10n.t('Canceled'); + export const cancel = l10n.t('Cancel'); + export const ok = l10n.t('Ok'); + export const error = l10n.t('Error'); + export const gotIt = l10n.t('Got it!'); + export const install = l10n.t('Install'); + export const loadingExtension = l10n.t('Python extension loading...'); + export const openOutputPanel = l10n.t('Show output'); + export const noIWillDoItLater = l10n.t('No, I will do it later'); + export const notNow = l10n.t('Not now'); + export const doNotShowAgain = l10n.t('Do not show again'); + export const reload = l10n.t('Reload'); + export const moreInfo = l10n.t('More Info'); + export const learnMore = l10n.t('Learn more'); + export const and = l10n.t('and'); + export const reportThisIssue = l10n.t('Report this issue'); + export const recommended = l10n.t('Recommended'); + export const clearAll = l10n.t('Clear all'); + export const alwaysIgnore = l10n.t('Always Ignore'); + export const ignore = l10n.t('Ignore'); + export const selectPythonInterpreter = l10n.t('Select Python Interpreter'); + export const openLaunch = l10n.t('Open launch.json'); + export const useCommandPrompt = l10n.t('Use Command Prompt'); + export const download = l10n.t('Download'); + export const showLogs = l10n.t('Show logs'); } export namespace CommonSurvey { - export const remindMeLaterLabel = localize('CommonSurvey.remindMeLaterLabel', 'Remind me later'); - export const yesLabel = localize('CommonSurvey.yesLabel', 'Yes, take survey now'); - export const noLabel = localize('CommonSurvey.noLabel', 'No, thanks'); + export const remindMeLaterLabel = l10n.t('Remind me later'); + export const yesLabel = l10n.t('Yes, take survey now'); + export const noLabel = l10n.t('No, thanks'); } export namespace AttachProcess { - export const attachTitle = localize('AttachProcess.attachTitle', 'Attach to process'); - export const selectProcessPlaceholder = localize( - 'AttachProcess.selectProcessPlaceholder', - 'Select the process to attach to', - ); - export const noProcessSelected = localize('AttachProcess.noProcessSelected', 'No process selected'); - export const refreshList = localize('AttachProcess.refreshList', 'Refresh process list'); + export const attachTitle = l10n.t('Attach to process'); + export const selectProcessPlaceholder = l10n.t('Select the process to attach to'); + export const noProcessSelected = l10n.t('No process selected'); + export const refreshList = l10n.t('Refresh process list'); } export namespace Pylance { - export const remindMeLater = localize('Pylance.remindMeLater', 'Remind me later'); + export const remindMeLater = l10n.t('Remind me later'); - export const pylanceNotInstalledMessage = localize( - 'Pylance.pylanceNotInstalledMessage', - 'Pylance extension is not installed.', - ); - export const pylanceInstalledReloadPromptMessage = localize( - 'Pylance.pylanceInstalledReloadPromptMessage', + export const pylanceNotInstalledMessage = l10n.t('Pylance extension is not installed.'); + export const pylanceInstalledReloadPromptMessage = l10n.t( 'Pylance extension is now installed. Reload window to activate?', ); - export const pylanceRevertToJediPrompt = localize( - 'Pylance.pylanceRevertToJediPrompt', + export const pylanceRevertToJediPrompt = l10n.t( 'The Pylance extension is not installed but the python.languageServer value is set to "Pylance". Would you like to install the Pylance extension to use Pylance, or revert back to Jedi?', ); - export const pylanceInstallPylance = localize('Pylance.pylanceInstallPylance', 'Install Pylance'); - export const pylanceRevertToJedi = localize('Pylance.pylanceRevertToJedi', 'Revert to Jedi'); + export const pylanceInstallPylance = l10n.t('Install Pylance'); + export const pylanceRevertToJedi = l10n.t('Revert to Jedi'); } export namespace TensorBoard { - export const enterRemoteUrl = localize('TensorBoard.enterRemoteUrl', 'Enter remote URL'); - export const enterRemoteUrlDetail = localize( - 'TensorBoard.enterRemoteUrlDetail', + export const enterRemoteUrl = l10n.t('Enter remote URL'); + export const enterRemoteUrlDetail = l10n.t( 'Enter a URL pointing to a remote directory containing your TensorBoard log files', ); - export const useCurrentWorkingDirectoryDetail = localize( - 'TensorBoard.useCurrentWorkingDirectoryDetail', + export const useCurrentWorkingDirectoryDetail = l10n.t( 'TensorBoard will search for tfevent files in all subdirectories of the current working directory', ); - export const useCurrentWorkingDirectory = localize( - 'TensorBoard.useCurrentWorkingDirectory', - 'Use current working directory', - ); - export const logDirectoryPrompt = localize( - 'TensorBoard.logDirectoryPrompt', - 'Select a log directory to start TensorBoard with', - ); - export const progressMessage = localize('TensorBoard.progressMessage', 'Starting TensorBoard session...'); - export const nativeTensorBoardPrompt = localize( - 'TensorBoard.nativeTensorBoardPrompt', + export const useCurrentWorkingDirectory = l10n.t('Use current working directory'); + export const logDirectoryPrompt = l10n.t('Select a log directory to start TensorBoard with'); + export const progressMessage = l10n.t('Starting TensorBoard session...'); + export const nativeTensorBoardPrompt = l10n.t( 'VS Code now has integrated TensorBoard support. Would you like to launch TensorBoard? (Tip: Launch TensorBoard anytime by opening the command palette and searching for "Launch TensorBoard".)', ); - export const selectAFolder = localize('TensorBoard.selectAFolder', 'Select a folder'); - export const selectAFolderDetail = localize( - 'TensorBoard.selectAFolderDetail', - 'Select a log directory containing tfevent files', - ); - export const selectAnotherFolder = localize('TensorBoard.selectAnotherFolder', 'Select another folder'); - export const selectAnotherFolderDetail = localize( - 'TensorBoard.selectAnotherFolderDetail', - 'Use the file explorer to select another folder', - ); - export const installPrompt = localize( - 'TensorBoard.installPrompt', + export const selectAFolder = l10n.t('Select a folder'); + export const selectAFolderDetail = l10n.t('Select a log directory containing tfevent files'); + export const selectAnotherFolder = l10n.t('Select another folder'); + export const selectAnotherFolderDetail = l10n.t('Use the file explorer to select another folder'); + export const installPrompt = l10n.t( 'The package TensorBoard is required to launch a TensorBoard session. Would you like to install it?', ); - export const installTensorBoardAndProfilerPluginPrompt = localize( - 'TensorBoard.installTensorBoardAndProfilerPluginPrompt', + export const installTensorBoardAndProfilerPluginPrompt = l10n.t( 'TensorBoard >= 2.4.1 and the PyTorch Profiler TensorBoard plugin >= 0.2.0 are required. Would you like to install these packages?', ); - export const installProfilerPluginPrompt = localize( - 'TensorBoard.installProfilerPluginPrompt', + export const installProfilerPluginPrompt = l10n.t( 'We recommend installing version >= 0.2.0 of the PyTorch Profiler TensorBoard plugin. Would you like to install the package?', ); - export const upgradePrompt = localize( - 'TensorBoard.upgradePrompt', + export const upgradePrompt = l10n.t( 'Integrated TensorBoard support is only available for TensorBoard >= 2.4.1. Would you like to upgrade your copy of TensorBoard?', ); - export const launchNativeTensorBoardSessionCodeLens = localize( - 'TensorBoard.launchNativeTensorBoardSessionCodeLens', - '▶ Launch TensorBoard Session', - ); - export const launchNativeTensorBoardSessionCodeAction = localize( - 'TensorBoard.launchNativeTensorBoardSessionCodeAction', - 'Launch TensorBoard session', - ); - export const missingSourceFile = localize( - 'TensorBoard.missingSourceFile', + export const launchNativeTensorBoardSessionCodeLens = l10n.t('▶ Launch TensorBoard Session'); + export const launchNativeTensorBoardSessionCodeAction = l10n.t('Launch TensorBoard session'); + export const missingSourceFile = l10n.t( 'We could not locate the requested source file on disk. Please manually specify the file.', ); - export const selectMissingSourceFile = localize('TensorBoard.selectMissingSourceFile', 'Choose File'); - export const selectMissingSourceFileDescription = localize( - 'TensorBoard.selectMissingSourceFileDescription', + export const selectMissingSourceFile = l10n.t('Choose File'); + export const selectMissingSourceFileDescription = l10n.t( "The source file's contents may not match the original contents in the trace.", ); } export namespace LanguageService { export const virtualWorkspaceStatusItem = { - detail: localize( - 'LanguageService.virtualWorkspaceStatusItem.detail', - 'Limited IntelliSense supported by Jedi and Pylance', - ), + detail: l10n.t('Limited IntelliSense supported by Jedi and Pylance'), }; export const statusItem = { - name: localize('LanguageService.statusItem.name', 'Python IntelliSense Status'), - text: localize('LanguageService.statusItem.text', 'Partial Mode'), - detail: localize('LanguageService.statusItem.detail', 'Limited IntelliSense provided by Pylance'), + name: l10n.t('Python IntelliSense Status'), + text: l10n.t('Partial Mode'), + detail: l10n.t('Limited IntelliSense provided by Pylance'), }; - export const startingPylance = localize('LanguageService.startingPylance', 'Starting Pylance language server.'); - export const startingNone = localize( - 'LanguageService.startingNone', - 'Editor support is inactive since language server is set to None.', - ); - export const untrustedWorkspaceMessage = localize( - 'LanguageService.untrustedWorkspaceMessage', + export const startingPylance = l10n.t('Starting Pylance language server.'); + export const startingNone = l10n.t('Editor support is inactive since language server is set to None.'); + export const untrustedWorkspaceMessage = l10n.t( 'Only Pylance is supported in untrusted workspaces, setting language server to None.', ); - export const reloadAfterLanguageServerChange = localize( - 'LanguageService.reloadAfterLanguageServerChange', + export const reloadAfterLanguageServerChange = l10n.t( 'Please reload the window switching between language servers.', ); - export const lsFailedToStart = localize( - 'LanguageService.lsFailedToStart', + export const lsFailedToStart = l10n.t( 'We encountered an issue starting the language server. Reverting to Jedi language engine. Check the Python output panel for details.', ); - export const lsFailedToDownload = localize( - 'LanguageService.lsFailedToDownload', + export const lsFailedToDownload = l10n.t( 'We encountered an issue downloading the language server. Reverting to Jedi language engine. Check the Python output panel for details.', ); - export const lsFailedToExtract = localize( - 'LanguageService.lsFailedToExtract', + export const lsFailedToExtract = l10n.t( 'We encountered an issue extracting the language server. Reverting to Jedi language engine. Check the Python output panel for details.', ); - export const downloadFailedOutputMessage = localize( - 'LanguageService.downloadFailedOutputMessage', - 'Language server download failed.', - ); - export const extractionFailedOutputMessage = localize( - 'LanguageService.extractionFailedOutputMessage', - 'Language server extraction failed.', - ); - export const extractionCompletedOutputMessage = localize( - 'LanguageService.extractionCompletedOutputMessage', - 'Language server download complete.', - ); - export const extractionDoneOutputMessage = localize('LanguageService.extractionDoneOutputMessage', 'done.'); - export const reloadVSCodeIfSeachPathHasChanged = localize( - 'LanguageService.reloadVSCodeIfSeachPathHasChanged', + export const downloadFailedOutputMessage = l10n.t('Language server download failed.'); + export const extractionFailedOutputMessage = l10n.t('Language server extraction failed.'); + export const extractionCompletedOutputMessage = l10n.t('Language server download complete.'); + export const extractionDoneOutputMessage = l10n.t('done.'); + export const reloadVSCodeIfSeachPathHasChanged = l10n.t( 'Search paths have changed for this Python interpreter. Please reload the extension to ensure that the IntelliSense works correctly.', ); } export namespace Interpreters { - export const installingPython = localize('Interpreters.installingPython', 'Installing Python into Environment...'); - export const discovering = localize('Interpreters.DiscoveringInterpreters', 'Discovering Python Interpreters'); - export const refreshing = localize('Interpreters.RefreshingInterpreters', 'Refreshing Python Interpreters'); - export const condaInheritEnvMessage = localize( - 'Interpreters.condaInheritEnvMessage', + export const installingPython = l10n.t('Installing Python into Environment...'); + export const discovering = l10n.t('Discovering Python Interpreters'); + export const refreshing = l10n.t('Refreshing Python Interpreters'); + export const condaInheritEnvMessage = l10n.t( 'We noticed you\'re using a conda environment. If you are experiencing issues with this environment in the integrated terminal, we recommend that you let the Python extension change "terminal.integrated.inheritEnv" to false in your user settings.', ); - export const environmentPromptMessage = localize( - 'Interpreters.environmentPromptMessage', + export const environmentPromptMessage = l10n.t( 'We noticed a new environment has been created. Do you want to select it for the workspace folder?', ); - export const entireWorkspace = localize('Interpreters.entireWorkspace', 'Select at workspace level'); - export const clearAtWorkspace = localize('Interpreters.clearAtWorkspace', 'Clear at workspace level'); - export const selectInterpreterTip = localize( - 'Interpreters.selectInterpreterTip', + export const entireWorkspace = l10n.t('Select at workspace level'); + export const clearAtWorkspace = l10n.t('Clear at workspace level'); + export const selectInterpreterTip = l10n.t( 'Tip: you can change the Python interpreter used by the Python extension by clicking on the Python version in the status bar', ); - export const installPythonTerminalMessage = localize( - 'Interpreters.installPythonTerminalMessage', + export const installPythonTerminalMessage = l10n.t( '💡 Please try installing the python package using your package manager. Alternatively you can also download it from https://www.python.org/downloads', ); - export const changePythonInterpreter = localize( - 'Interpreters.changePythonInterpreter', - 'Change Python Interpreter', - ); - export const selectedPythonInterpreter = localize( - 'Interpreters.selectedPythonInterpreter', - 'Selected Python Interpreter', - ); + export const changePythonInterpreter = l10n.t('Change Python Interpreter'); + export const selectedPythonInterpreter = l10n.t('Selected Python Interpreter'); } export namespace InterpreterQuickPickList { - export const noPythonInstalled = localize( - 'InterpreterQuickPickList.noPythonInstalled', - 'Python is not installed, please download and install it', - ); - export const clickForInstructions = localize( - 'InterpreterQuickPickList.clickForInstructions', - 'Click for instructions...', - ); - export const globalGroupName = localize('InterpreterQuickPickList.globalGroupName', 'Global'); - export const workspaceGroupName = localize('InterpreterQuickPickList.workspaceGroupName', 'Workspace'); + export const noPythonInstalled = l10n.t('Python is not installed, please download and install it'); + export const clickForInstructions = l10n.t('Click for instructions...'); + export const globalGroupName = l10n.t('Global'); + export const workspaceGroupName = l10n.t('Workspace'); export const enterPath = { - label: localize('InterpreterQuickPickList.enterPath.label', 'Enter interpreter path...'), - placeholder: localize('InterpreterQuickPickList.enterPath.placeholder', 'Enter path to a Python interpreter.'), + label: l10n.t('Enter interpreter path...'), + placeholder: l10n.t('Enter path to a Python interpreter.'), }; export const defaultInterpreterPath = { - label: localize( - 'InterpreterQuickPickList.defaultInterpreterPath.label', - 'Use Python from `python.defaultInterpreterPath` setting', - ), + label: l10n.t('Use Python from `python.defaultInterpreterPath` setting'), }; export const browsePath = { - label: localize('InterpreterQuickPickList.browsePath.label', 'Find...'), - detail: localize( - 'InterpreterQuickPickList.browsePath.detail', - 'Browse your file system to find a Python interpreter.', - ), - openButtonLabel: localize('python.command.python.setInterpreter.title', 'Select Interpreter'), - title: localize('InterpreterQuickPickList.browsePath.title', 'Select Python interpreter'), + label: l10n.t('Find...'), + detail: l10n.t('Browse your file system to find a Python interpreter.'), + openButtonLabel: l10n.t('Select Interpreter'), + title: l10n.t('Select Python interpreter'), }; - export const refreshInterpreterList = localize( - 'InterpreterQuickPickList.refreshInterpreterList', - 'Refresh Interpreter list', - ); - export const refreshingInterpreterList = localize( - 'InterpreterQuickPickList.refreshingInterpreterList', - 'Refreshing Interpreter list...', - ); + export const refreshInterpreterList = l10n.t('Refresh Interpreter list'); + export const refreshingInterpreterList = l10n.t('Refreshing Interpreter list...'); } export namespace OutputChannelNames { - export const languageServer = localize('OutputChannelNames.languageServer', 'Python Language Server'); - export const python = localize('OutputChannelNames.python', 'Python'); - export const pythonTest = localize('OutputChannelNames.pythonTest', 'Python Test Log'); + export const languageServer = l10n.t('Python Language Server'); + export const python = l10n.t('Python'); + export const pythonTest = l10n.t('Python Test Log'); } export namespace Logging { - export const currentWorkingDirectory = localize('Logging.CurrentWorkingDirectory', 'cwd:'); + export const currentWorkingDirectory = l10n.t('cwd:'); } export namespace Linters { - export const selectLinter = localize('Linter.selectLinter', 'Select Linter'); + export const selectLinter = l10n.t('Select Linter'); } export namespace Installer { - export const noCondaOrPipInstaller = localize( - 'Installer.noCondaOrPipInstaller', + export const noCondaOrPipInstaller = l10n.t( 'There is no Conda or Pip installer available in the selected environment.', ); - export const noPipInstaller = localize( - 'Installer.noPipInstaller', - 'There is no Pip installer available in the selected environment.', - ); - export const searchForHelp = localize('Installer.searchForHelp', 'Search for help'); + export const noPipInstaller = l10n.t('There is no Pip installer available in the selected environment.'); + export const searchForHelp = l10n.t('Search for help'); } export namespace ExtensionSurveyBanner { - export const bannerMessage = localize( - 'ExtensionSurveyBanner.bannerMessage', + export const bannerMessage = l10n.t( 'Can you please take 2 minutes to tell us how the Python extension is working for you?', ); - export const bannerLabelYes = localize('ExtensionSurveyBanner.bannerLabelYes', 'Yes, take survey now'); - export const bannerLabelNo = localize('ExtensionSurveyBanner.bannerLabelNo', 'No, thanks'); - export const maybeLater = localize('ExtensionSurveyBanner.maybeLater', 'Maybe later'); + export const bannerLabelYes = l10n.t('Yes, take survey now'); + export const bannerLabelNo = l10n.t('No, thanks'); + export const maybeLater = l10n.t('Maybe later'); } export namespace DebugConfigStrings { export const selectConfiguration = { - title: localize('debug.selectConfigurationTitle', 'Select a debug configuration'), - placeholder: localize('debug.selectConfigurationPlaceholder', 'Debug Configuration'), + title: l10n.t('Select a debug configuration'), + placeholder: l10n.t('Debug Configuration'), }; export const launchJsonCompletions = { - label: localize('debug.launchJsonConfigurationsCompletionLabel', 'Python'), - description: localize( - 'debug.launchJsonConfigurationsCompletionDescription', - 'Select a Python debug configuration', - ), + label: l10n.t('Python'), + description: l10n.t('Select a Python debug configuration'), }; export namespace file { export const snippet = { - name: localize('python.snippet.launch.standard.label', 'Python: Current File'), + name: l10n.t('Python: Current File'), }; export const selectConfiguration = { - label: localize('debug.debugFileConfigurationLabel', 'Python File'), - description: localize('debug.debugFileConfigurationDescription', 'Debug the currently active Python file'), + label: l10n.t('Python File'), + description: l10n.t('Debug the currently active Python file'), }; } export namespace module { export const snippet = { - name: localize('python.snippet.launch.module.label', 'Python: Module'), - default: localize('python.snippet.launch.module.default', 'enter-your-module-name'), + name: l10n.t('Python: Module'), + default: l10n.t('enter-your-module-name'), }; export const selectConfiguration = { - label: localize('debug.debugModuleConfigurationLabel', 'Module'), - description: localize( - 'debug.debugModuleConfigurationDescription', - "Debug a Python module by invoking it with '-m'", - ), + label: l10n.t('Module'), + description: l10n.t("Debug a Python module by invoking it with '-m'"), }; export const enterModule = { - title: localize('debug.moduleEnterModuleTitle', 'Debug Module'), - prompt: localize('debug.moduleEnterModulePrompt', 'Enter a Python module/package name'), - default: localize('debug.moduleEnterModuleDefault', 'enter-your-module-name'), - invalid: localize('debug.moduleEnterModuleInvalidNameError', 'Enter a valid module name'), + title: l10n.t('Debug Module'), + prompt: l10n.t('Enter a Python module/package name'), + default: l10n.t('enter-your-module-name'), + invalid: l10n.t('Enter a valid module name'), }; } export namespace attach { export const snippet = { - name: localize('python.snippet.launch.attach.label', 'Python: Remote Attach'), + name: l10n.t('Python: Remote Attach'), }; export const selectConfiguration = { - label: localize('debug.remoteAttachConfigurationLabel', 'Remote Attach'), - description: localize('debug.remoteAttachConfigurationDescription', 'Attach to a remote debug server'), + label: l10n.t('Remote Attach'), + description: l10n.t('Attach to a remote debug server'), }; export const enterRemoteHost = { - title: localize('debug.attachRemoteHostTitle', 'Remote Debugging'), - prompt: localize('debug.attachRemoteHostPrompt', 'Enter a valid host name or IP address'), - invalid: localize('debug.attachRemoteHostValidationError', 'Enter a valid host name or IP address'), + title: l10n.t('Remote Debugging'), + prompt: l10n.t('Enter a valid host name or IP address'), + invalid: l10n.t('Enter a valid host name or IP address'), }; export const enterRemotePort = { - title: localize('debug.attachRemotePortTitle', 'Remote Debugging'), - prompt: localize( - 'debug.attachRemotePortPrompt', - 'Enter the port number that the debug server is listening on', - ), - invalid: localize('debug.attachRemotePortValidationError', 'Enter a valid port number'), + title: l10n.t('Remote Debugging'), + prompt: l10n.t('Enter the port number that the debug server is listening on'), + invalid: l10n.t('Enter a valid port number'), }; } export namespace attachPid { export const snippet = { - name: localize('python.snippet.launch.attachpid.label', 'Python: Attach using Process Id'), + name: l10n.t('Python: Attach using Process Id'), }; export const selectConfiguration = { - label: localize('debug.attachPidConfigurationLabel', 'Attach using Process ID'), - description: localize('debug.attachPidConfigurationDescription', 'Attach to a local process'), + label: l10n.t('Attach using Process ID'), + description: l10n.t('Attach to a local process'), }; } export namespace django { export const snippet = { - name: localize('python.snippet.launch.django.label', 'Python: Django'), + name: l10n.t('Python: Django'), }; export const selectConfiguration = { - label: localize('debug.debugDjangoConfigurationLabel', 'Django'), - description: localize( - 'debug.debugDjangoConfigurationDescription', - 'Launch and debug a Django web application', - ), + label: l10n.t('Django'), + description: l10n.t('Launch and debug a Django web application'), }; export const enterManagePyPath = { - title: localize('debug.djangoEnterManagePyPathTitle', 'Debug Django'), - prompt: localize( - 'debug.djangoEnterManagePyPathPrompt', + title: l10n.t('Debug Django'), + prompt: l10n.t( "Enter the path to manage.py ('${workspaceFolderToken}' points to the root of the current workspace folder)", ), - invalid: localize('debug.djangoEnterManagePyPathInvalidFilePathError', 'Enter a valid Python file path'), + invalid: l10n.t('Enter a valid Python file path'), }; } export namespace fastapi { export const snippet = { - name: localize('python.snippet.launch.fastapi.label', 'Python: FastAPI'), + name: l10n.t('Python: FastAPI'), }; export const selectConfiguration = { - label: localize('debug.debugFastAPIConfigurationLabel', 'FastAPI'), - description: localize( - 'debug.debugFastAPIConfigurationDescription', - 'Launch and debug a FastAPI web application', - ), + label: l10n.t('FastAPI'), + description: l10n.t('Launch and debug a FastAPI web application'), }; export const enterAppPathOrNamePath = { - title: localize('debug.fastapiEnterAppPathOrNamePathTitle', 'Debug FastAPI'), - prompt: localize( - 'debug.fastapiEnterAppPathOrNamePathPrompt', - "Enter the path to the application, e.g. 'main.py' or 'main'", - ), - invalid: localize('debug.fastapiEnterAppPathOrNamePathInvalidNameError', 'Enter a valid name'), + title: l10n.t('Debug FastAPI'), + prompt: l10n.t("Enter the path to the application, e.g. 'main.py' or 'main'"), + invalid: l10n.t('Enter a valid name'), }; } export namespace flask { export const snippet = { - name: localize('python.snippet.launch.flask.label', 'Python: Flask'), + name: l10n.t('Python: Flask'), }; export const selectConfiguration = { - label: localize('debug.debugFlaskConfigurationLabel', 'Flask'), - description: localize( - 'debug.debugFlaskConfigurationDescription', - 'Launch and debug a Flask web application', - ), + label: l10n.t('Flask'), + description: l10n.t('Launch and debug a Flask web application'), }; export const enterAppPathOrNamePath = { - title: localize('debug.flaskEnterAppPathOrNamePathTitle', 'Debug Flask'), - prompt: localize('debug.flaskEnterAppPathOrNamePathPrompt', 'Python: Flask'), - invalid: localize('debug.flaskEnterAppPathOrNamePathInvalidNameError', 'Enter a valid name'), + title: l10n.t('Debug Flask'), + prompt: l10n.t('Python: Flask'), + invalid: l10n.t('Enter a valid name'), }; } export namespace pyramid { export const snippet = { - name: localize('python.snippet.launch.pyramid.label', 'Python: Pyramid Application'), + name: l10n.t('Python: Pyramid Application'), }; export const selectConfiguration = { - label: localize('debug.debugPyramidConfigurationLabel', 'Pyramid'), - description: localize( - 'debug.debugPyramidConfigurationDescription', - 'Launch and debug a Pyramid web application', - ), + label: l10n.t('Pyramid'), + description: l10n.t('Launch and debug a Pyramid web application'), }; export const enterDevelopmentIniPath = { - title: localize('debug.pyramidEnterDevelopmentIniPathTitle', 'Debug Pyramid'), - invalid: localize('debug.pyramidEnterDevelopmentIniPathInvalidFilePathError', 'Enter a valid file path'), + title: l10n.t('Debug Pyramid'), + invalid: l10n.t('Enter a valid file path'), }; } } export namespace Testing { - export const configureTests = localize('Testing.configureTests', 'Configure Test Framework'); - export const testNotConfigured = localize('Testing.testNotConfigured', 'No test framework configured.'); - export const cancelUnittestDiscovery = localize( - 'Testing.cancelUnittestDiscovery', - 'Canceled unittest test discovery', - ); - export const errorUnittestDiscovery = localize('Testing.errorUnittestDiscovery', 'Unittest test discovery error'); - export const seePythonOutput = localize('Testing.seePythonOutput', '(see Output > Python)'); - export const cancelUnittestExecution = localize( - 'Testing.cancelUnittestExecution', - 'Canceled unittest test execution', - ); - export const errorUnittestExecution = localize('Testing.errorUnittestExecution', 'Unittest test execution error'); + export const configureTests = l10n.t('Configure Test Framework'); + export const testNotConfigured = l10n.t('No test framework configured.'); + export const cancelUnittestDiscovery = l10n.t('Canceled unittest test discovery'); + export const errorUnittestDiscovery = l10n.t('Unittest test discovery error'); + export const seePythonOutput = l10n.t('(see Output > Python)'); + export const cancelUnittestExecution = l10n.t('Canceled unittest test execution'); + export const errorUnittestExecution = l10n.t('Unittest test execution error'); } export namespace OutdatedDebugger { - export const outdatedDebuggerMessage = localize( - 'OutdatedDebugger.updateDebuggerMessage', + export const outdatedDebuggerMessage = l10n.t( 'We noticed you are attaching to ptvsd (Python debugger), which was deprecated on May 1st, 2020. Please switch to [debugpy](https://aka.ms/migrateToDebugpy).', ); } export namespace Python27Support { - export const jediMessage = localize( - 'Python27Support.jediMessage', + export const jediMessage = l10n.t( 'IntelliSense with Jedi for Python 2.7 is no longer supported. [Learn more](https://aka.ms/python-27-support).', ); } export namespace SwitchToDefaultLS { - export const bannerMessage = localize( - 'SwitchToDefaultLS.bannerMessage', + export const bannerMessage = l10n.t( "The Microsoft Python Language Server has reached end of life. Your language server has been set to the default for Python in VS Code, Pylance.\n\nIf you'd like to change your language server, you can learn about how to do so [here](https://devblogs.microsoft.com/python/python-in-visual-studio-code-may-2021-release/#configuring-your-language-server).\n\nRead Pylance's license [here](https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license).", ); } export namespace CreateEnv { - export const informEnvCreation = localize( - 'createEnv.informEnvCreation', - 'We have selected the following environment:', - ); - export const statusTitle = localize('createEnv.statusTitle', 'Creating environment'); - export const statusStarting = localize('createEnv.statusStarting', 'Starting...'); + export const informEnvCreation = l10n.t('We have selected the following environment:'); + export const statusTitle = l10n.t('Creating environment'); + export const statusStarting = l10n.t('Starting...'); - export const hasVirtualEnv = localize('createEnv.hasVirtualEnv', 'Workspace folder contains a virtual environment'); + export const hasVirtualEnv = l10n.t('Workspace folder contains a virtual environment'); - export const noWorkspace = localize( - 'createEnv.noWorkspace', - 'Please open a folder when creating an environment using venv.', - ); + export const noWorkspace = l10n.t('Please open a folder when creating an environment using venv.'); - export const pickWorkspacePlaceholder = localize( - 'createEnv.workspaceQuickPick.placeholder', - 'Select a workspace to create environment', - ); + export const pickWorkspacePlaceholder = l10n.t('Select a workspace to create environment'); - export const providersQuickPickPlaceholder = localize( - 'createEnv.providersQuickPick.placeholder', - 'Select an environment type', - ); + export const providersQuickPickPlaceholder = l10n.t('Select an environment type'); export namespace Venv { - export const creating = localize('createEnv.venv.creating', 'Creating venv...'); - export const created = localize('createEnv.venv.created', 'Environment created...'); - export const installingPackages = localize('createEnv.venv.installingPackages', 'Installing packages...'); - export const errorCreatingEnvironment = localize( - 'createEnv.venv.errorCreatingEnvironment', - 'Error while creating virtual environment.', - ); - export const selectPythonQuickPickTitle = localize( - 'createEnv.venv.basePython.title', - 'Select a python to use for environment creation', - ); - export const providerDescription = localize( - 'createEnv.venv.description', - 'Creates a `.venv` virtual environment in the current workspace', - ); - export const error = localize('createEnv.venv.error', 'Creating virtual environment failed with error.'); + export const creating = l10n.t('Creating venv...'); + export const created = l10n.t('Environment created...'); + export const installingPackages = l10n.t('Installing packages...'); + export const errorCreatingEnvironment = l10n.t('Error while creating virtual environment.'); + export const selectPythonQuickPickTitle = l10n.t('Select a python to use for environment creation'); + export const providerDescription = l10n.t('Creates a `.venv` virtual environment in the current workspace'); + export const error = l10n.t('Creating virtual environment failed with error.'); } export namespace Conda { - export const condaMissing = localize( - 'createEnv.conda.missing', - 'Please install `conda` to create conda environments.', - ); - export const created = localize('createEnv.conda.created', 'Environment created...'); - export const installingPackages = localize('createEnv.conda.installingPackages', 'Installing packages...'); - export const errorCreatingEnvironment = localize( - 'createEnv.conda.errorCreatingEnvironment', - 'Error while creating conda environment.', - ); - export const selectPythonQuickPickPlaceholder = localize( - 'createEnv.conda.pythonSelection.placeholder', + export const condaMissing = l10n.t('Please install `conda` to create conda environments.'); + export const created = l10n.t('Environment created...'); + export const installingPackages = l10n.t('Installing packages...'); + export const errorCreatingEnvironment = l10n.t('Error while creating conda environment.'); + export const selectPythonQuickPickPlaceholder = l10n.t( 'Please select the version of Python to install in the environment', ); - export const creating = localize('createEnv.conda.creating', 'Creating conda environment...'); - export const providerDescription = localize( - 'createEnv.conda.description', - 'Creates a `.conda` Conda environment in the current workspace', - ); + export const creating = l10n.t('Creating conda environment...'); + export const providerDescription = l10n.t('Creates a `.conda` Conda environment in the current workspace'); } } diff --git a/src/client/debugger/extension/adapter/factory.ts b/src/client/debugger/extension/adapter/factory.ts index 10985fb97097..316c2d382a4c 100644 --- a/src/client/debugger/extension/adapter/factory.ts +++ b/src/client/debugger/extension/adapter/factory.ts @@ -10,6 +10,7 @@ import { DebugAdapterExecutable, DebugAdapterServer, DebugSession, + l10n, WorkspaceFolder, } from 'vscode'; import { EXTENSION_ROOT_DIR } from '../../../constants'; @@ -20,15 +21,12 @@ import { sendTelemetryEvent } from '../../../telemetry'; import { EventName } from '../../../telemetry/constants'; import { AttachRequestArguments, LaunchRequestArguments } from '../../types'; import { IDebugAdapterDescriptorFactory } from '../types'; -import * as nls from 'vscode-nls'; import { showErrorMessage } from '../../../common/vscodeApis/windowApis'; import { Common, Interpreters } from '../../../common/utils/localize'; import { IPersistentStateFactory } from '../../../common/types'; import { Commands } from '../../../common/constants'; import { ICommandManager } from '../../../common/application/types'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - // persistent state names, exported to make use of in testing export enum debugStateKeys { doNotShowAgain = 'doNotShowPython36DebugDeprecatedAgain', @@ -206,7 +204,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac */ private async notifySelectInterpreter() { await showErrorMessage( - localize('interpreterError', 'Please install Python or select a Python Interpreter to use the debugger.'), + l10n.t('interpreterError', 'Please install Python or select a Python Interpreter to use the debugger.'), ); } } diff --git a/src/client/debugger/extension/attachQuickPick/provider.ts b/src/client/debugger/extension/attachQuickPick/provider.ts index 26bb80067f93..89b197fb1f2a 100644 --- a/src/client/debugger/extension/attachQuickPick/provider.ts +++ b/src/client/debugger/extension/attachQuickPick/provider.ts @@ -4,15 +4,13 @@ 'use strict'; import { inject, injectable } from 'inversify'; -import * as nls from 'vscode-nls'; +import { l10n } from 'vscode'; import { IPlatformService } from '../../../common/platform/types'; import { IProcessServiceFactory } from '../../../common/process/types'; import { PsProcessParser } from './psProcessParser'; import { IAttachItem, IAttachProcessProvider, ProcessListCommand } from './types'; import { WmicProcessParser } from './wmicProcessParser'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - @injectable() export class AttachProcessProvider implements IAttachProcessProvider { constructor( @@ -72,8 +70,7 @@ export class AttachProcessProvider implements IAttachProcessProvider { processCmd = WmicProcessParser.wmicCommand; } else { throw new Error( - localize( - 'AttachProcess.unsupportedOS', + l10n.t( "Operating system '{0}' not supported.", this.platformService.osType, ), diff --git a/src/client/debugger/extension/configuration/providers/pyramidLaunch.ts b/src/client/debugger/extension/configuration/providers/pyramidLaunch.ts index 3cce683de8ea..315e204e7bf8 100644 --- a/src/client/debugger/extension/configuration/providers/pyramidLaunch.ts +++ b/src/client/debugger/extension/configuration/providers/pyramidLaunch.ts @@ -5,8 +5,7 @@ import * as path from 'path'; import * as fs from 'fs-extra'; -import { WorkspaceFolder } from 'vscode'; -import * as nls from 'vscode-nls'; +import { l10n, WorkspaceFolder } from 'vscode'; import { DebugConfigStrings } from '../../../../common/utils/localize'; import { MultiStepInput } from '../../../../common/utils/multiStepInput'; import { sendTelemetryEvent } from '../../../../telemetry'; @@ -16,8 +15,6 @@ import { LaunchRequestArguments } from '../../../types'; import { DebugConfigurationState, DebugConfigurationType } from '../../types'; import { resolveVariables } from '../utils/common'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - const workspaceFolderToken = '${workspaceFolder}'; export async function buildPyramidLaunchConfiguration( @@ -43,8 +40,7 @@ export async function buildPyramidLaunchConfiguration( const selectedIniPath = await input.showInputBox({ title: DebugConfigStrings.pyramid.enterDevelopmentIniPath.title, value: defaultIni, - prompt: localize( - 'debug.pyramidEnterDevelopmentIniPathPrompt', + prompt: l10n.t( 'Enter the path to development.ini ({0} points to the root of the current workspace folder)', workspaceFolderToken, ), diff --git a/src/client/debugger/extension/hooks/childProcessAttachService.ts b/src/client/debugger/extension/hooks/childProcessAttachService.ts index 07077fda8e0d..c6556a62eaa1 100644 --- a/src/client/debugger/extension/hooks/childProcessAttachService.ts +++ b/src/client/debugger/extension/hooks/childProcessAttachService.ts @@ -4,19 +4,16 @@ 'use strict'; import { inject, injectable } from 'inversify'; -import { DebugConfiguration, DebugSession, WorkspaceFolder } from 'vscode'; import { IDebugService } from '../../../common/application/types'; +import { DebugConfiguration, DebugSession, l10n, WorkspaceFolder } from 'vscode'; import { noop } from '../../../common/utils/misc'; import { captureTelemetry } from '../../../telemetry'; import { EventName } from '../../../telemetry/constants'; import { AttachRequestArguments } from '../../types'; import { IChildProcessAttachService } from './types'; -import * as nls from 'vscode-nls'; import { showErrorMessage } from '../../../common/vscodeApis/windowApis'; import { getWorkspaceFolders } from '../../../common/vscodeApis/workspaceApis'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - /** * This class is responsible for attaching the debugger to any * child processes launched. I.e. this is the class responsible for multi-proc debugging. @@ -35,9 +32,7 @@ export class ChildProcessAttachService implements IChildProcessAttachService { const folder = this.getRelatedWorkspaceFolder(debugConfig); const launched = await this.debugService.startDebugging(folder, debugConfig, parentSession); if (!launched) { - showErrorMessage( - localize('debuggerError', 'Failed to launch debugger for child process {0}', processId), - ).then(noop, noop); + showErrorMessage(l10n.t('Failed to launch debugger for child process {0}', processId)).then(noop, noop); } } diff --git a/src/client/extension.ts b/src/client/extension.ts index 04ad91f80c84..67710b73c8b0 100644 --- a/src/client/extension.ts +++ b/src/client/extension.ts @@ -28,7 +28,6 @@ initializeFileLogging(logDispose); //=============================================== // loading starts here -import '../setupNls'; import { ProgressLocation, ProgressOptions, window } from 'vscode'; import { buildApi } from './api'; import { IApplicationShell, IWorkspaceService } from './common/application/types'; diff --git a/src/client/formatters/blackFormatter.ts b/src/client/formatters/blackFormatter.ts index 4ca741842b55..63170ecf056c 100644 --- a/src/client/formatters/blackFormatter.ts +++ b/src/client/formatters/blackFormatter.ts @@ -5,7 +5,6 @@ import * as path from 'path'; import * as vscode from 'vscode'; -import * as nls from 'vscode-nls'; import { IApplicationShell } from '../common/application/types'; import { Product } from '../common/installer/productInstaller'; import { IConfigurationService } from '../common/types'; @@ -16,8 +15,6 @@ import { sendTelemetryWhenDone } from '../telemetry'; import { EventName } from '../telemetry/constants'; import { BaseFormatter } from './baseFormatter'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - export class BlackFormatter extends BaseFormatter { constructor(serviceContainer: IServiceContainer) { super('black', Product.black, serviceContainer); @@ -41,7 +38,7 @@ export class BlackFormatter extends BaseFormatter { // Black does not support partial formatting on purpose. shell .showErrorMessage( - localize('formatSelectionError', 'Black does not support the "Format Selection" command'), + vscode.l10n.t('Black does not support the "Format Selection" command'), ) .then(noop, noop); return []; diff --git a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts index 5a8c72cd117d..9929cc314b90 100644 --- a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts +++ b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts @@ -6,8 +6,7 @@ import { inject, injectable } from 'inversify'; import { cloneDeep } from 'lodash'; import * as path from 'path'; -import { QuickPick, QuickPickItem, QuickPickItemKind, ThemeIcon } from 'vscode'; -import * as nls from 'vscode-nls'; +import { l10n, QuickPick, QuickPickItem, QuickPickItemKind, ThemeIcon } from 'vscode'; import { IApplicationShell, ICommandManager, IWorkspaceService } from '../../../../common/application/types'; import { Commands, Octicons, ThemeIcons } from '../../../../common/constants'; import { isParentPath } from '../../../../common/platform/fs-paths'; @@ -38,7 +37,6 @@ import { } from '../../types'; import { BaseInterpreterSelectorCommand } from './base'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); const untildify = require('untildify'); export type InterpreterStateArgs = { path?: string; workspace: Resource }; @@ -144,8 +142,7 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem params?.placeholder === null ? undefined : params?.placeholder ?? - localize( - 'InterpreterQuickPickList.quickPickListPlaceholder', + l10n.t( 'Selected Interpreter: {0}', currentInterpreterPathDisplay, ); diff --git a/src/client/interpreter/configuration/pythonPathUpdaterService.ts b/src/client/interpreter/configuration/pythonPathUpdaterService.ts index 64b6d03fddf0..6fc1698412a4 100644 --- a/src/client/interpreter/configuration/pythonPathUpdaterService.ts +++ b/src/client/interpreter/configuration/pythonPathUpdaterService.ts @@ -1,7 +1,6 @@ import { inject, injectable } from 'inversify'; import * as path from 'path'; -import { ConfigurationTarget, Uri, window } from 'vscode'; -import * as nls from 'vscode-nls'; +import { ConfigurationTarget, l10n, Uri, window } from 'vscode'; import { StopWatch } from '../../common/utils/stopWatch'; import { SystemVariables } from '../../common/variables/systemVariables'; import { traceError } from '../../logging'; @@ -11,8 +10,6 @@ import { PythonInterpreterTelemetry } from '../../telemetry/types'; import { IComponentAdapter } from '../contracts'; import { IPythonPathUpdaterServiceFactory, IPythonPathUpdaterServiceManager } from './types'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - @injectable() export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManager { constructor( @@ -37,7 +34,7 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage const reason = err as Error; const message = reason && typeof reason.message === 'string' ? (reason.message as string) : ''; window.showErrorMessage( - localize('setInterpreterError', 'Failed to set interpreter path. Error: {0}', message), + l10n.t('Failed to set interpreter path. Error: {0}', message), ); traceError(reason); } diff --git a/src/client/interpreter/display/index.ts b/src/client/interpreter/display/index.ts index 98f1626ef435..aabb9f86f6d1 100644 --- a/src/client/interpreter/display/index.ts +++ b/src/client/interpreter/display/index.ts @@ -1,6 +1,7 @@ import { inject, injectable } from 'inversify'; import { Disposable, + l10n, LanguageStatusItem, LanguageStatusSeverity, StatusBarAlignment, @@ -23,9 +24,6 @@ import { IInterpreterService, IInterpreterStatusbarVisibilityFilter, } from '../contracts'; -import * as nls from 'vscode-nls'; - -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); /** * Based on https://github.com/microsoft/vscode-python/issues/18040#issuecomment-992567670. @@ -128,8 +126,7 @@ export class InterpreterDisplay implements IInterpreterDisplay, IExtensionSingle this.statusBar.tooltip = this.pathUtils.getDisplayName(interpreter.path, workspaceFolder?.fsPath); if (this.currentlySelectedInterpreterPath !== interpreter.path) { traceLog( - localize( - 'Interpreters.sttausBarPythonInterpreterPath', + l10n.t( 'Python interpreter path: {0}', this.pathUtils.getDisplayName(interpreter.path, workspaceFolder?.fsPath), ), @@ -153,8 +150,7 @@ export class InterpreterDisplay implements IInterpreterDisplay, IExtensionSingle this.languageStatus.detail = this.pathUtils.getDisplayName(interpreter.path, workspaceFolder?.fsPath); if (this.currentlySelectedInterpreterPath !== interpreter.path) { traceLog( - localize( - 'Interpreters.pythonInterpreterPath', + l10n.t( 'Python interpreter path: {0}', this.pathUtils.getDisplayName(interpreter.path, workspaceFolder?.fsPath), ), diff --git a/src/client/languageServer/watcher.ts b/src/client/languageServer/watcher.ts index f7c4193bde90..c71c33b7ad28 100644 --- a/src/client/languageServer/watcher.ts +++ b/src/client/languageServer/watcher.ts @@ -3,8 +3,7 @@ import * as path from 'path'; import { inject, injectable } from 'inversify'; -import { ConfigurationChangeEvent, Uri, WorkspaceFoldersChangeEvent } from 'vscode'; -import * as nls from 'vscode-nls'; +import { ConfigurationChangeEvent, l10n, Uri, WorkspaceFoldersChangeEvent } from 'vscode'; import { LanguageServerChangeHandler } from '../activation/common/languageServerChangeHandler'; import { IExtensionActivationService, ILanguageServerOutputChannel, LanguageServerType } from '../activation/types'; import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common/application/types'; @@ -30,8 +29,6 @@ import { PylanceLSExtensionManager } from './pylanceLSExtensionManager'; import { ILanguageServerExtensionManager, ILanguageServerWatcher } from './types'; import { LspNotebooksExperiment } from '../activation/node/lspNotebooksExperiment'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - @injectable() /** * The Language Server Watcher class implements the ILanguageServerWatcher interface, which is the one-stop shop for language server activation. @@ -380,7 +377,7 @@ function logStartup(languageServerType: LanguageServerType, resource: Uri): void switch (languageServerType) { case LanguageServerType.Jedi: - outputLine = localize('LanguageService.startingJedi', 'Starting Jedi language server for {0}.', basename); + outputLine = l10n.t('Starting Jedi language server for {0}.', basename); break; case LanguageServerType.Node: outputLine = LanguageService.startingPylance; diff --git a/src/client/linters/errorHandlers/standard.ts b/src/client/linters/errorHandlers/standard.ts index 62aac7dffa47..6bd2d3c8e115 100644 --- a/src/client/linters/errorHandlers/standard.ts +++ b/src/client/linters/errorHandlers/standard.ts @@ -1,5 +1,4 @@ -import { Uri } from 'vscode'; -import * as nls from 'vscode-nls'; +import { l10n, Uri } from 'vscode'; import { IApplicationShell } from '../../common/application/types'; import { STANDARD_OUTPUT_CHANNEL } from '../../common/constants'; import { ExecutionInfo, IOutputChannel } from '../../common/types'; @@ -7,7 +6,6 @@ import { traceError, traceLog } from '../../logging'; import { ILinterManager, LinterId } from '../types'; import { BaseErrorHandler } from './baseErrorHandler'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); export class StandardErrorHandler extends BaseErrorHandler { public async handleError(error: Error, resource: Uri, execInfo: ExecutionInfo): Promise { if ( @@ -29,7 +27,7 @@ export class StandardErrorHandler extends BaseErrorHandler { } private async displayLinterError(linterId: LinterId) { - const message = localize('linterError', "There was an error in running the linter '{0}'", linterId); + const message = l10n.t("There was an error in running the linter '{0}'", linterId); const appShell = this.serviceContainer.get(IApplicationShell); const outputChannel = this.serviceContainer.get(IOutputChannel, STANDARD_OUTPUT_CHANNEL); const action = await appShell.showErrorMessage(message, 'View Errors'); diff --git a/src/client/linters/linterCommands.ts b/src/client/linters/linterCommands.ts index 5c9cb42bb460..cc33d100103b 100644 --- a/src/client/linters/linterCommands.ts +++ b/src/client/linters/linterCommands.ts @@ -3,8 +3,7 @@ 'use strict'; -import { DiagnosticCollection, Disposable, QuickPickOptions, Uri } from 'vscode'; -import * as nls from 'vscode-nls'; +import { DiagnosticCollection, Disposable, l10n, QuickPickOptions, Uri } from 'vscode'; import { IApplicationShell, ICommandManager, IDocumentManager } from '../common/application/types'; import { Commands } from '../common/constants'; import { IDisposable } from '../common/types'; @@ -14,8 +13,6 @@ import { sendTelemetryEvent } from '../telemetry'; import { EventName } from '../telemetry/constants'; import { ILinterManager, ILintingEngine, LinterId } from './types'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - export class LinterCommands implements IDisposable { private disposables: Disposable[] = []; @@ -74,8 +71,7 @@ export class LinterCommands implements IDisposable { const index = linters.findIndex((x) => x.id === selection); if (activeLinters.length > 1) { const response = await this.appShell.showWarningMessage( - localize( - 'Linter.replaceWithSelectedLinter', + l10n.t( "Multiple linters are enabled in settings. Replace with '{0}'?", selection, ), diff --git a/src/client/tensorBoard/tensorBoardSession.ts b/src/client/tensorBoard/tensorBoardSession.ts index 345c7e1b7351..5d5b9cd1bb35 100644 --- a/src/client/tensorBoard/tensorBoardSession.ts +++ b/src/client/tensorBoard/tensorBoardSession.ts @@ -9,6 +9,7 @@ import { env, Event, EventEmitter, + l10n, Position, Progress, ProgressLocation, @@ -23,7 +24,6 @@ import { window, workspace, } from 'vscode'; -import * as nls from 'vscode-nls'; import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common/application/types'; import { createPromiseFromCancellation } from '../common/cancellation'; import { tensorboardLauncher } from '../common/process/internal/scripts'; @@ -49,8 +49,6 @@ import { IMultiStepInputFactory } from '../common/utils/multiStepInput'; import { ModuleInstallFlags } from '../common/installer/types'; import { traceError, traceInfo } from '../logging'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - enum Messages { JumpToSource = 'jump_to_source', } @@ -359,7 +357,7 @@ export class TensorBoardSession { const item = await this.applicationShell.showQuickPick(items, { canPickMany: false, ignoreFocusOut: false, - placeHolder: logDir ? localize('TensorBoard.currentDirectory', 'Current: {0}', logDir) : undefined, + placeHolder: logDir ? l10n.t('Current: {0}', logDir) : undefined, }); switch (item?.label) { case useCurrentWorkingDirectory: diff --git a/src/client/tensorBoard/tensorBoardSessionProvider.ts b/src/client/tensorBoard/tensorBoardSessionProvider.ts index 6840e3062f2c..f689dab6a6ba 100644 --- a/src/client/tensorBoard/tensorBoardSessionProvider.ts +++ b/src/client/tensorBoard/tensorBoardSessionProvider.ts @@ -2,8 +2,7 @@ // Licensed under the MIT License. import { inject, injectable } from 'inversify'; -import { ViewColumn } from 'vscode'; -import * as nls from 'vscode-nls'; +import { l10n, ViewColumn } from 'vscode'; import { IExtensionSingleActivationService } from '../activation/types'; import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common/application/types'; import { Commands } from '../common/constants'; @@ -24,8 +23,6 @@ import { EventName } from '../telemetry/constants'; import { TensorBoardEntrypoint, TensorBoardEntrypointTrigger } from './constants'; import { TensorBoardSession } from './tensorBoardSession'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - const PREFERRED_VIEWGROUP = 'PythonTensorBoardWebviewPreferredViewGroup'; @injectable() @@ -119,8 +116,7 @@ export class TensorBoardSessionProvider implements IExtensionSingleActivationSer } catch (e) { traceError(`Encountered error while starting new TensorBoard session: ${e}`); await this.applicationShell.showErrorMessage( - localize( - 'TensorBoard.failedToStartSessionError', + l10n.t( 'We failed to start a TensorBoard session due to the following error: {0}', (e as Error).message, ), diff --git a/src/client/terminals/codeExecution/helper.ts b/src/client/terminals/codeExecution/helper.ts index 6d4fbf9e92cd..f85f6d8b5d85 100644 --- a/src/client/terminals/codeExecution/helper.ts +++ b/src/client/terminals/codeExecution/helper.ts @@ -3,9 +3,8 @@ import '../../common/extensions'; import { inject, injectable } from 'inversify'; -import { Position, Range, TextEditor, Uri } from 'vscode'; +import { l10n, Position, Range, TextEditor, Uri } from 'vscode'; -import * as nls from 'vscode-nls'; import { IApplicationShell, IDocumentManager } from '../../common/application/types'; import { PYTHON_LANGUAGE } from '../../common/constants'; import * as internalScripts from '../../common/process/internal/scripts'; @@ -16,8 +15,6 @@ import { IServiceContainer } from '../../ioc/types'; import { ICodeExecutionHelper } from '../types'; import { traceError } from '../../logging'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - @injectable() export class CodeExecutionHelper implements ICodeExecutionHelper { private readonly documentManager: IDocumentManager; @@ -86,18 +83,18 @@ export class CodeExecutionHelper implements ICodeExecutionHelper { public async getFileToExecute(): Promise { const activeEditor = this.documentManager.activeTextEditor; if (!activeEditor) { - this.applicationShell.showErrorMessage(localize('documentError.Empty', 'No open file to run in terminal')); + this.applicationShell.showErrorMessage(l10n.t('No open file to run in terminal')); return undefined; } if (activeEditor.document.isUntitled) { this.applicationShell.showErrorMessage( - localize('documentError.NoSaved', 'The active file needs to be saved before it can be run'), + l10n.t('The active file needs to be saved before it can be run'), ); return undefined; } if (activeEditor.document.languageId !== PYTHON_LANGUAGE) { this.applicationShell.showErrorMessage( - localize('documentError.NotPythonFile', 'The active file is not a Python source file)'), + l10n.t('The active file is not a Python source file)'), ); return undefined; } diff --git a/src/client/testing/common/debugLauncher.ts b/src/client/testing/common/debugLauncher.ts index 0e7f5e6c5abd..36432c0bd831 100644 --- a/src/client/testing/common/debugLauncher.ts +++ b/src/client/testing/common/debugLauncher.ts @@ -1,7 +1,6 @@ import { inject, injectable, named } from 'inversify'; import * as path from 'path'; -import * as nls from 'vscode-nls'; -import { DebugConfiguration, Uri, WorkspaceFolder } from 'vscode'; +import { DebugConfiguration, l10n, Uri, WorkspaceFolder } from 'vscode'; import { IApplicationShell, IDebugService } from '../../common/application/types'; import { EXTENSION_ROOT_DIR } from '../../common/constants'; import * as internalScripts from '../../common/process/internal/scripts'; @@ -17,8 +16,6 @@ import { getConfigurationsForWorkspace } from '../../debugger/extension/configur import { getWorkspaceFolder, getWorkspaceFolders } from '../../common/vscodeApis/workspaceApis'; import { showErrorMessage } from '../../common/vscodeApis/windowApis'; -const localize: nls.LocalizeFunc = nls.loadMessageBundle(); - @injectable() export class DebugLauncher implements ITestDebugLauncher { private readonly configService: IConfigurationService; @@ -106,7 +103,7 @@ export class DebugLauncher implements ITestDebugLauncher { traceError('could not get debug config', exc); const appShell = this.serviceContainer.get(IApplicationShell); await appShell.showErrorMessage( - localize('readDebugError', 'Could not load unit test config from launch.json as it is missing a field'), + l10n.t('Could not load unit test config from launch.json as it is missing a field'), ); return []; } @@ -131,9 +128,7 @@ export class DebugLauncher implements ITestDebugLauncher { return undefined; } catch (exc) { traceError('could not get debug config', exc); - await showErrorMessage( - localize('readDebugError', 'Could not load unit test config from launch.json as it is missing a field'), - ); + await showErrorMessage(l10n.t('Could not load unit test config from launch.json as it is missing a field')); return undefined; } } diff --git a/src/setupNls.ts b/src/setupNls.ts deleted file mode 100644 index 22ece182e5ae..000000000000 --- a/src/setupNls.ts +++ /dev/null @@ -1,8 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -import * as nls from 'vscode-nls'; - -nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone }); diff --git a/types/vscode.proposed.localization.d.ts b/types/vscode.proposed.localization.d.ts new file mode 100644 index 000000000000..b103a0aed67e --- /dev/null +++ b/types/vscode.proposed.localization.d.ts @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + export namespace l10n { + /** + * A string that can be pulled out of a localization bundle if it exists. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function t(message: string, ...args: any[]): string; + /** + * A string that can be pulled out of a localization bundle if it exists. + */ + // eslint-disable-next-line @typescript-eslint/no-explicit-any + export function t(options: { message: string; args?: any[]; comment: string[] }): string; + /** + * The bundle of localized strings that have been loaded for the extension. + */ + export const bundle: { [key: string]: string } | undefined; + /** + * The URI of the localization bundle that has been loaded for the extension. + */ + export const uri: Uri | undefined; + } +} From 8ebfa28d20bfe79fcd230e4fad6b34a08244d926 Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Tue, 4 Oct 2022 21:56:46 -0700 Subject: [PATCH 02/11] prettier --- .../common/installer/productInstaller.ts | 33 ++++--------------- src/client/common/utils/localize.ts | 8 +---- .../extension/attachQuickPick/provider.ts | 7 +--- src/client/formatters/blackFormatter.ts | 4 +-- .../commands/setInterpreter.ts | 6 +--- .../configuration/pythonPathUpdaterService.ts | 4 +-- src/client/linters/linterCommands.ts | 5 +-- src/client/terminals/codeExecution/helper.ts | 8 ++--- 8 files changed, 14 insertions(+), 61 deletions(-) diff --git a/src/client/common/installer/productInstaller.ts b/src/client/common/installer/productInstaller.ts index 10e36f1ad229..526369f9e9ad 100644 --- a/src/client/common/installer/productInstaller.ts +++ b/src/client/common/installer/productInstaller.ts @@ -253,19 +253,12 @@ export class FormatterInstaller extends BaseInstaller { const yesChoice = Common.bannerLabelYes; const options = [...useOptions, Common.doNotShowAgain]; - let message = l10n.t( - 'Formatter {0} is not installed. Install?', - productName, - ); + let message = l10n.t('Formatter {0} is not installed. Install?', productName); if (this.isExecutableAModule(product, resource)) { options.splice(0, 0, yesChoice); } else { const executable = this.getExecutableNameFromSettings(product, resource); - message = l10n.t( - 'Path to the {0} formatter is invalid ({1})', - productName, - executable, - ); + message = l10n.t('Path to the {0} formatter is invalid ({1})', productName, executable); } const item = await this.appShell.showErrorMessage(message, ...options); @@ -339,11 +332,7 @@ export class LinterInstaller extends BaseInstaller { options.splice(0, 0, install); } else { const executable = this.getExecutableNameFromSettings(product, resource); - message = l10n.t( - 'Path to the {0} linter is invalid ({1})', - productName, - executable, - ); + message = l10n.t('Path to the {0} linter is invalid ({1})', productName, executable); } const response = await this.appShell.showErrorMessage(message, ...options); if (response === install) { @@ -398,19 +387,12 @@ export class TestFrameworkInstaller extends BaseInstaller { const productName = ProductNames.get(product)!; const options: string[] = []; - let message = l10n.t( - 'Test framework {0} is not installed. Install?', - productName, - ); + let message = l10n.t('Test framework {0} is not installed. Install?', productName); if (this.isExecutableAModule(product, resource)) { options.push(...[Common.bannerLabelYes, Common.bannerLabelNo]); } else { const executable = this.getExecutableNameFromSettings(product, resource); - message = l10n.t( - 'Path to the {0} test framework is invalid ({1})', - productName, - executable, - ); + message = l10n.t('Path to the {0} test framework is invalid ({1})', productName, executable); } const item = await this.appShell.showErrorMessage(message, ...options); @@ -566,10 +548,7 @@ export class DataScienceInstaller extends BaseInstaller { ): Promise { const productName = ProductNames.get(product)!; const item = await this.appShell.showErrorMessage( - l10n.t( - 'Data Science library {0} is not installed. Install?', - productName, - ), + l10n.t('Data Science library {0} is not installed. Install?', productName), Common.bannerLabelYes, Common.bannerLabelNo, ); diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index d1fbb7aec977..456ed5fd344b 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -43,14 +43,10 @@ export namespace Diagnostics { export const pylanceDefaultMessage = l10n.t( "The Python extension now includes Pylance to improve completions, code navigation, overall performance and much more! You can learn more about the update and learn how to change your language server [here](https://aka.ms/new-python-bundle).\n\nRead Pylance's license [here](https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license).", ); - export const warnSourceMaps = l10n.t( - 'Source map support is enabled in the Python Extension, this will adversely impact performance of the extension.', - ); - export const disableSourceMaps = l10n.t('Disable Source Map Support'); } export namespace Common { - export const openFolder = localize('Common.openFolder', 'Open Folder...'); + export const openFolder = l10n.t('Common.openFolder', 'Open Folder...'); export const bannerLabelYes = l10n.t('Yes'); export const bannerLabelNo = l10n.t('No'); export const yesPlease = l10n.t('Yes, please'); @@ -204,8 +200,6 @@ export namespace Interpreters { export const installPythonTerminalMessage = l10n.t( '💡 Please try installing the python package using your package manager. Alternatively you can also download it from https://www.python.org/downloads', ); - export const changePythonInterpreter = l10n.t('Change Python Interpreter'); - export const selectedPythonInterpreter = l10n.t('Selected Python Interpreter'); } export namespace InterpreterQuickPickList { diff --git a/src/client/debugger/extension/attachQuickPick/provider.ts b/src/client/debugger/extension/attachQuickPick/provider.ts index 89b197fb1f2a..3626d8dfb8ce 100644 --- a/src/client/debugger/extension/attachQuickPick/provider.ts +++ b/src/client/debugger/extension/attachQuickPick/provider.ts @@ -69,12 +69,7 @@ export class AttachProcessProvider implements IAttachProcessProvider { } else if (this.platformService.isWindows) { processCmd = WmicProcessParser.wmicCommand; } else { - throw new Error( - l10n.t( - "Operating system '{0}' not supported.", - this.platformService.osType, - ), - ); + throw new Error(l10n.t("Operating system '{0}' not supported.", this.platformService.osType)); } const processService = await this.processServiceFactory.create(); diff --git a/src/client/formatters/blackFormatter.ts b/src/client/formatters/blackFormatter.ts index 63170ecf056c..0a8109e163e0 100644 --- a/src/client/formatters/blackFormatter.ts +++ b/src/client/formatters/blackFormatter.ts @@ -37,9 +37,7 @@ export class BlackFormatter extends BaseFormatter { const shell = this.serviceContainer.get(IApplicationShell); // Black does not support partial formatting on purpose. shell - .showErrorMessage( - vscode.l10n.t('Black does not support the "Format Selection" command'), - ) + .showErrorMessage(vscode.l10n.t('Black does not support the "Format Selection" command')) .then(noop, noop); return []; } diff --git a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts index 9929cc314b90..39965adec0a0 100644 --- a/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts +++ b/src/client/interpreter/configuration/interpreterSelector/commands/setInterpreter.ts @@ -141,11 +141,7 @@ export class SetInterpreterCommand extends BaseInterpreterSelectorCommand implem const placeholder = params?.placeholder === null ? undefined - : params?.placeholder ?? - l10n.t( - 'Selected Interpreter: {0}', - currentInterpreterPathDisplay, - ); + : params?.placeholder ?? l10n.t('Selected Interpreter: {0}', currentInterpreterPathDisplay); const title = params?.title === null ? undefined : params?.title ?? InterpreterQuickPickList.browsePath.openButtonLabel; const selection = await input.showQuickPick>({ diff --git a/src/client/interpreter/configuration/pythonPathUpdaterService.ts b/src/client/interpreter/configuration/pythonPathUpdaterService.ts index 6fc1698412a4..ae2c92eada5b 100644 --- a/src/client/interpreter/configuration/pythonPathUpdaterService.ts +++ b/src/client/interpreter/configuration/pythonPathUpdaterService.ts @@ -33,9 +33,7 @@ export class PythonPathUpdaterService implements IPythonPathUpdaterServiceManage failed = true; const reason = err as Error; const message = reason && typeof reason.message === 'string' ? (reason.message as string) : ''; - window.showErrorMessage( - l10n.t('Failed to set interpreter path. Error: {0}', message), - ); + window.showErrorMessage(l10n.t('Failed to set interpreter path. Error: {0}', message)); traceError(reason); } // do not wait for this to complete diff --git a/src/client/linters/linterCommands.ts b/src/client/linters/linterCommands.ts index cc33d100103b..cc35e80f26b1 100644 --- a/src/client/linters/linterCommands.ts +++ b/src/client/linters/linterCommands.ts @@ -71,10 +71,7 @@ export class LinterCommands implements IDisposable { const index = linters.findIndex((x) => x.id === selection); if (activeLinters.length > 1) { const response = await this.appShell.showWarningMessage( - l10n.t( - "Multiple linters are enabled in settings. Replace with '{0}'?", - selection, - ), + l10n.t("Multiple linters are enabled in settings. Replace with '{0}'?", selection), Common.bannerLabelYes, Common.bannerLabelNo, ); diff --git a/src/client/terminals/codeExecution/helper.ts b/src/client/terminals/codeExecution/helper.ts index f85f6d8b5d85..d4f205883cef 100644 --- a/src/client/terminals/codeExecution/helper.ts +++ b/src/client/terminals/codeExecution/helper.ts @@ -87,15 +87,11 @@ export class CodeExecutionHelper implements ICodeExecutionHelper { return undefined; } if (activeEditor.document.isUntitled) { - this.applicationShell.showErrorMessage( - l10n.t('The active file needs to be saved before it can be run'), - ); + this.applicationShell.showErrorMessage(l10n.t('The active file needs to be saved before it can be run')); return undefined; } if (activeEditor.document.languageId !== PYTHON_LANGUAGE) { - this.applicationShell.showErrorMessage( - l10n.t('The active file is not a Python source file)'), - ); + this.applicationShell.showErrorMessage(l10n.t('The active file is not a Python source file)')); return undefined; } if (activeEditor.document.isDirty) { From 3936caf827b5028811c6a86177a453f68466b0cb Mon Sep 17 00:00:00 2001 From: Tyler Leonhardt Date: Thu, 6 Oct 2022 14:49:21 -0600 Subject: [PATCH 03/11] bump engine & types --- package-lock.json | 14 +++++++------- package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5af7c48df6f6..411c49a849f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,7 +68,7 @@ "@types/stack-trace": "0.0.29", "@types/tmp": "^0.0.33", "@types/uuid": "^8.3.4", - "@types/vscode": "~1.68.0", + "@types/vscode": "~1.72.0", "@types/which": "^2.0.1", "@types/winreg": "^1.2.30", "@types/xml2js": "^0.4.2", @@ -1134,9 +1134,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.68.1", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.1.tgz", - "integrity": "sha512-fXlaq13NT5yHh6yZ3c+UxXloTSk34mIvsNFYyQCeO5Po2BLFAwz7EZT4kQ43B64/aPcnAenyWy3QasrTofBOnQ==", + "version": "1.72.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.72.0.tgz", + "integrity": "sha512-WvHluhUo+lQvE3I4wUagRpnkHuysB4qSyOQUyIAS9n9PYMJjepzTUD8Jyks0YeXoPD0UGctjqp2u84/b3v6Ydw==", "dev": true }, "node_modules/@types/which": { @@ -16318,9 +16318,9 @@ "dev": true }, "@types/vscode": { - "version": "1.68.1", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.68.1.tgz", - "integrity": "sha512-fXlaq13NT5yHh6yZ3c+UxXloTSk34mIvsNFYyQCeO5Po2BLFAwz7EZT4kQ43B64/aPcnAenyWy3QasrTofBOnQ==", + "version": "1.72.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.72.0.tgz", + "integrity": "sha512-WvHluhUo+lQvE3I4wUagRpnkHuysB4qSyOQUyIAS9n9PYMJjepzTUD8Jyks0YeXoPD0UGctjqp2u84/b3v6Ydw==", "dev": true }, "@types/which": { diff --git a/package.json b/package.json index 8deb663d1889..0d2cd3c17fa3 100644 --- a/package.json +++ b/package.json @@ -1865,7 +1865,7 @@ "@types/stack-trace": "0.0.29", "@types/tmp": "^0.0.33", "@types/uuid": "^8.3.4", - "@types/vscode": "~1.68.0", + "@types/vscode": "~1.72.0", "@types/which": "^2.0.1", "@types/winreg": "^1.2.30", "@types/xml2js": "^0.4.2", From 98db8d389369975a380a4a65f5e205ddd91052d5 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Mon, 9 Jan 2023 15:24:41 -0500 Subject: [PATCH 04/11] Fix merge --- src/client/common/utils/localize.ts | 20 +++++++++++-------- .../debugger/extension/adapter/factory.ts | 5 +---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index 456ed5fd344b..caef57eeace7 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -9,6 +9,11 @@ import { l10n } from 'vscode'; // External callers of localize use these tables to retrieve localized values. export namespace Diagnostics { + export const warnSourceMaps = l10n.t( + 'Source map support is enabled in the Python Extension, this will adversely impact performance of the extension.', + ); + export const disableSourceMaps = l10n.t('Disable Source Map Support'); + export const warnBeforeEnablingSourceMaps = l10n.t( 'Enabling source map support in the Python Extension will adversely impact performance of the extension.', ); @@ -16,9 +21,6 @@ export namespace Diagnostics { export const lsNotSupported = l10n.t( 'Your operating system does not meet the minimum requirements of the Python Language Server. Reverting to the alternative autocompletion provider, Jedi.', ); - export const removedPythonPathFromSettings = l10n.t( - 'The "python.pythonPath" setting in your settings.json is no longer used by the Python extension. If you want, you can use a new setting called "python.defaultInterpreterPath" instead. Keep in mind that you need to change the value of this setting manually as the Python extension doesn\'t modify it when you change interpreters. [Learn more](https://aka.ms/AA7jfor).', - ); export const invalidPythonPathInDebuggerSettings = l10n.t( 'You need to select a Python interpreter before you start debugging.\n\nTip: click on "Select Interpreter" in the status bar.', ); @@ -46,7 +48,6 @@ export namespace Diagnostics { } export namespace Common { - export const openFolder = l10n.t('Common.openFolder', 'Open Folder...'); export const bannerLabelYes = l10n.t('Yes'); export const bannerLabelNo = l10n.t('No'); export const yesPlease = l10n.t('Yes, please'); @@ -75,6 +76,7 @@ export namespace Common { export const useCommandPrompt = l10n.t('Use Command Prompt'); export const download = l10n.t('Download'); export const showLogs = l10n.t('Show logs'); + export const openFolder = l10n.t('Common.openFolder', 'Open Folder...'); } export namespace CommonSurvey { @@ -200,6 +202,8 @@ export namespace Interpreters { export const installPythonTerminalMessage = l10n.t( '💡 Please try installing the python package using your package manager. Alternatively you can also download it from https://www.python.org/downloads', ); + export const changePythonInterpreter = l10n.t('Change Python Interpreter'); + export const selectedPythonInterpreter = l10n.t('Selected Python Interpreter'); } export namespace InterpreterQuickPickList { @@ -449,14 +453,14 @@ export namespace CreateEnv { } export namespace ToolsExtensions { - export const flake8PromptMessage = localize( + export const flake8PromptMessage = l10n.t( 'toolsExt.flake8.message', 'Use the Flake8 extension to enable easier configuration and new features such as quick fixes.', ); - export const pylintPromptMessage = localize( + export const pylintPromptMessage = l10n.t( 'toolsExt.pylint.message', 'Use the Pylint extension to enable easier configuration and new features such as quick fixes.', ); - export const installPylintExtension = localize('toolsExt.install.pylint', 'Install Pylint extension'); - export const installFlake8Extension = localize('toolsExt.install.flake8', 'Install Flake8 extension'); + export const installPylintExtension = l10n.t('toolsExt.install.pylint', 'Install Pylint extension'); + export const installFlake8Extension = l10n.t('toolsExt.install.flake8', 'Install Flake8 extension'); } diff --git a/src/client/debugger/extension/adapter/factory.ts b/src/client/debugger/extension/adapter/factory.ts index 316c2d382a4c..ab440ddbe227 100644 --- a/src/client/debugger/extension/adapter/factory.ts +++ b/src/client/debugger/extension/adapter/factory.ts @@ -163,10 +163,7 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac } const prompts = [Interpreters.changePythonInterpreter, Common.doNotShowAgain]; const selection = await showErrorMessage( - localize( - 'Debug.deprecatedDebuggerError', - 'The debugger in the python extension no longer supports python versions minor than 3.7.', - ), + l10n.t('The debugger in the python extension no longer supports python versions minor than 3.7.'), { modal: true }, ...prompts, ); From 88be869432caf14aaebe3ea69ec6a102709ec237 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Tue, 10 Jan 2023 11:07:42 -0500 Subject: [PATCH 05/11] Fix localize file --- src/client/common/utils/localize.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/common/utils/localize.ts b/src/client/common/utils/localize.ts index caef57eeace7..9928a15194e7 100644 --- a/src/client/common/utils/localize.ts +++ b/src/client/common/utils/localize.ts @@ -76,7 +76,7 @@ export namespace Common { export const useCommandPrompt = l10n.t('Use Command Prompt'); export const download = l10n.t('Download'); export const showLogs = l10n.t('Show logs'); - export const openFolder = l10n.t('Common.openFolder', 'Open Folder...'); + export const openFolder = l10n.t('Open Folder...'); } export namespace CommonSurvey { From f682c5c535d59f34ad327866bdfdf8803b3b52a6 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 11 Jan 2023 10:55:04 -0500 Subject: [PATCH 06/11] fix lint --- src/test/mocks/vsc/extHostedTypes.ts | 201 ++++++++++++++++++++++++--- src/test/mocks/vsc/index.ts | 2 + 2 files changed, 180 insertions(+), 23 deletions(-) diff --git a/src/test/mocks/vsc/extHostedTypes.ts b/src/test/mocks/vsc/extHostedTypes.ts index bb60cfd0c698..ff2dc230f1ea 100644 --- a/src/test/mocks/vsc/extHostedTypes.ts +++ b/src/test/mocks/vsc/extHostedTypes.ts @@ -6,15 +6,16 @@ 'use strict'; +import { isNumber } from 'lodash'; import { relative } from 'path'; -import type * as vscode from 'vscode'; +import * as vscode from 'vscode'; import * as vscMockHtmlContent from './htmlContent'; import * as vscMockStrings from './strings'; import * as vscUri from './uri'; import { generateUuid } from './uuid'; export enum NotebookCellKind { - Markdown = 1, + Markup = 1, Code = 2, } @@ -237,6 +238,121 @@ export class Position { } } +export class NotebookCellOutputItem { + static text(value: any, mime?: string): NotebookCellOutputItem { + return mime ? new NotebookCellOutputItem(value, mime) : new NotebookCellOutputItem(value, ''); + } + + static json(value: any, mime?: string): NotebookCellOutputItem { + return mime ? new NotebookCellOutputItem(value, mime) : new NotebookCellOutputItem(value, ''); + } + + static stdout(value: any): NotebookCellOutputItem { + return new NotebookCellOutputItem(value, ''); + } + + static stderr(value: any): NotebookCellOutputItem { + return new NotebookCellOutputItem(value, ''); + } + + static error(value: any): NotebookCellOutputItem { + return new NotebookCellOutputItem(value, ''); + } + + mime: string; + + data: Uint8Array; + + constructor(data: Uint8Array, mime: string) { + this.data = data; + this.mime = mime; + } +} + +export class NotebookCellOutput implements vscode.NotebookCellOutput { + items: NotebookCellOutputItem[]; + + metadata?: { [key: string]: any }; + + constructor(items: NotebookCellOutputItem[], metadata?: { [key: string]: any }) { + this.items = items; + this.metadata = metadata; + } +} + +export interface NotebookCellExecutionSummary { + readonly executionOrder?: number; + readonly success?: boolean; + readonly timing?: { readonly startTime: number; readonly endTime: number }; +} + +export class NotebookCellData implements vscode.NotebookCellData { + kind: NotebookCellKind; + + value: string; + + languageId: string; + + outputs?: NotebookCellOutput[]; + + metadata?: { [key: string]: any }; + + executionSummary?: NotebookCellExecutionSummary; + + constructor(kind: NotebookCellKind, value: string, languageId: string) { + this.kind = kind; + this.value = value; + this.languageId = languageId; + } +} + +export class NotebookRange implements vscode.NotebookRange { + readonly start: number; + + readonly end: number; + + readonly isEmpty: boolean = false; + + constructor(start: number, end: number) { + this.start = start; + this.end = end; + if (end === start) { + this.isEmpty = true; + } + } + + with(change: { start?: number; end?: number }) { + if (change.start === null || change.end === null) { + throw illegalArgument(); + } + + let start: number; + + if (!change.start) { + start = this.start; + } else if (isNumber(change.start)) { + start = change.start; + } else { + start = change.start || this.start; + } + + let end: number; + if (!change.end) { + end = this.end; + } else if (isNumber(change.end)) { + end = change.end; + } else { + end = change.end || this.end; + } + + if (start === this.start && end === this.end) { + return this; + } + + return new NotebookRange(start, end); + } +} + export class Range { static isRange(thing: unknown): thing is vscode.Range { if (thing instanceof Range) { @@ -464,6 +580,45 @@ export enum EndOfLine { CRLF = 2, } +// export class NotebookEdit implements vscode.NotebookEdit { +// static replaceCells(range: NotebookRange, newCells: NotebookCellData[]) { +// return new NotebookEdit(range, newCells); +// } + +// static insertCells(index: number, newCells: NotebookCellData[]) { +// return NotebookEdit.replaceCells(new NotebookRange(index, index), newCells); +// } + +// static deleteCells(range: NotebookRange) { +// return NotebookEdit.replaceCells(range, [new NotebookCellData(NotebookCellKind.Code, '', '')]); +// } + +// static updateCellMetadata(index: number, newCellMetadata: { [key: string]: any }) { +// const notebookEdit = NotebookEdit.replaceCells(new NotebookRange(index, index), []); +// notebookEdit.newCellMetadata = newCellMetadata; +// return notebookEdit; +// } + +// static updateNotebookMetadata(newNotebookMetadata: { [key: string]: any }) { +// const notebookEdit = NotebookEdit.replaceCells(new NotebookRange(0, 0), []); +// notebookEdit.newCellMetadata = newNotebookMetadata; +// return notebookEdit; +// } + +// range: NotebookRange; + +// newCells: NotebookCellData[]; + +// newCellMetadata?: { [key: string]: any }; + +// newNotebookMetadata?: { [key: string]: any }; + +// constructor(range: NotebookRange, newCells: NotebookCellData[]) { +// this.range = range; +// this.newCells = newCells; +// } +// } + export class TextEdit { static isTextEdit(thing: unknown): thing is TextEdit { if (thing instanceof TextEdit) { @@ -493,11 +648,11 @@ export class TextEdit { return ret; } - protected _range: Range = new Range(new Position(0, 0), new Position(0, 0)); + _range: Range = new Range(new Position(0, 0), new Position(0, 0)); - protected _newText = ''; + newText = ''; - protected _newEol: EndOfLine = EndOfLine.LF; + _newEol: EndOfLine = EndOfLine.LF; get range(): Range { return this._range; @@ -510,16 +665,16 @@ export class TextEdit { this._range = value; } - get newText(): string { - return this._newText || ''; - } + // get newText(): string { + // return this._newText || ''; + // } - set newText(value: string) { - if (value && typeof value !== 'string') { - throw illegalArgument('newText'); - } - this._newText = value; - } + // set newText(value: string) { + // if (value && typeof value !== 'string') { + // throw illegalArgument('newText'); + // } + // this._newText = value; + // } get newEol(): EndOfLine { return this._newEol; @@ -537,13 +692,13 @@ export class TextEdit { this.newText = newText; } - toJSON(): { range: Range; newText: string; newEol: EndOfLine } { - return { - range: this.range, - newText: this.newText, - newEol: this._newEol, - }; - } + // toJSON(): { range: Range; newText: string; newEol: EndOfLine } { + // return { + // range: this.range, + // newText: this.newText, + // newEol: this.newEol, + // }; + // } } export class WorkspaceEdit implements vscode.WorkspaceEdit { @@ -664,7 +819,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit { return this._textEdits.has(uri.toString()); } - set(uri: vscUri.URI, edits: TextEdit[]): void { + set(uri: vscUri.URI, edits: unknown[]): void { let data = this._textEdits.get(uri.toString()); if (!data) { data = { seq: this._seqPool += 1, uri, edits: [] }; @@ -673,7 +828,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit { if (!edits) { data.edits = []; } else { - data.edits = edits.slice(0); + data.edits = edits.slice(0) as TextEdit[]; } } diff --git a/src/test/mocks/vsc/index.ts b/src/test/mocks/vsc/index.ts index bbd3d23091b1..df15759206c9 100644 --- a/src/test/mocks/vsc/index.ts +++ b/src/test/mocks/vsc/index.ts @@ -302,6 +302,8 @@ export class CodeActionKind { public static readonly RefactorInline: CodeActionKind = new CodeActionKind('refactor.inline'); + public static readonly RefactorMove: CodeActionKind = new CodeActionKind('refactor.move'); + public static readonly RefactorRewrite: CodeActionKind = new CodeActionKind('refactor.rewrite'); public static readonly Source: CodeActionKind = new CodeActionKind('source'); From 60fda9e6acb99ae9f4013b70736c63ac5baac65f Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 11 Jan 2023 11:26:54 -0500 Subject: [PATCH 07/11] Add i10n mock --- src/test/vscode-mock.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/vscode-mock.ts b/src/test/vscode-mock.ts index 8e1f319bee08..2a4fcd1f3b94 100644 --- a/src/test/vscode-mock.ts +++ b/src/test/vscode-mock.ts @@ -38,6 +38,7 @@ export function initialize() { generateMock('env'); generateMock('debug'); generateMock('scm'); + generateMock('l10n'); generateNotebookMocks(); // Use mock clipboard fo testing purposes. From f4bb6a6cf6337ead8cbc378cac77b774daa1a0de Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 11 Jan 2023 13:01:40 -0500 Subject: [PATCH 08/11] Fix new vscode --- package-lock.json | 47 +++++++++++++++---------- package.json | 10 +++--- src/test/mocks/vsc/extHostedTypes.ts | 13 +++---- types/vscode.proposed.localization.d.ts | 27 -------------- 4 files changed, 39 insertions(+), 58 deletions(-) delete mode 100644 types/vscode.proposed.localization.d.ts diff --git a/package-lock.json b/package-lock.json index 411c49a849f4..63f798cb2d6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,7 +68,7 @@ "@types/stack-trace": "0.0.29", "@types/tmp": "^0.0.33", "@types/uuid": "^8.3.4", - "@types/vscode": "~1.72.0", + "@types/vscode": "^1.74.0", "@types/which": "^2.0.1", "@types/winreg": "^1.2.30", "@types/xml2js": "^0.4.2", @@ -1134,9 +1134,9 @@ "dev": true }, "node_modules/@types/vscode": { - "version": "1.72.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.72.0.tgz", - "integrity": "sha512-WvHluhUo+lQvE3I4wUagRpnkHuysB4qSyOQUyIAS9n9PYMJjepzTUD8Jyks0YeXoPD0UGctjqp2u84/b3v6Ydw==", + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.74.0.tgz", + "integrity": "sha512-LyeCIU3jb9d38w0MXFwta9r0Jx23ugujkAxdwLTNCyspdZTKUc43t7ppPbCiPoQ/Ivd/pnDFZrb4hWd45wrsgA==", "dev": true }, "node_modules/@types/which": { @@ -16318,9 +16318,9 @@ "dev": true }, "@types/vscode": { - "version": "1.72.0", - "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.72.0.tgz", - "integrity": "sha512-WvHluhUo+lQvE3I4wUagRpnkHuysB4qSyOQUyIAS9n9PYMJjepzTUD8Jyks0YeXoPD0UGctjqp2u84/b3v6Ydw==", + "version": "1.74.0", + "resolved": "https://registry.npmjs.org/@types/vscode/-/vscode-1.74.0.tgz", + "integrity": "sha512-LyeCIU3jb9d38w0MXFwta9r0Jx23ugujkAxdwLTNCyspdZTKUc43t7ppPbCiPoQ/Ivd/pnDFZrb4hWd45wrsgA==", "dev": true }, "@types/which": { @@ -16657,7 +16657,8 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.1.1.tgz", "integrity": "sha512-1FBc1f9G4P/AxMqIgfZgeOTuRnwZMten8E7zap5zgpPInnCrP8D4Q81+4CWIch8i/Nf7nXjP0v6CjjbHOrXhKg==", - "dev": true + "dev": true, + "requires": {} }, "@webpack-cli/info": { "version": "1.4.1", @@ -16672,7 +16673,8 @@ "version": "1.6.1", "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.6.1.tgz", "integrity": "sha512-gNGTiTrjEVQ0OcVnzsRSqTxaBSr+dmTfm+qJsCDluky8uhdLWep7Gcr62QsAKHTMxjCS/8nEITsmFAhfIx+QSw==", - "dev": true + "dev": true, + "requires": {} }, "@xtuc/ieee754": { "version": "1.2.0", @@ -16696,13 +16698,15 @@ "version": "1.8.0", "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", - "dev": true + "dev": true, + "requires": {} }, "acorn-jsx": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true + "dev": true, + "requires": {} }, "acorn-walk": { "version": "8.2.0", @@ -16735,7 +16739,8 @@ "version": "3.5.2", "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", - "dev": true + "dev": true, + "requires": {} }, "ansi-colors": { "version": "1.1.0", @@ -18832,7 +18837,8 @@ "diagnostic-channel-publishers": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/diagnostic-channel-publishers/-/diagnostic-channel-publishers-1.0.5.tgz", - "integrity": "sha512-dJwUS0915pkjjimPJVDnS/QQHsH0aOYhnZsLJdnZIMOrB+csj8RnZhWTuwnm8R5v3Z7OZs+ksv5luC14DGB7eg==" + "integrity": "sha512-dJwUS0915pkjjimPJVDnS/QQHsH0aOYhnZsLJdnZIMOrB+csj8RnZhWTuwnm8R5v3Z7OZs+ksv5luC14DGB7eg==", + "requires": {} }, "diff": { "version": "4.0.2", @@ -19488,7 +19494,8 @@ "version": "8.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", - "dev": true + "dev": true, + "requires": {} }, "eslint-import-resolver-node": { "version": "0.3.6", @@ -19713,7 +19720,8 @@ "version": "4.4.0", "resolved": "https://registry.npmjs.org/eslint-plugin-react-hooks/-/eslint-plugin-react-hooks-4.4.0.tgz", "integrity": "sha512-U3RVIfdzJaeKDQKEJbz5p3NW8/L80PCATJAfuojwbaEL+gBjfGdhUcGde+WGUW46Q5sr/NgxevsIiDtNXrvZaQ==", - "dev": true + "dev": true, + "requires": {} }, "eslint-scope": { "version": "5.1.1", @@ -19938,7 +19946,8 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/expose-loader/-/expose-loader-3.1.0.tgz", "integrity": "sha512-2RExSo0yJiqP+xiUue13jQa2IHE8kLDzTI7b6kn+vUlBVvlzNSiLDzo4e5Pp5J039usvTUnxZ8sUOhv0Kg15NA==", - "dev": true + "dev": true, + "requires": {} }, "ext": { "version": "1.6.0", @@ -27156,7 +27165,8 @@ "version": "1.8.6", "resolved": "https://registry.npmjs.org/webpack-require-from/-/webpack-require-from-1.8.6.tgz", "integrity": "sha512-QmRsOkOYPKeNXp4uVc7qxnPrFQPrP4bhOc/gl4QenTFNgXdEbF1U8VC+jM/Sljb0VzJLNgyNiHlVkuHjcmDtBQ==", - "dev": true + "dev": true, + "requires": {} }, "webpack-sources": { "version": "3.2.3", @@ -27326,7 +27336,8 @@ "version": "7.5.7", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.7.tgz", "integrity": "sha512-KMvVuFzpKBuiIXW3E4u3mySRO2/mCHSyZDJQM5NQ9Q9KHWHWh0NHgfbRMLLrceUK5qAL4ytALJbpRMjixFZh8A==", - "dev": true + "dev": true, + "requires": {} }, "xml": { "version": "1.0.1", diff --git a/package.json b/package.json index 0d2cd3c17fa3..b29435cbf71a 100644 --- a/package.json +++ b/package.json @@ -1806,8 +1806,8 @@ "webpack": "webpack" }, "dependencies": { - "@vscode/jupyter-lsp-middleware": "^0.2.50", "@vscode/extension-telemetry": "^0.7.4-preview", + "@vscode/jupyter-lsp-middleware": "^0.2.50", "arch": "^2.1.0", "diff-match-patch": "^1.0.0", "fs-extra": "^10.0.1", @@ -1826,8 +1826,8 @@ "request-progress": "^3.0.0", "rxjs": "^6.5.4", "rxjs-compat": "^6.5.4", - "stack-trace": "0.0.10", "semver": "^5.5.0", + "stack-trace": "0.0.10", "sudo-prompt": "^9.2.1", "tmp": "^0.0.33", "uint64be": "^3.0.0", @@ -1840,9 +1840,9 @@ "vscode-languageserver": "8.0.2-next.5", "vscode-languageserver-protocol": "3.17.2-next.6", "vscode-tas-client": "^0.1.63", + "which": "^2.0.2", "winreg": "^1.2.4", - "xml2js": "^0.4.19", - "which": "^2.0.2" + "xml2js": "^0.4.19" }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.2", @@ -1865,7 +1865,7 @@ "@types/stack-trace": "0.0.29", "@types/tmp": "^0.0.33", "@types/uuid": "^8.3.4", - "@types/vscode": "~1.72.0", + "@types/vscode": "^1.74.0", "@types/which": "^2.0.1", "@types/winreg": "^1.2.30", "@types/xml2js": "^0.4.2", diff --git a/src/test/mocks/vsc/extHostedTypes.ts b/src/test/mocks/vsc/extHostedTypes.ts index ff2dc230f1ea..91b036e3951e 100644 --- a/src/test/mocks/vsc/extHostedTypes.ts +++ b/src/test/mocks/vsc/extHostedTypes.ts @@ -819,7 +819,7 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit { return this._textEdits.has(uri.toString()); } - set(uri: vscUri.URI, edits: unknown[]): void { + set(uri: vscUri.URI, edits: readonly unknown[]): void { let data = this._textEdits.get(uri.toString()); if (!data) { data = { seq: this._seqPool += 1, uri, edits: [] }; @@ -1067,20 +1067,17 @@ export class Diagnostic { } } -export class Hover { - public contents: vscode.MarkdownString[] | vscode.MarkedString[]; +export class Hover implements vscode.Hover { + public contents: vscode.MarkdownString[]; public range: Range; - constructor( - contents: vscode.MarkdownString | vscode.MarkedString | vscode.MarkdownString[] | vscode.MarkedString[], - range?: Range, - ) { + constructor(contents: vscode.MarkdownString | vscode.MarkdownString[], range?: Range) { if (!contents) { throw new Error('Illegal argument, contents must be defined'); } if (Array.isArray(contents)) { - this.contents = contents; + this.contents = contents; } else if (vscMockHtmlContent.isMarkdownString(contents)) { this.contents = [contents]; } else { diff --git a/types/vscode.proposed.localization.d.ts b/types/vscode.proposed.localization.d.ts deleted file mode 100644 index b103a0aed67e..000000000000 --- a/types/vscode.proposed.localization.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -declare module 'vscode' { - export namespace l10n { - /** - * A string that can be pulled out of a localization bundle if it exists. - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - export function t(message: string, ...args: any[]): string; - /** - * A string that can be pulled out of a localization bundle if it exists. - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - export function t(options: { message: string; args?: any[]; comment: string[] }): string; - /** - * The bundle of localized strings that have been loaded for the extension. - */ - export const bundle: { [key: string]: string } | undefined; - /** - * The URI of the localization bundle that has been loaded for the extension. - */ - export const uri: Uri | undefined; - } -} From 8ada33b4ad33d48427f3d78cede1896fdff5bc5a Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 11 Jan 2023 15:13:39 -0500 Subject: [PATCH 09/11] Fix code --- .../debugger/extension/adapter/factory.ts | 4 +- src/test/mocks/vsc/extHostedTypes.ts | 174 ------------------ 2 files changed, 1 insertion(+), 177 deletions(-) diff --git a/src/client/debugger/extension/adapter/factory.ts b/src/client/debugger/extension/adapter/factory.ts index ab440ddbe227..fc9232729eae 100644 --- a/src/client/debugger/extension/adapter/factory.ts +++ b/src/client/debugger/extension/adapter/factory.ts @@ -200,8 +200,6 @@ export class DebugAdapterDescriptorFactory implements IDebugAdapterDescriptorFac * @memberof DebugAdapterDescriptorFactory */ private async notifySelectInterpreter() { - await showErrorMessage( - l10n.t('interpreterError', 'Please install Python or select a Python Interpreter to use the debugger.'), - ); + await showErrorMessage(l10n.t('Please install Python or select a Python Interpreter to use the debugger.')); } } diff --git a/src/test/mocks/vsc/extHostedTypes.ts b/src/test/mocks/vsc/extHostedTypes.ts index 91b036e3951e..22660e37dc7c 100644 --- a/src/test/mocks/vsc/extHostedTypes.ts +++ b/src/test/mocks/vsc/extHostedTypes.ts @@ -6,7 +6,6 @@ 'use strict'; -import { isNumber } from 'lodash'; import { relative } from 'path'; import * as vscode from 'vscode'; import * as vscMockHtmlContent from './htmlContent'; @@ -238,121 +237,6 @@ export class Position { } } -export class NotebookCellOutputItem { - static text(value: any, mime?: string): NotebookCellOutputItem { - return mime ? new NotebookCellOutputItem(value, mime) : new NotebookCellOutputItem(value, ''); - } - - static json(value: any, mime?: string): NotebookCellOutputItem { - return mime ? new NotebookCellOutputItem(value, mime) : new NotebookCellOutputItem(value, ''); - } - - static stdout(value: any): NotebookCellOutputItem { - return new NotebookCellOutputItem(value, ''); - } - - static stderr(value: any): NotebookCellOutputItem { - return new NotebookCellOutputItem(value, ''); - } - - static error(value: any): NotebookCellOutputItem { - return new NotebookCellOutputItem(value, ''); - } - - mime: string; - - data: Uint8Array; - - constructor(data: Uint8Array, mime: string) { - this.data = data; - this.mime = mime; - } -} - -export class NotebookCellOutput implements vscode.NotebookCellOutput { - items: NotebookCellOutputItem[]; - - metadata?: { [key: string]: any }; - - constructor(items: NotebookCellOutputItem[], metadata?: { [key: string]: any }) { - this.items = items; - this.metadata = metadata; - } -} - -export interface NotebookCellExecutionSummary { - readonly executionOrder?: number; - readonly success?: boolean; - readonly timing?: { readonly startTime: number; readonly endTime: number }; -} - -export class NotebookCellData implements vscode.NotebookCellData { - kind: NotebookCellKind; - - value: string; - - languageId: string; - - outputs?: NotebookCellOutput[]; - - metadata?: { [key: string]: any }; - - executionSummary?: NotebookCellExecutionSummary; - - constructor(kind: NotebookCellKind, value: string, languageId: string) { - this.kind = kind; - this.value = value; - this.languageId = languageId; - } -} - -export class NotebookRange implements vscode.NotebookRange { - readonly start: number; - - readonly end: number; - - readonly isEmpty: boolean = false; - - constructor(start: number, end: number) { - this.start = start; - this.end = end; - if (end === start) { - this.isEmpty = true; - } - } - - with(change: { start?: number; end?: number }) { - if (change.start === null || change.end === null) { - throw illegalArgument(); - } - - let start: number; - - if (!change.start) { - start = this.start; - } else if (isNumber(change.start)) { - start = change.start; - } else { - start = change.start || this.start; - } - - let end: number; - if (!change.end) { - end = this.end; - } else if (isNumber(change.end)) { - end = change.end; - } else { - end = change.end || this.end; - } - - if (start === this.start && end === this.end) { - return this; - } - - return new NotebookRange(start, end); - } -} - export class Range { static isRange(thing: unknown): thing is vscode.Range { if (thing instanceof Range) { @@ -580,45 +464,6 @@ export enum EndOfLine { CRLF = 2, } -// export class NotebookEdit implements vscode.NotebookEdit { -// static replaceCells(range: NotebookRange, newCells: NotebookCellData[]) { -// return new NotebookEdit(range, newCells); -// } - -// static insertCells(index: number, newCells: NotebookCellData[]) { -// return NotebookEdit.replaceCells(new NotebookRange(index, index), newCells); -// } - -// static deleteCells(range: NotebookRange) { -// return NotebookEdit.replaceCells(range, [new NotebookCellData(NotebookCellKind.Code, '', '')]); -// } - -// static updateCellMetadata(index: number, newCellMetadata: { [key: string]: any }) { -// const notebookEdit = NotebookEdit.replaceCells(new NotebookRange(index, index), []); -// notebookEdit.newCellMetadata = newCellMetadata; -// return notebookEdit; -// } - -// static updateNotebookMetadata(newNotebookMetadata: { [key: string]: any }) { -// const notebookEdit = NotebookEdit.replaceCells(new NotebookRange(0, 0), []); -// notebookEdit.newCellMetadata = newNotebookMetadata; -// return notebookEdit; -// } - -// range: NotebookRange; - -// newCells: NotebookCellData[]; - -// newCellMetadata?: { [key: string]: any }; - -// newNotebookMetadata?: { [key: string]: any }; - -// constructor(range: NotebookRange, newCells: NotebookCellData[]) { -// this.range = range; -// this.newCells = newCells; -// } -// } - export class TextEdit { static isTextEdit(thing: unknown): thing is TextEdit { if (thing instanceof TextEdit) { @@ -665,17 +510,6 @@ export class TextEdit { this._range = value; } - // get newText(): string { - // return this._newText || ''; - // } - - // set newText(value: string) { - // if (value && typeof value !== 'string') { - // throw illegalArgument('newText'); - // } - // this._newText = value; - // } - get newEol(): EndOfLine { return this._newEol; } @@ -691,14 +525,6 @@ export class TextEdit { this.range = range; this.newText = newText; } - - // toJSON(): { range: Range; newText: string; newEol: EndOfLine } { - // return { - // range: this.range, - // newText: this.newText, - // newEol: this.newEol, - // }; - // } } export class WorkspaceEdit implements vscode.WorkspaceEdit { From ce0ef6e263a6f62c724c29479a0118f17865b167 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 11 Jan 2023 18:19:16 -0500 Subject: [PATCH 10/11] Fix unit tests --- src/test/mocks/vsc/extHostedTypes.ts | 2 +- src/test/mocks/vsc/index.ts | 28 ++++++++++++++++++++++++++++ src/test/vscode-mock.ts | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/test/mocks/vsc/extHostedTypes.ts b/src/test/mocks/vsc/extHostedTypes.ts index 22660e37dc7c..4921b24629d1 100644 --- a/src/test/mocks/vsc/extHostedTypes.ts +++ b/src/test/mocks/vsc/extHostedTypes.ts @@ -893,7 +893,7 @@ export class Diagnostic { } } -export class Hover implements vscode.Hover { +export class Hover { public contents: vscode.MarkdownString[]; public range: Range; diff --git a/src/test/mocks/vsc/index.ts b/src/test/mocks/vsc/index.ts index df15759206c9..7d7c2c6d269e 100644 --- a/src/test/mocks/vsc/index.ts +++ b/src/test/mocks/vsc/index.ts @@ -62,6 +62,34 @@ export class Disposable { } } +// eslint-disable-next-line @typescript-eslint/no-namespace +export namespace l10n { + export function t(message: string, ...args: unknown[]): string; + export function t(options: { + message: string; + args?: Array | Record; + comment: string | string[]; + }): string; + + export function t( + message: + | string + | { + message: string; + args?: Array | Record; + comment: string | string[]; + }, + ...args: unknown[] + ): string { + if (args) { + return (message as string).format(...(args as Array)) as string; + } + return message as string; + } + export const bundle: { [key: string]: string } | undefined = undefined; + export const uri: vscode.Uri | undefined = undefined; +} + export class EventEmitter implements vscode.EventEmitter { public event: vscode.Event; diff --git a/src/test/vscode-mock.ts b/src/test/vscode-mock.ts index 2a4fcd1f3b94..9fb4bbec329b 100644 --- a/src/test/vscode-mock.ts +++ b/src/test/vscode-mock.ts @@ -38,7 +38,6 @@ export function initialize() { generateMock('env'); generateMock('debug'); generateMock('scm'); - generateMock('l10n'); generateNotebookMocks(); // Use mock clipboard fo testing purposes. @@ -64,6 +63,7 @@ export function initialize() { } mockedVSCode.ThemeIcon = vscodeMocks.ThemeIcon; +mockedVSCode.l10n = vscodeMocks.l10n; mockedVSCode.ThemeColor = vscodeMocks.ThemeColor; mockedVSCode.MarkdownString = vscodeMocks.MarkdownString; mockedVSCode.Hover = vscodeMocks.Hover; From 334f8bb41ed02f6b631acbefed66d24be3ff9d72 Mon Sep 17 00:00:00 2001 From: Paula Camargo Date: Wed, 11 Jan 2023 18:26:42 -0500 Subject: [PATCH 11/11] Fix time --- src/test/mocks/vsc/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/mocks/vsc/index.ts b/src/test/mocks/vsc/index.ts index 7d7c2c6d269e..986e81d85f3f 100644 --- a/src/test/mocks/vsc/index.ts +++ b/src/test/mocks/vsc/index.ts @@ -67,7 +67,7 @@ export namespace l10n { export function t(message: string, ...args: unknown[]): string; export function t(options: { message: string; - args?: Array | Record; + args?: Array | Record; comment: string | string[]; }): string; @@ -76,7 +76,7 @@ export namespace l10n { | string | { message: string; - args?: Array | Record; + args?: Array | Record; comment: string | string[]; }, ...args: unknown[]