Skip to content

Commit

Permalink
Localize strings
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcrane committed Jun 28, 2019
1 parent c6d454a commit 19a28b6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
17 changes: 9 additions & 8 deletions appservice/src/TunnelProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as requestP from 'request-promise';
import { IParsedError, parseError } from 'vscode-azureextensionui';
import * as websocket from 'websocket';
import { ext } from './extensionVariables';
import { localize } from './localize';
import { SiteClient } from './SiteClient';
import { delay } from './utils/delay';

Expand Down Expand Up @@ -206,25 +207,25 @@ export class TunnelProxy {
} catch (error) {
const parsedError: IParsedError = parseError(error);
ext.outputChannel.appendLine(`[Tunnel] Checking status, error: ${parsedError.message}`);
throw new Error(`Error getting tunnel status: ${parsedError.errorType}`);
throw new Error(localize('tunnelStatusError', 'Error getting tunnel status: {0}', parsedError.errorType));
}

if (tunnelStatus.state === AppState.STARTED) {
if ((tunnelStatus.port === 2222 && !this._isSsh) || (tunnelStatus.port !== 2222 && this._isSsh)) {
// Tunnel is pointed to default SSH port and still needs time to restart
throw new RetryableTunnelStatusError('App is waiting for restart');
throw new RetryableTunnelStatusError();
} else if (tunnelStatus.canReachPort) {
return;
} else {
throw new Error('App is started, but port is unreachable');
throw new Error(localize('tunnelUnreachable', 'App is started, but port is unreachable'));
}
} else if (tunnelStatus.state === AppState.STARTING) {
throw new RetryableTunnelStatusError('App is starting');
throw new RetryableTunnelStatusError();
} else if (tunnelStatus.state === AppState.STOPPED) {
await this.startupApp();
throw new RetryableTunnelStatusError('App is starting from STOPPED state');
throw new RetryableTunnelStatusError();
} else {
throw new Error(`Unexpected app state: ${tunnelStatus.state}`);
throw new Error(localize('tunnelStatusError', 'Unexpected app state: {0}', tunnelStatus.state));
}
}

Expand All @@ -242,14 +243,14 @@ export class TunnelProxy {
return;
} catch (error) {
if (!(error instanceof RetryableTunnelStatusError)) {
reject(new Error(`Unable to establish connection to application: ${parseError(error).message}`));
reject(new Error(localize('tunnelFailed', 'Unable to establish connection to application: {0}', parseError(error).message)));
return;
} // else allow retry
}

await delay(pollingIntervalMs);
}
reject(new Error('Unable to establish connection to application: Timed out'));
reject(new Error(localize('tunnelTimedOut', 'Unable to establish connection to application: Timed out')));
});
}

Expand Down
7 changes: 4 additions & 3 deletions appservice/src/remoteDebug/remoteDebugCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { SiteConfigResource } from 'azure-arm-website/lib/models';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, DialogResponses, IActionContext } from 'vscode-azureextensionui';
import { ext } from '../extensionVariables';
import { localize } from '../localize';
import { SiteClient } from '../SiteClient';

