Skip to content

Commit

Permalink
onboard built-in debug extensions to l10n (#166300)
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerLeonhardt authored Nov 14, 2022
1 parent 0537f30 commit fd7e27f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 57 deletions.
3 changes: 0 additions & 3 deletions extensions/debug-auto-launch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@
}
]
},
"dependencies": {
"vscode-nls": "^5.2.0"
},
"devDependencies": {
"@types/node": "16.x"
},
Expand Down
55 changes: 19 additions & 36 deletions extensions/debug-auto-launch/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,54 +6,37 @@
import { promises as fs } from 'fs';
import { createServer, Server } from 'net';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';

const enum State {
Disabled = 'disabled',
OnlyWithFlag = 'onlyWithFlag',
Smart = 'smart',
Always = 'always',
}
const localize = nls.loadMessageBundle();
const TEXT_STATUSBAR_LABEL = {
[State.Disabled]: localize('status.text.auto.attach.disabled', 'Auto Attach: Disabled'),
[State.Always]: localize('status.text.auto.attach.always', 'Auto Attach: Always'),
[State.Smart]: localize('status.text.auto.attach.smart', 'Auto Attach: Smart'),
[State.OnlyWithFlag]: localize('status.text.auto.attach.withFlag', 'Auto Attach: With Flag'),
[State.Disabled]: vscode.l10n.t('Auto Attach: Disabled'),
[State.Always]: vscode.l10n.t('Auto Attach: Always'),
[State.Smart]: vscode.l10n.t('Auto Attach: Smart'),
[State.OnlyWithFlag]: vscode.l10n.t('Auto Attach: With Flag'),
};

const TEXT_STATE_LABEL = {
[State.Disabled]: localize('debug.javascript.autoAttach.disabled.label', 'Disabled'),
[State.Always]: localize('debug.javascript.autoAttach.always.label', 'Always'),
[State.Smart]: localize('debug.javascript.autoAttach.smart.label', 'Smart'),
[State.OnlyWithFlag]: localize(
'debug.javascript.autoAttach.onlyWithFlag.label',
'Only With Flag',
),
[State.Disabled]: vscode.l10n.t('Disabled'),
[State.Always]: vscode.l10n.t('Always'),
[State.Smart]: vscode.l10n.t('Smart'),
[State.OnlyWithFlag]: vscode.l10n.t('Only With Flag'),
};
const TEXT_STATE_DESCRIPTION = {
[State.Disabled]: localize(
'debug.javascript.autoAttach.disabled.description',
'Auto attach is disabled and not shown in status bar',
),
[State.Always]: localize(
'debug.javascript.autoAttach.always.description',
'Auto attach to every Node.js process launched in the terminal',
),
[State.Smart]: localize(
'debug.javascript.autoAttach.smart.description',
"Auto attach when running scripts that aren't in a node_modules folder",
),
[State.OnlyWithFlag]: localize(
'debug.javascript.autoAttach.onlyWithFlag.description',
'Only auto attach when the `--inspect` flag is given',
),
[State.Disabled]: vscode.l10n.t('Auto attach is disabled and not shown in status bar'),
[State.Always]: vscode.l10n.t('Auto attach to every Node.js process launched in the terminal'),
[State.Smart]: vscode.l10n.t("Auto attach when running scripts that aren't in a node_modules folder"),
[State.OnlyWithFlag]: vscode.l10n.t('Only auto attach when the `--inspect` flag is given')
};
const TEXT_TOGGLE_WORKSPACE = localize('scope.workspace', 'Toggle auto attach in this workspace');
const TEXT_TOGGLE_GLOBAL = localize('scope.global', 'Toggle auto attach on this machine');
const TEXT_TEMP_DISABLE = localize('tempDisable.disable', 'Temporarily disable auto attach in this session');
const TEXT_TEMP_ENABLE = localize('tempDisable.enable', 'Re-enable auto attach');
const TEXT_TEMP_DISABLE_LABEL = localize('tempDisable.suffix', 'Auto Attach: Disabled');
const TEXT_TOGGLE_WORKSPACE = vscode.l10n.t('Toggle auto attach in this workspace');
const TEXT_TOGGLE_GLOBAL = vscode.l10n.t('Toggle auto attach on this machine');
const TEXT_TEMP_DISABLE = vscode.l10n.t('Temporarily disable auto attach in this session');
const TEXT_TEMP_ENABLE = vscode.l10n.t('Re-enable auto attach');
const TEXT_TEMP_DISABLE_LABEL = vscode.l10n.t('Auto Attach: Disabled');

const TOGGLE_COMMAND = 'extension.node-debug.toggleAutoAttach';
const STORAGE_IPC = 'jsDebugIpcState';
Expand Down Expand Up @@ -318,9 +301,9 @@ function updateStatusBar(context: vscode.ExtensionContext, state: State, busy =

if (!statusItem) {
statusItem = vscode.window.createStatusBarItem('status.debug.autoAttach', vscode.StatusBarAlignment.Left);
statusItem.name = localize('status.name.auto.attach', "Debug Auto Attach");
statusItem.name = vscode.l10n.t("Debug Auto Attach");
statusItem.command = TOGGLE_COMMAND;
statusItem.tooltip = localize('status.tooltip.auto.attach', "Automatically attach to node.js processes in debug mode");
statusItem.tooltip = vscode.l10n.t("Automatically attach to node.js processes in debug mode");
context.subscriptions.push(statusItem);
}

Expand Down
5 changes: 0 additions & 5 deletions extensions/debug-auto-launch/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@
version "16.11.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==

vscode-nls@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
3 changes: 0 additions & 3 deletions extensions/debug-server-ready/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,6 @@
}
]
},
"dependencies": {
"vscode-nls": "^5.2.0"
},
"devDependencies": {
"@types/node": "16.x"
},
Expand Down
7 changes: 2 additions & 5 deletions extensions/debug-server-ready/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@

import * as vscode from 'vscode';
import * as util from 'util';
import * as nls from 'vscode-nls';

const localize = nls.loadMessageBundle();

const PATTERN = 'listening on.* (https?://\\S+|[0-9]+)'; // matches "listening on port 3000" or "Now listening on: https://localhost:5001"
const URI_PORT_FORMAT = 'http://localhost:%s';
Expand Down Expand Up @@ -135,7 +132,7 @@ class ServerReadyDetector extends vscode.Disposable {
// verify that format does not contain '%s'
const format = args.uriFormat || '';
if (format.indexOf('%s') >= 0) {
const errMsg = localize('server.ready.nocapture.error', "Format uri ('{0}') uses a substitution placeholder but pattern did not capture anything.", format);
const errMsg = vscode.l10n.t("Format uri ('{0}') uses a substitution placeholder but pattern did not capture anything.", format);
vscode.window.showErrorMessage(errMsg, { modal: true }).then(_ => undefined);
return;
}
Expand All @@ -146,7 +143,7 @@ class ServerReadyDetector extends vscode.Disposable {
// verify that format only contains a single '%s'
const s = format.split('%s');
if (s.length !== 2) {
const errMsg = localize('server.ready.placeholder.error', "Format uri ('{0}') must contain exactly one substitution placeholder.", format);
const errMsg = vscode.l10n.t("Format uri ('{0}') must contain exactly one substitution placeholder.", format);
vscode.window.showErrorMessage(errMsg, { modal: true }).then(_ => undefined);
return;
}
Expand Down
5 changes: 0 additions & 5 deletions extensions/debug-server-ready/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,3 @@
version "16.11.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==

vscode-nls@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

0 comments on commit fd7e27f

Please sign in to comment.