export function reportMessage(message: string, progress: vscode.Progress<{}>): void {
Expand All @@ -17,7 +18,7 @@ export function reportMessage(message: string, progress: vscode.Progress<{}>): v
export async function setRemoteDebug(isRemoteDebuggingToBeEnabled: boolean, confirmMessage: string, noopMessage: string | undefined, siteClient: SiteClient, siteConfig: SiteConfigResource, progress?: vscode.Progress<{}>, learnMoreLink?: string): Promise<void> {
const state: string | undefined = await siteClient.getState();
if (state && state.toLowerCase() === 'stopped') {
throw new Error('The app must be running, but is currently in state "Stopped". Start the app to continue.');
throw new Error(localize('remoteDebugStopped', 'The app must be running, but is currently in state "Stopped". Start the app to continue.'));
}

if (isRemoteDebuggingToBeEnabled !== siteConfig.remoteDebuggingEnabled) {
Expand All @@ -27,7 +28,7 @@ export async function setRemoteDebug(isRemoteDebuggingToBeEnabled: boolean, conf
await ext.ui.showWarningMessage(confirmMessage, { modal: true, learnMoreLink }, confirmButton, DialogResponses.cancel);
siteConfig.remoteDebuggingEnabled = isRemoteDebuggingToBeEnabled;
if (progress) {
reportMessage('Updating site configuration to set remote debugging...', progress);
reportMessage(localize('remoteDebugUpdate', 'Updating site configuration to set remote debugging...'), progress);
}

await callWithTelemetryAndErrorHandling('appService.remoteDebugUpdateConfiguration', async (context: IActionContext) => {
Expand All @@ -37,7 +38,7 @@ export async function setRemoteDebug(isRemoteDebuggingToBeEnabled: boolean, conf
});

if (progress) {
reportMessage('Updating site configuration done.', progress);
reportMessage(localize('remoteDebugUpdateDone', 'Updating site configuration done.'), progress);
}
} else {
// Update not needed
Expand Down
15 changes: 8 additions & 7 deletions appservice/src/remoteDebug/startRemoteDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as portfinder from 'portfinder';
import * as vscode from 'vscode';
import { callWithTelemetryAndErrorHandling, IActionContext } from 'vscode-azureextensionui';
import { ext } from '../extensionVariables';
import { localize } from '../localize';
import { SiteClient } from '../SiteClient';
import { TunnelProxy } from '../TunnelProxy';
import { reportMessage, setRemoteDebug } from './remoteDebugCommon';
Expand All @@ -18,7 +19,7 @@ let isRemoteDebugging: boolean = false;

export async function startRemoteDebug(siteClient: SiteClient, siteConfig: SiteConfigResource): Promise<void> {
if (isRemoteDebugging) {
throw new Error('Azure Remote Debugging is currently starting or already started.');
throw new Error(localize('remoteDebugAlreadyStarted', 'Azure Remote Debugging is currently starting or already started.'));
}

isRemoteDebugging = true;
Expand All @@ -36,10 +37,10 @@ async function startRemoteDebugInternal(siteClient: SiteClient, siteConfig: Site
// tslint:disable-next-line:no-unsafe-any
const localHostPortNumber: number = debugConfig.port;

const confirmEnableMessage: string = 'The configuration will be updated to enable remote debugging. Would you like to continue? This will restart the app.';
const confirmEnableMessage: string = localize('remoteDebugEnablePrompt', 'The configuration will be updated to enable remote debugging. Would you like to continue? This will restart the app.');
await setRemoteDebug(true, confirmEnableMessage, undefined, siteClient, siteConfig, progress, remoteDebugLink);

reportMessage('Starting tunnel proxy...', progress);
reportMessage(localize('remoteDebugStartingTunnel', 'Starting tunnel proxy...'), progress);

const publishCredential: User = await siteClient.getWebAppPublishCredential();
const tunnelProxy: TunnelProxy = new TunnelProxy(localHostPortNumber, siteClient, publishCredential);
Expand All @@ -49,15 +50,15 @@ async function startRemoteDebugInternal(siteClient: SiteClient, siteConfig: Site
await tunnelProxy.startProxy();
});

reportMessage('Attaching debugger...', progress);
reportMessage(localize('remoteDebugAttaching', 'Attaching debugger...'), progress);

await callWithTelemetryAndErrorHandling('appService.remoteDebugAttach', async (attachContext: IActionContext) => {
attachContext.errorHandling.suppressDisplay = true;
attachContext.errorHandling.rethrow = true;
await vscode.debug.startDebugging(undefined, debugConfig);
});

reportMessage('Attached!', progress);
reportMessage(localize('remoteDebugAttached', 'Attached!'), progress);

const terminateDebugListener: vscode.Disposable = vscode.debug.onDidTerminateDebugSession(async (event: vscode.DebugSession) => {
if (event.name === debugConfig.name) {
Expand Down Expand Up @@ -101,11 +102,11 @@ async function getDebugConfiguration(): Promise<vscode.DebugConfiguration> {
// In this case we don't know which folder to use. Show a warning and proceed.
// In the future we should allow users to choose a workspace folder to map sources from.
// tslint:disable-next-line:no-floating-promises
ext.ui.showWarningMessage('Unable to bind breakpoints from workspace when multiple folders are open. Use "loaded scripts" instead.');
ext.ui.showWarningMessage(localize('remoteDebugMultipleFolders', 'Unable to bind breakpoints from workspace when multiple folders are open. Use "loaded scripts" instead.');
}
} else {
// vscode will throw an error if you try to start debugging without any workspace folder open
throw new Error('Please open a workspace folder before attaching a debugger.');
throw new Error(localize('remoteDebugNoFolders', 'Please open a workspace folder before attaching a debugger.'));
}

return config;
Expand Down

0 comments on commit 19a28b6

Please sign in to comment.