diff --git a/appservice/package-lock.json b/appservice/package-lock.json index 2d1668202a..1a557ce71f 100644 --- a/appservice/package-lock.json +++ b/appservice/package-lock.json @@ -26,7 +26,6 @@ "p-retry": "^3.0.1", "pretty-bytes": "^5.3.0", "simple-git": "^3.5.0", - "vscode-nls": "^5.0.1", "ws": "^8.5.0", "yazl": "^2.5.1" }, diff --git a/appservice/package.json b/appservice/package.json index ccf1fc9f2c..7246872344 100644 --- a/appservice/package.json +++ b/appservice/package.json @@ -49,7 +49,6 @@ "p-retry": "^3.0.1", "pretty-bytes": "^5.3.0", "simple-git": "^3.5.0", - "vscode-nls": "^5.0.1", "ws": "^8.5.0", "yazl": "^2.5.1" }, diff --git a/appservice/src/TunnelProxy.ts b/appservice/src/TunnelProxy.ts index 329f323046..091a25bdbf 100644 --- a/appservice/src/TunnelProxy.ts +++ b/appservice/src/TunnelProxy.ts @@ -9,11 +9,10 @@ import { RestError, createPipelineRequest } from "@azure/core-rest-pipeline"; import { AzExtPipelineResponse, addBasicAuthenticationCredentialsToClient, createGenericClient } from '@microsoft/vscode-azext-azureutils'; import { IActionContext, IParsedError, UserCancelledError, nonNullProp, parseError } from '@microsoft/vscode-azext-utils'; import { Server, Socket, createServer } from 'net'; -import { CancellationToken, Disposable } from 'vscode'; +import { CancellationToken, Disposable, l10n } from 'vscode'; import * as ws from 'ws'; import { ParsedSite } from './SiteClient'; import { ext } from './extensionVariables'; -import { localize } from './localize'; import { delay } from './utils/delay'; /** @@ -112,7 +111,7 @@ export class TunnelProxy { } catch (error) { const parsedError: IParsedError = parseError(error); ext.outputChannel.appendLog(`[Tunnel] Checking status, error: ${parsedError.message}`); - throw new Error(localize('tunnelStatusError', 'Error getting tunnel status: {0}', parsedError.errorType)); + throw new Error(l10n.t('Error getting tunnel status: {0}', parsedError.errorType)); } if (tunnelStatus.state === AppState.STARTED) { @@ -122,7 +121,7 @@ export class TunnelProxy { } else if (tunnelStatus.canReachPort) { return; } else { - throw new Error(localize('tunnelUnreachable', 'App is started, but port is unreachable')); + throw new Error(l10n.t('App is started, but port is unreachable')); } } else if (tunnelStatus.state === AppState.STARTING) { throw new RetryableTunnelStatusError(); @@ -130,7 +129,7 @@ export class TunnelProxy { await this.pingApp(context); throw new RetryableTunnelStatusError(); } else { - throw new Error(localize('tunnelStatusError', 'Unexpected app state: {0}', tunnelStatus.state)); + throw new Error(l10n.t('Unexpected app state: {0}', tunnelStatus.state)); } } @@ -151,13 +150,13 @@ export class TunnelProxy { return; } catch (error) { if (!(error instanceof RetryableTunnelStatusError)) { - throw new Error(localize('tunnelFailed', 'Unable to establish connection to application: {0}', parseError(error).message)); + throw new Error(l10n.t('Unable to establish connection to application: {0}', parseError(error).message)); } // else allow retry } await delay(pollingIntervalMs); } - throw new Error(localize('tunnelTimedOut', 'Unable to establish connection to application: Timed out')); + throw new Error(l10n.t('Unable to establish connection to application: Timed out')); } private async setupTunnelServer(token: CancellationToken): Promise { diff --git a/appservice/src/confirmOverwriteSettings.ts b/appservice/src/confirmOverwriteSettings.ts index a1581a5964..d985328b83 100644 --- a/appservice/src/confirmOverwriteSettings.ts +++ b/appservice/src/confirmOverwriteSettings.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { DialogResponses, IActionContext } from '@microsoft/vscode-azext-utils'; -import { MessageItem } from 'vscode'; +import { l10n, MessageItem } from 'vscode'; import { ext } from './extensionVariables'; -import { localize } from './localize'; export async function confirmOverwriteSettings(context: IActionContext, sourceSettings: { [key: string]: string }, destinationSettings: { [key: string]: string }, destinationName: string): Promise { let suppressPrompt: boolean = false; @@ -28,9 +27,9 @@ export async function confirmOverwriteSettings(context: IActionContext, sourceSe matchingKeys.push(destKey); } else if (sourceSettings[srcKey]) { // ignore empty settings if (!suppressPrompt) { - const yesToAll: MessageItem = { title: localize('yesToAll', 'Yes to all') }; - const noToAll: MessageItem = { title: localize('noToAll', 'No to all') }; - const message: string = localize('overwriteSetting', 'Setting "{0}" already exists in "{1}". Overwrite?', destKey, destinationName); + const yesToAll: MessageItem = { title: l10n.t('Yes to all') }; + const noToAll: MessageItem = { title: l10n.t('No to all') }; + const message: string = l10n.t('Setting "{0}" already exists in "{1}". Overwrite?', destKey, destinationName); const result: MessageItem = await context.ui.showWarningMessage(message, { modal: true, stepName: 'confirmOverwriteSetting' }, DialogResponses.yes, yesToAll, DialogResponses.no, noToAll); if (result === DialogResponses.yes) { overwriteSetting = true; @@ -55,27 +54,27 @@ export async function confirmOverwriteSettings(context: IActionContext, sourceSe } if (addedKeys.length > 0) { - ext.outputChannel.appendLog(localize('addedKeys', 'Added the following settings:')); + ext.outputChannel.appendLog(l10n.t('Added the following settings:')); addedKeys.forEach(logKey); } if (updatedKeys.length > 0) { - ext.outputChannel.appendLog(localize('updatedKeys', 'Updated the following settings:')); + ext.outputChannel.appendLog(l10n.t('Updated the following settings:')); updatedKeys.forEach(logKey); } if (matchingKeys.length > 0) { - ext.outputChannel.appendLog(localize('matchingKeys', 'Ignored the following settings that were already the same:')); + ext.outputChannel.appendLog(l10n.t('Ignored the following settings that were already the same:')); matchingKeys.forEach(logKey); } if (userIgnoredKeys.length > 0) { - ext.outputChannel.appendLog(localize('userIgnoredKeys', 'Ignored the following settings based on user input:')); + ext.outputChannel.appendLog(l10n.t('Ignored the following settings based on user input:')); userIgnoredKeys.forEach(logKey); } if (Object.keys(destinationSettings).length > Object.keys(sourceSettings).length) { - ext.outputChannel.appendLog(localize('noDeleteKey', 'WARNING: This operation will not delete any settings in "{0}". You must manually delete settings if desired.', destinationName)); + ext.outputChannel.appendLog(l10n.t('WARNING: This operation will not delete any settings in "{0}". You must manually delete settings if desired.', destinationName)); } } diff --git a/appservice/src/createAppService/AppInsightsCreateStep.ts b/appservice/src/createAppService/AppInsightsCreateStep.ts index 266d58dd6a..f01c053708 100644 --- a/appservice/src/createAppService/AppInsightsCreateStep.ts +++ b/appservice/src/createAppService/AppInsightsCreateStep.ts @@ -7,9 +7,8 @@ import type { ApplicationInsightsManagementClient } from '@azure/arm-appinsights import type { ResourceGroup } from '@azure/arm-resources'; import { AzExtLocation, LocationListStep } from '@microsoft/vscode-azext-azureutils'; import { AzureWizardExecuteStep, IParsedError, nonNullProp, parseError } from '@microsoft/vscode-azext-utils'; -import { MessageItem, Progress } from 'vscode'; +import { l10n, MessageItem, Progress } from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { createAppInsightsClient } from '../utils/azureClients'; import { AppInsightsListStep } from './AppInsightsListStep'; import { getAppInsightsSupportedLocation } from './getAppInsightsSupportedLocation'; @@ -19,7 +18,7 @@ export class AppInsightsCreateStep extends AzureWizardExecuteStep): Promise { - const verifyingAppInsightsAvailable: string = localize('verifyingAppInsightsAvailable', 'Verifying that Application Insights is available for this location...'); + const verifyingAppInsightsAvailable: string = l10n.t('Verifying that Application Insights is available for this location...'); ext.outputChannel.appendLog(verifyingAppInsightsAvailable); const resourceLocation: AzExtLocation = await LocationListStep.getLocation(context); const appInsightsLocation = await getAppInsightsSupportedLocation(context, resourceLocation); @@ -31,12 +30,12 @@ export class AppInsightsCreateStep extends AzureWizardExecuteStep { - const message: string = localize('aiForbidden', 'You do not have permission to create an app insights resource in subscription "{0}".', context.subscriptionDisplayName); - const selectExisting: MessageItem = { title: localize('selectExisting', 'Select Existing') }; - const skipForNow: MessageItem = { title: localize('skipForNow', 'Skip for Now') }; + const message: string = l10n.t('You do not have permission to create an app insights resource in subscription "{0}".', context.subscriptionDisplayName); + const selectExisting: MessageItem = { title: l10n.t('Select Existing') }; + const skipForNow: MessageItem = { title: l10n.t('Skip for Now') }; const result = await context.ui.showWarningMessage(message, { modal: true, stepName: 'AppInsightsNoPermissions' }, selectExisting, skipForNow); if (result === skipForNow) { context.telemetry.properties.aiSkipForNow = 'true'; diff --git a/appservice/src/createAppService/AppInsightsListStep.ts b/appservice/src/createAppService/AppInsightsListStep.ts index ac294b55f8..0bd00c8b0a 100644 --- a/appservice/src/createAppService/AppInsightsListStep.ts +++ b/appservice/src/createAppService/AppInsightsListStep.ts @@ -3,11 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import type { ApplicationInsightsManagementClient } from "@azure/arm-appinsights"; -import type { ApplicationInsightsComponent } from "@azure/arm-appinsights"; +import type { ApplicationInsightsComponent, ApplicationInsightsManagementClient } from "@azure/arm-appinsights"; import { LocationListStep, uiUtils } from "@microsoft/vscode-azext-azureutils"; import { AzureWizardPromptStep, IAzureNamingRules, IAzureQuickPickItem, IAzureQuickPickOptions, IWizardOptions, nonNullProp } from "@microsoft/vscode-azext-utils"; -import { localize } from "../localize"; +import * as vscode from 'vscode'; import { createAppInsightsClient } from "../utils/azureClients"; import { AppInsightsCreateStep } from "./AppInsightsCreateStep"; import { AppInsightsNameStep } from "./AppInsightsNameStep"; @@ -75,12 +74,12 @@ export class AppInsightsListStep extends AzureWizardPromptStep[]> { const picks: IAzureQuickPickItem[] = !this._suppressCreate ? [{ - label: localize('newApplicationInsight', '$(plus) Create new Application Insights resource'), + label: vscode.l10n.t('$(plus) Create new Application Insights resource'), data: undefined }] : []; picks.push({ - label: localize('skipForNow', skipForNowLabel), + label: vscode.l10n.t(skipForNowLabel), data: undefined }); diff --git a/appservice/src/createAppService/AppInsightsNameStep.ts b/appservice/src/createAppService/AppInsightsNameStep.ts index a2eb929e3a..d5c35fb563 100644 --- a/appservice/src/createAppService/AppInsightsNameStep.ts +++ b/appservice/src/createAppService/AppInsightsNameStep.ts @@ -5,7 +5,7 @@ import type { ApplicationInsightsComponent } from '@azure/arm-appinsights'; import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils'; -import { localize } from '../localize'; +import * as vscode from 'vscode'; import { AppInsightsListStep, appInsightsNamingRules } from './AppInsightsListStep'; import { IAppServiceWizardContext } from './IAppServiceWizardContext'; @@ -34,13 +34,13 @@ export class AppInsightsNameStep extends AzureWizardPromptStep appInsightsNamingRules.maxLength) { - return localize('invalidLength', 'The name must be between {0} and {1} characters.', appInsightsNamingRules.minLength, appInsightsNamingRules.maxLength); + return vscode.l10n.t('The name must be between {0} and {1} characters.', appInsightsNamingRules.minLength, appInsightsNamingRules.maxLength); } else if (appInsightsNamingRules.invalidCharsRegExp.test(name)) { - return localize('invalidChars', "The name can only contain alphanumeric characters or the symbols ._-()"); + return vscode.l10n.t("The name can only contain alphanumeric characters or the symbols ._-()"); } else if (name.endsWith('.')) { - return localize('invalidEndingChar', "The name cannot end in a period."); + return vscode.l10n.t("The name cannot end in a period."); } else if (!await this.isNameAvailable(context, name)) { - return localize('nameAlreadyExists', 'Application Insights resource "{0}" already exists in subscription "{1}".', name, context.subscriptionDisplayName); + return vscode.l10n.t('Application Insights resource "{0}" already exists in subscription "{1}".', name, context.subscriptionDisplayName); } else { return undefined; } diff --git a/appservice/src/createAppService/AppServicePlanCreateStep.ts b/appservice/src/createAppService/AppServicePlanCreateStep.ts index 5dad59bdce..fea38297e7 100644 --- a/appservice/src/createAppService/AppServicePlanCreateStep.ts +++ b/appservice/src/createAppService/AppServicePlanCreateStep.ts @@ -6,10 +6,9 @@ import { AppServicePlan, WebSiteManagementClient } from '@azure/arm-appservice'; import { AzExtLocation, LocationListStep } from '@microsoft/vscode-azext-azureutils'; import { AzureWizardExecuteStep, nonNullProp, nonNullValue, parseError } from '@microsoft/vscode-azext-utils'; -import { MessageItem, Progress } from 'vscode'; +import { l10n, MessageItem, Progress } from 'vscode'; import { webProvider } from '../constants'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { tryGetAppServicePlan } from '../tryGetSiteResource'; import { createWebSiteClient } from '../utils/azureClients'; import { AppKind, WebsiteOS } from './AppKind'; @@ -23,10 +22,10 @@ export class AppServicePlanCreateStep extends AzureWizardExecuteStep { - const message: string = localize('planForbidden', 'You do not have permission to create an app service plan in subscription "{0}".', context.subscriptionDisplayName); - const selectExisting: MessageItem = { title: localize('selectExisting', 'Select Existing') }; + const message: string = l10n.t('You do not have permission to create an app service plan in subscription "{0}".', context.subscriptionDisplayName); + const selectExisting: MessageItem = { title: l10n.t('Select Existing') }; await context.ui.showWarningMessage(message, { modal: true, stepName: 'AspNoPermissions' }, selectExisting); context.telemetry.properties.forbiddenResponse = 'SelectExistingAsp'; diff --git a/appservice/src/createAppService/AppServicePlanListStep.ts b/appservice/src/createAppService/AppServicePlanListStep.ts index ae7d1081cf..ea193857bc 100644 --- a/appservice/src/createAppService/AppServicePlanListStep.ts +++ b/appservice/src/createAppService/AppServicePlanListStep.ts @@ -6,8 +6,8 @@ import type { AppServicePlan, WebSiteManagementClient } from '@azure/arm-appservice'; import { AzExtLocation, LocationListStep, ResourceGroupListStep, uiUtils } from '@microsoft/vscode-azext-azureutils'; import { AzureWizardPromptStep, IAzureQuickPickItem, IAzureQuickPickOptions, IWizardOptions, nonNullProp } from '@microsoft/vscode-azext-utils'; +import * as vscode from 'vscode'; import { webProvider } from '../constants'; -import { localize } from '../localize'; import { tryGetAppServicePlan } from '../tryGetSiteResource'; import { createWebSiteClient } from '../utils/azureClients'; import { AppKind, getWebsiteOSDisplayName, WebsiteOS } from './AppKind'; @@ -48,8 +48,8 @@ export class AppServicePlanListStep extends AzureWizardPromptStep[]> { const picks: IAzureQuickPickItem[] = !this._suppressCreate ? [{ - label: localize('CreateNewAppServicePlan', '$(plus) Create new App Service plan'), + label: vscode.l10n.t('$(plus) Create new App Service plan'), description: '', data: undefined }] @@ -128,7 +128,7 @@ export class AppServicePlanListStep extends AzureWizardPromptStep { /* do nothing */ }, data: undefined }); diff --git a/appservice/src/createAppService/AppServicePlanNameStep.ts b/appservice/src/createAppService/AppServicePlanNameStep.ts index aec9997c93..4ed853e91f 100644 --- a/appservice/src/createAppService/AppServicePlanNameStep.ts +++ b/appservice/src/createAppService/AppServicePlanNameStep.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { AzureWizardPromptStep, IAzureNamingRules, nonNullProp } from '@microsoft/vscode-azext-utils'; -import { localize } from '../localize'; +import * as vscode from 'vscode'; import { AppServicePlanListStep } from './AppServicePlanListStep'; import { IAppServiceWizardContext } from './IAppServiceWizardContext'; @@ -18,7 +18,7 @@ export class AppServicePlanNameStep extends AzureWizardPromptStep { context.newPlanName = (await context.ui.showInputBox({ value: await context.relatedNameTask, - prompt: localize('AppServicePlanPrompt', 'Enter the name of the new App Service plan.'), + prompt: vscode.l10n.t('Enter the name of the new App Service plan.'), validateInput: async (value: string): Promise => await this.validatePlanName(context, value) })).trim(); context.valuesToMask.push(context.newPlanName); @@ -32,11 +32,12 @@ export class AppServicePlanNameStep extends AzureWizardPromptStep appServicePlanNamingRules.maxLength) { - return localize('invalidLength', 'The name must be between {0} and {1} characters.', appServicePlanNamingRules.minLength, appServicePlanNamingRules.maxLength); + return vscode.l10n.t('The name must be between {0} and {1} characters.', appServicePlanNamingRules.minLength, appServicePlanNamingRules.maxLength); } else if (appServicePlanNamingRules.invalidCharsRegExp.test(name)) { - return localize('invalidChars', "The name can only contain alphanumeric characters, hyphens, and underscores."); + return vscode.l10n.t("The name can only contain alphanumeric characters, hyphens, and underscores."); } else if (context.resourceGroup && !await AppServicePlanListStep.isNameAvailable(context, name, nonNullProp(context.resourceGroup, 'name'))) { - return localize('nameAlreadyExists', 'App Service plan "{0}" already exists in resource group "{1}".', name, context.resourceGroup.name); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + return vscode.l10n.t('App Service plan "{0}" already exists in resource group "{1}".', name, context.resourceGroup.name!); } else { return undefined; } diff --git a/appservice/src/createAppService/AppServicePlanRedundancyStep.ts b/appservice/src/createAppService/AppServicePlanRedundancyStep.ts index 53ecb7d68d..2c7753821b 100644 --- a/appservice/src/createAppService/AppServicePlanRedundancyStep.ts +++ b/appservice/src/createAppService/AppServicePlanRedundancyStep.ts @@ -6,7 +6,7 @@ import { SkuDescription } from '@azure/arm-appservice'; import { AzExtLocation } from '@microsoft/vscode-azext-azureutils'; import { AzureWizardPromptStep, IAzureQuickPickItem } from '@microsoft/vscode-azext-utils'; -import { localize } from '../localize'; +import * as vscode from 'vscode'; import { IAppServiceWizardContext } from './IAppServiceWizardContext'; interface AppServiceWizardContext extends IAppServiceWizardContext { @@ -16,10 +16,10 @@ interface AppServiceWizardContext extends IAppServiceWizardContext { export class AppServicePlanRedundancyStep extends AzureWizardPromptStep { public async prompt(context: AppServiceWizardContext): Promise { - const placeHolder: string = localize('selectZoneRedundancy', 'Select zone redundancy availability'); + const placeHolder: string = vscode.l10n.t('Select zone redundancy availability'); const picks: IAzureQuickPickItem[] = [ - { label: localize('enabled', 'Enabled'), data: true }, - { label: localize('disabled', 'Disabled'), data: false } + { label: vscode.l10n.t('Enabled'), data: true }, + { label: vscode.l10n.t('Disabled'), data: false } ]; context.zoneRedundant = (await context.ui.showQuickPick(picks, { placeHolder })).data; diff --git a/appservice/src/createAppService/AppServicePlanSkuStep.ts b/appservice/src/createAppService/AppServicePlanSkuStep.ts index 726bc4498a..f37521ec64 100644 --- a/appservice/src/createAppService/AppServicePlanSkuStep.ts +++ b/appservice/src/createAppService/AppServicePlanSkuStep.ts @@ -5,7 +5,7 @@ import type { SkuDescription } from '@azure/arm-appservice'; import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullProp } from '@microsoft/vscode-azext-utils'; -import { localize } from '../localize'; +import * as vscode from 'vscode'; import { openUrl } from '../utils/openUrl'; import { AppKind, WebsiteOS } from './AppKind'; import { IAppServiceWizardContext } from './IAppServiceWizardContext'; @@ -32,14 +32,14 @@ export class AppServicePlanSkuStep extends AzureWizardPromptStep extends LocationListStep { public async prompt(context: T): Promise { - const options: IAzureQuickPickOptions = { placeHolder: localize('selectLocation', 'Select a location for new resources.'), enableGrouping: true }; + const options: IAzureQuickPickOptions = { placeHolder: vscode.l10n.t('Select a location for new resources.'), enableGrouping: true }; const result: AzExtLocation | CustomLocation = (await context.ui.showQuickPick(this.getCustomQuickPicks(context), options)).data; if ('kubeEnvironment' in result) { context.telemetry.properties.pickedCustomLoc = 'true'; @@ -43,7 +43,7 @@ export class CustomLocationListStep extends picks.unshift(...customLocations.map(cl => { return { label: cl.name, - group: localize('custom', 'Custom'), + group: vscode.l10n.t('Custom'), data: cl }; })); diff --git a/appservice/src/createAppService/LogAnalyticsCreateStep.ts b/appservice/src/createAppService/LogAnalyticsCreateStep.ts index dad47b5480..3edea44661 100644 --- a/appservice/src/createAppService/LogAnalyticsCreateStep.ts +++ b/appservice/src/createAppService/LogAnalyticsCreateStep.ts @@ -5,9 +5,8 @@ import { AzExtLocation, getResourceGroupFromId, LocationListStep, uiUtils } from "@microsoft/vscode-azext-azureutils"; import { AzureWizardExecuteStep, nonNullProp, nonNullValueAndProp } from "@microsoft/vscode-azext-utils"; -import { Progress } from "vscode"; +import { l10n, Progress } from "vscode"; import { ext } from "../extensionVariables"; -import { localize } from "../localize"; import { createOperationalInsightsManagementClient } from "../utils/azureClients"; import { getAppInsightsSupportedLocation } from "./getAppInsightsSupportedLocation"; import { IAppServiceWizardContext } from "./IAppServiceWizardContext"; @@ -21,7 +20,7 @@ export class LogAnalyticsCreateStep extends AzureWizardExecuteStep { // For now, we'll only display this placeholder for the most common case let namePlaceholder: string; if (context.newSiteKind === AppKind.functionapp) { - namePlaceholder = localize('funcAppName', 'function app name'); + namePlaceholder = vscode.l10n.t('function app name'); } else if (context.newSiteKind?.includes(AppKind.workflowapp)) { - namePlaceholder = localize('logicAppName', 'logic app name'); + namePlaceholder = vscode.l10n.t('logic app name'); } else { - namePlaceholder = localize('webAppName', 'web app name'); + namePlaceholder = vscode.l10n.t('web app name'); } placeHolder = `<${namePlaceholder}>.azurewebsites.net`; } let prompt: string; if (context.newSiteKind === AppKind.functionapp) { - prompt = localize('functionAppNamePrompt', 'Enter a globally unique name for the new function app.'); + prompt = vscode.l10n.t('Enter a globally unique name for the new function app.'); } else if (context.newSiteKind?.includes(AppKind.workflowapp)) { - prompt = localize('functionAppNamePrompt', 'Enter a globally unique name for the new logic app.'); + prompt = vscode.l10n.t('Enter a globally unique name for the new logic app.'); } else { - prompt = localize('webAppNamePrompt', 'Enter a globally unique name for the new web app.'); + prompt = vscode.l10n.t('Enter a globally unique name for the new web app.'); } context.newSiteName = (await context.ui.showInputBox({ @@ -90,9 +90,9 @@ export class SiteNameStep extends AzureNameStep { name = name.trim(); if (name.length < siteNamingRules.minLength || name.length > siteNamingRules.maxLength) { - return localize('invalidLength', 'The name must be between {0} and {1} characters.', siteNamingRules.minLength, siteNamingRules.maxLength); + return vscode.l10n.t('The name must be between {0} and {1} characters.', siteNamingRules.minLength, siteNamingRules.maxLength); } else if (siteNamingRules.invalidCharsRegExp.test(name)) { - return localize('invalidChars', "The name can only contain letters, numbers, or hyphens."); + return vscode.l10n.t("The name can only contain letters, numbers, or hyphens."); } return undefined; diff --git a/appservice/src/createAppService/SiteOSStep.ts b/appservice/src/createAppService/SiteOSStep.ts index 5ec739797f..dac101754e 100644 --- a/appservice/src/createAppService/SiteOSStep.ts +++ b/appservice/src/createAppService/SiteOSStep.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { AzureWizardPromptStep, IAzureQuickPickItem } from '@microsoft/vscode-azext-utils'; -import { localize } from '../localize'; +import * as vscode from 'vscode'; import { getWebsiteOSDisplayName, WebsiteOS } from './AppKind'; import { IAppServiceWizardContext } from './IAppServiceWizardContext'; import { setLocationsTask } from './setLocationsTask'; @@ -16,7 +16,7 @@ export class SiteOSStep extends AzureWizardPromptStep return { label: getWebsiteOSDisplayName(os), description: '', data: os }; }); - context.newSiteOS = (await context.ui.showQuickPick(picks, { placeHolder: localize('selectOS', 'Select an OS.') })).data; + context.newSiteOS = (await context.ui.showQuickPick(picks, { placeHolder: vscode.l10n.t('Select an OS.') })).data; await setLocationsTask(context); } diff --git a/appservice/src/createSlot.ts b/appservice/src/createSlot.ts index eed3bf8b45..9141b90b1e 100644 --- a/appservice/src/createSlot.ts +++ b/appservice/src/createSlot.ts @@ -7,11 +7,10 @@ import type { CheckNameAvailabilityResponse, NameValuePair, Site, StringDictiona import { ServiceClient } from '@azure/core-client'; import { createGenericClient } from "@microsoft/vscode-azext-azureutils"; import { IActionContext, IAzureNamingRules, IAzureQuickPickItem, ICreateChildImplContext } from "@microsoft/vscode-azext-utils"; -import { ProgressLocation, window } from "vscode"; +import { ProgressLocation, l10n, window } from "vscode"; import { ParsedSite } from './SiteClient'; import { getNewFileShareName } from "./createAppService/getNewFileShareName"; import { ext } from "./extensionVariables"; -import { localize } from "./localize"; import { createWebSiteClient } from "./utils/azureClients"; import { checkNameAvailability } from "./utils/azureUtils"; @@ -19,7 +18,7 @@ export async function createSlot(site: ParsedSite, existingSlots: ParsedSite[], const client: WebSiteManagementClient = await createWebSiteClient([context, site.subscription]); const gClient = await createGenericClient(context, site.subscription); const slotName: string = (await context.ui.showInputBox({ - prompt: localize('enterSlotName', 'Enter a unique name for the new deployment slot'), + prompt: l10n.t('Enter a unique name for the new deployment slot'), stepName: 'slotName', validateInput: async (value: string): Promise => validateSlotName(value, gClient, site) })).trim(); @@ -43,7 +42,7 @@ export async function createSlot(site: ParsedSite, existingSlots: ParsedSite[], context.showCreatingTreeItem(slotName); - const creatingSlot: string = localize('creatingSlot', 'Creating slot "{0}"...', slotName); + const creatingSlot: string = l10n.t('Creating slot "{0}"...', slotName); ext.outputChannel.appendLog(creatingSlot); return await window.withProgress({ location: ProgressLocation.Notification, title: creatingSlot }, async () => { return await client.webApps.beginCreateOrUpdateSlotAndWait(site.resourceGroup, site.siteName, slotName, newDeploymentSlot); @@ -60,13 +59,13 @@ async function validateSlotName(value: string, client: ServiceClient, site: Pars value = value.trim(); // Can not have "production" as a slot name, but checkNameAvailability doesn't validate that if (value === 'production') { - return localize('slotNotAvailable', 'The slot name "{0}" is not available.', value); + return l10n.t('The slot name "{0}" is not available.', value); } else if (value.length < slotNamingRules.minLength) { - return localize('nameTooShort', 'The slot name must be at least {0} characters.', slotNamingRules.minLength); + return l10n.t('The slot name must be at least {0} characters.', slotNamingRules.minLength); } else if (value.length + site.siteName.length > slotNamingRules.maxLength) { - return localize('nameTooLong', 'The combined site name and slot name must be fewer than {0} characters.', slotNamingRules.maxLength); + return l10n.t('The combined site name and slot name must be fewer than {0} characters.', slotNamingRules.maxLength); } else if (slotNamingRules.invalidCharsRegExp.test(value)) { - return localize('invalidChars', "The name can only contain letters, numbers, or hyphens."); + return l10n.t("The name can only contain letters, numbers, or hyphens."); } else { const nameAvailability: CheckNameAvailabilityResponse = await checkNameAvailability(client, site.subscription.subscriptionId, `${site.siteName}-${value}`, 'Slot'); if (!nameAvailability.nameAvailable) { @@ -83,7 +82,7 @@ async function chooseConfigurationSource(context: IActionContext, site: ParsedSi return site; } else { const configurationSources: IAzureQuickPickItem[] = [{ - label: localize('dontClone', "Don't clone configuration from an existing slot"), + label: l10n.t("Don't clone configuration from an existing slot"), data: undefined }]; @@ -101,7 +100,7 @@ async function chooseConfigurationSource(context: IActionContext, site: ParsedSi }); } - const placeHolder: string = localize('chooseSource', 'Choose a configuration source.'); + const placeHolder: string = l10n.t('Choose a configuration source.'); return (await context.ui.showQuickPick(configurationSources, { placeHolder, stepName: 'slotConfigSource' })).data; } } diff --git a/appservice/src/deleteSite/DeleteLastServicePlanStep.ts b/appservice/src/deleteSite/DeleteLastServicePlanStep.ts index 6fe8c19e47..79569fbd45 100644 --- a/appservice/src/deleteSite/DeleteLastServicePlanStep.ts +++ b/appservice/src/deleteSite/DeleteLastServicePlanStep.ts @@ -5,8 +5,7 @@ import { AzureWizardPromptStep, DialogResponses, nonNullProp } from "@microsoft/vscode-azext-utils"; import { isNullOrUndefined } from "util"; -import { MessageItem } from "vscode"; -import { localize } from "../localize"; +import { l10n, MessageItem } from "vscode"; import { IDeleteSiteWizardContext } from "./IDeleteSiteWizardContext"; export class DeleteLastServicePlanStep extends AzureWizardPromptStep { @@ -17,7 +16,8 @@ export class DeleteLastServicePlanStep extends AzureWizardPromptStep { @@ -20,14 +19,14 @@ export class DeleteSiteStep extends AzureWizardExecuteStep { if (context.stopAppBeforeDeploy) { - ext.outputChannel.appendLog(localize('stoppingApp', 'Stopping app...'), { resourceName: site.fullName }); + ext.outputChannel.appendLog(l10n.t('Stopping app...'), { resourceName: site.fullName }); await client.stop(); } - ext.outputChannel.appendLog(localize('deployStart', 'Starting deployment...'), { resourceName: site.fullName }); + ext.outputChannel.appendLog(l10n.t('Starting deployment...'), { resourceName: site.fullName }); try { if (!context.deployMethod && config.scmType === ScmType.GitHub) { - throw new Error(localize('gitHubConnected', '"{0}" is connected to a GitHub repository. Push to GitHub repository to deploy.', site.fullName)); + throw new Error(l10n.t('"{0}" is connected to a GitHub repository. Push to GitHub repository to deploy.', site.fullName)); } else if (!context.deployMethod && config.scmType === ScmType.LocalGit) { await localGitDeploy(site, { fsPath: fsPath }, context); } else { if (!(await fse.pathExists(fsPath))) { - throw new Error(localize('pathNotExist', 'Failed to deploy path that does not exist: {0}', fsPath)); + throw new Error(l10n.t('Failed to deploy path that does not exist: {0}', fsPath)); } const javaRuntime = site.isLinux ? config.linuxFxVersion : config.javaContainer; @@ -100,7 +99,7 @@ export async function deploy(site: ParsedSite, fsPath: string, context: IDeployC } } finally { if (context.stopAppBeforeDeploy) { - ext.outputChannel.appendLog(localize('startingApp', 'Starting app...'), { resourceName: site.fullName }); + ext.outputChannel.appendLog(l10n.t('Starting app...'), { resourceName: site.fullName }); await client.start(); } } diff --git a/appservice/src/deploy/deployToStorageAccount.ts b/appservice/src/deploy/deployToStorageAccount.ts index 4b0183f14c..e03962c4de 100644 --- a/appservice/src/deploy/deployToStorageAccount.ts +++ b/appservice/src/deploy/deployToStorageAccount.ts @@ -13,8 +13,8 @@ import * as relativeTime from 'dayjs/plugin/relativeTime'; // eslint-disable-next-line import/no-internal-modules import * as utc from 'dayjs/plugin/utc'; import { URL } from 'url'; +import * as vscode from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; import { randomUtils } from '../utils/randomUtils'; import { IDeployContext } from './IDeployContext'; @@ -43,7 +43,7 @@ export async function deployToStorageAccount(context: IDeployContext, fsPath: st delete appSettings.properties.WEBSITE_RUN_FROM_ZIP; // delete old app setting name if it exists appSettings.properties.WEBSITE_RUN_FROM_PACKAGE = blobUrl; await client.updateApplicationSettings(appSettings); - ext.outputChannel.appendLog(localize('deploymentSuccessful', 'Deployment successful.'), { resourceName: site.fullName }); + ext.outputChannel.appendLog(vscode.l10n.t('Deployment successful.'), { resourceName: site.fullName }); context.syncTriggersPostDeploy = true; } @@ -73,7 +73,7 @@ async function createBlobServiceClient(context: IActionContext, site: ParsedSite } } } else { - throw new Error(localize('azureWebJobsStorageKey', '"{0}" app setting is required for Run From Package deployment.', azureWebJobsStorageKey)); + throw new Error(vscode.l10n.t('"{0}" app setting is required for Run From Package deployment.', azureWebJobsStorageKey)); } } @@ -88,7 +88,7 @@ async function createBlobFromZip(context: IActionContext, fsPath: string, site: await runWithZipStream(context, { fsPath, site, callback: async zipStream => { - ext.outputChannel.appendLog(localize('creatingBlob', 'Uploading zip package to storage container...'), { resourceName: site.fullName }); + ext.outputChannel.appendLog(vscode.l10n.t('Uploading zip package to storage container...'), { resourceName: site.fullName }); await blobClient.uploadStream(zipStream); } }); diff --git a/appservice/src/deploy/deployWar.ts b/appservice/src/deploy/deployWar.ts index 83f435ae26..d2a22feda4 100644 --- a/appservice/src/deploy/deployWar.ts +++ b/appservice/src/deploy/deployWar.ts @@ -5,15 +5,15 @@ import { IActionContext } from '@microsoft/vscode-azext-utils'; import * as fs from 'fs'; -import { ParsedSite } from '../SiteClient'; +import * as vscode from 'vscode'; import { publisherName } from '../constants'; -import { localize } from '../localize'; +import { ParsedSite } from '../SiteClient'; import { getFileExtension } from '../utils/pathUtils'; import { waitForDeploymentToComplete } from './waitForDeploymentToComplete'; export async function deployWar(context: IActionContext, site: ParsedSite, fsPath: string): Promise { if (getFileExtension(fsPath) !== 'war') { - throw new Error(localize('NotAWarError', 'Path specified is not a war file')); + throw new Error(vscode.l10n.t('Path specified is not a war file')); } const kuduClient = await site.createClient(context); diff --git a/appservice/src/deploy/getDeployFsPath.ts b/appservice/src/deploy/getDeployFsPath.ts index 1081a1b5ab..1f3d6192ba 100644 --- a/appservice/src/deploy/getDeployFsPath.ts +++ b/appservice/src/deploy/getDeployFsPath.ts @@ -8,7 +8,6 @@ import * as fse from 'fs-extra'; import * as path from 'path'; import * as vscode from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { isPathEqual, isSubpath } from '../utils/pathUtils'; import { getWorkspaceSetting, updateGlobalSetting } from '../utils/settings'; import * as workspaceUtil from '../utils/workspace'; @@ -49,8 +48,8 @@ export async function getDeployFsPath(context: IActionContext, target: vscode.Ur fileExtensions = [fileExtensions]; } - const selectFile: string = localize('selectDeployFile', 'Select the {0} file to deploy', fileExtensions ? fileExtensions.join('/') : ''); - const selectFolder: string = localize('selectDeployFolder', 'Select the folder to deploy'); + const selectFile: string = vscode.l10n.t('Select the {0} file to deploy', fileExtensions ? fileExtensions.join('/') : ''); + const selectFolder: string = vscode.l10n.t('Select the folder to deploy'); const selectedItem = fileExtensions ? await workspaceUtil.selectWorkspaceFile(context, selectFile, fileExtensions) : @@ -121,9 +120,9 @@ async function appendDeploySubpathSetting(context: IActionContext, workspaceFold const settingKey: string = 'showDeploySubpathWarning'; if (getWorkspaceSetting(settingKey, ext.prefix)) { const selectedFolder: string = path.relative(workspaceFolder.uri.fsPath, targetPath); - const message: string = localize('mismatchDeployPath', 'Deploying "{0}" instead of selected folder "{1}". Use "{2}.{3}" to change this behavior.', deploySubPath, selectedFolder, ext.prefix, deploySubpathSetting); + const message: string = vscode.l10n.t('Deploying "{0}" instead of selected folder "{1}". Use "{2}.{3}" to change this behavior.', deploySubPath, selectedFolder, ext.prefix, deploySubpathSetting); // don't wait - void context.ui.showWarningMessage(message, { title: localize('ok', 'OK') }, DialogResponses.dontWarnAgain).then(async (result: vscode.MessageItem) => { + void context.ui.showWarningMessage(message, { title: vscode.l10n.t('OK') }, DialogResponses.dontWarnAgain).then(async (result: vscode.MessageItem) => { if (result === DialogResponses.dontWarnAgain) { await updateGlobalSetting(settingKey, false, ext.prefix); } @@ -149,8 +148,8 @@ export type IDeployPaths = { }; function promptToOpenWorkspace(context: IActionContext, originalDeployFsPath: string): never { - const openInNewWindow: vscode.MessageItem = { title: localize('openInNewWindow', 'Open in new window') }; - const message: string = localize('folderOpenWarning', 'Failed to deploy because "{0}" is not part of an open workspace.', path.basename(originalDeployFsPath)); + const openInNewWindow: vscode.MessageItem = { title: vscode.l10n.t('Open in new window') }; + const message: string = vscode.l10n.t('Failed to deploy because "{0}" is not part of an open workspace.', path.basename(originalDeployFsPath)); // don't wait void context.ui.showWarningMessage(message, openInNewWindow).then(async result => { diff --git a/appservice/src/deploy/getDeployNode.ts b/appservice/src/deploy/getDeployNode.ts index c416fa6f18..5c9e8b542e 100644 --- a/appservice/src/deploy/getDeployNode.ts +++ b/appservice/src/deploy/getDeployNode.ts @@ -4,8 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { AzExtTreeDataProvider, AzExtTreeItem } from '@microsoft/vscode-azext-utils'; +import * as vscode from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { getWorkspaceSetting } from '../utils/settings'; import { AppSource, IDeployContext } from './IDeployContext'; @@ -28,7 +28,7 @@ export async function getDeployNode(context: IDeployCon } else if (typeof arg2 === 'string' && arg2) { node = await tree.findTreeItem(arg2, context); if (!node) { - throw new Error(localize('noMatchingApp', 'Failed to find app matching id "{0}".', arg2)); + throw new Error(vscode.l10n.t('Failed to find app matching id "{0}".', arg2)); } context.appSource = AppSource.api; } else { @@ -38,7 +38,7 @@ export async function getDeployNode(context: IDeployCon if (node) { context.appSource = AppSource.setting; } else { - ext.outputChannel.appendLog(localize('appFromSettingNotFound', 'WARNING: Failed to find app matching setting "{0}.{1}" with id "{2}"', ext.prefix, context.defaultAppSetting, defaultAppId)); + ext.outputChannel.appendLog(vscode.l10n.t('WARNING: Failed to find app matching setting "{0}.{1}" with id "{2}"', ext.prefix, context.defaultAppSetting, defaultAppId)); } } diff --git a/appservice/src/deploy/localGitDeploy.ts b/appservice/src/deploy/localGitDeploy.ts index 0a922e59ec..d81279238a 100644 --- a/appservice/src/deploy/localGitDeploy.ts +++ b/appservice/src/deploy/localGitDeploy.ts @@ -8,7 +8,6 @@ import { callWithMaskHandling, IActionContext, nonNullProp } from '@microsoft/vs import simpleGit, { Options, SimpleGit, StatusResult } from 'simple-git'; import * as vscode from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; import { openUrl } from '../utils/openUrl'; import { verifyNoRunFromPackageSetting } from '../verifyNoRunFromPackageSetting'; @@ -40,20 +39,20 @@ export async function localGitDeploy(site: ParsedSite, options: localGitOptions, try { status = await localGit.status(); if (status.files.length > 0 && !options.commit) { - const message: string = localize('localGitUncommit', '{0} uncommitted change(s) in local repo "{1}"', status.files.length, options.fsPath); - const deployAnyway: vscode.MessageItem = { title: localize('deployAnyway', 'Deploy Anyway') }; + const message: string = vscode.l10n.t('{0} uncommitted change(s) in local repo "{1}"', status.files.length, options.fsPath); + const deployAnyway: vscode.MessageItem = { title: vscode.l10n.t('Deploy Anyway') }; await context.ui.showWarningMessage(message, { modal: true, stepName: 'pushWithUncommitChanges' }, deployAnyway); context.telemetry.properties.pushWithUncommitChanges = 'true'; } await verifyNoRunFromPackageSetting(context, site); - ext.outputChannel.appendLog(localize('localGitDeploy', `Deploying Local Git repository to "${site.fullName}"...`), { resourceName: site.fullName }); + ext.outputChannel.appendLog(vscode.l10n.t(`Deploying Local Git repository to "${site.fullName}"...`), { resourceName: site.fullName }); await tryPushAndWaitForDeploymentToComplete(); } catch (err) { // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call if (err.message.indexOf('spawn git ENOENT') >= 0) { - const installString: string = localize('Install', 'Install'); - const input: string | undefined = await vscode.window.showErrorMessage(localize('GitRequired', 'Git must be installed to use Local Git Deploy.'), installString); + const installString: string = vscode.l10n.t('Install'); + const input: string | undefined = await vscode.window.showErrorMessage(vscode.l10n.t('Git must be installed to use Local Git Deploy.'), installString); if (input === installString) { await openUrl('https://git-scm.com/downloads'); } @@ -61,8 +60,8 @@ export async function localGitDeploy(site: ParsedSite, options: localGitOptions, return undefined; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call } else if (err.message.indexOf('error: failed to push') >= 0) { - const forcePushMessage: vscode.MessageItem = { title: localize('forcePush', 'Force Push') }; - const pushReject: string = localize('localGitPush', 'Push rejected due to Git history diverging.'); + const forcePushMessage: vscode.MessageItem = { title: vscode.l10n.t('Force Push') }; + const pushReject: string = vscode.l10n.t('Push rejected due to Git history diverging.'); await context.ui.showWarningMessage(pushReject, { modal: true, stepName: 'forcePush' }, forcePushMessage); context.telemetry.properties.forcePush = 'true'; diff --git a/appservice/src/deploy/runDeployTask.ts b/appservice/src/deploy/runDeployTask.ts index 8fcb1369e6..cde7c7b87f 100644 --- a/appservice/src/deploy/runDeployTask.ts +++ b/appservice/src/deploy/runDeployTask.ts @@ -6,7 +6,6 @@ import { IActionContext, UserCancelledError } from '@microsoft/vscode-azext-utils'; import * as vscode from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ScmType } from '../ScmType'; import { taskUtils } from '../utils/taskUtils'; import { IDeployContext } from './IDeployContext'; @@ -31,7 +30,7 @@ export async function tryRunPreDeployTask(context: IDeployContext, deployFsPath: const task: vscode.Task | undefined = await taskUtils.findTask(deployFsPath, taskName); context.telemetry.properties.foundPreDeployTask = String(!!task); if (task) { - const progressMessage: string = localize('runningTask', 'Running preDeployTask "{0}"...', taskName); + const progressMessage: string = vscode.l10n.t('Running preDeployTask "{0}"...', taskName); await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: progressMessage }, async () => { await taskUtils.executeIfNotActive(task); preDeployTaskResult = await waitForPreDeployTask(task, deployFsPath); @@ -58,9 +57,9 @@ export async function startPostDeployTask(context: IDeployContext, deployFsPath: context.telemetry.properties.foundPostDeployTask = String(!!task); if (task) { await taskUtils.executeIfNotActive(task); - ext.outputChannel.appendLog(localize('startedPostDeployTask', 'Started {0} "{1}".', settingKey, taskName), { resourceName }); + ext.outputChannel.appendLog(vscode.l10n.t('Started {0} "{1}".', settingKey, taskName), { resourceName }); } else { - ext.outputChannel.appendLog(localize('noPostDeployTask', 'WARNING: Failed to find {0} "{1}".', settingKey, taskName), { resourceName }); + ext.outputChannel.appendLog(vscode.l10n.t('WARNING: Failed to find {0} "{1}".', settingKey, taskName), { resourceName }); } } } @@ -75,7 +74,7 @@ function shouldExecuteTask(context: IDeployContext, scmType: string | undefined, // We don't run deploy tasks for non-zipdeploy since that stuff should be handled by kudu const shouldExecute: boolean = context.deployMethod === 'storage' || context.deployMethod === 'zip' || (scmType !== ScmType.LocalGit && scmType !== ScmType.GitHub); if (!shouldExecute) { - ext.outputChannel.appendLog(localize('ignoringDeployTask', 'WARNING: Ignoring {0} "{1}" for non-zip deploy.', settingKey, taskName)); + ext.outputChannel.appendLog(vscode.l10n.t('WARNING: Ignoring {0} "{1}" for non-zip deploy.', settingKey, taskName)); } return shouldExecute; } @@ -99,9 +98,10 @@ async function waitForPreDeployTask(preDeployTask: vscode.Task, deployFsPath: st } export async function handleFailedPreDeployTask(context: IActionContext, preDeployResult: IPreDeployTaskResult): Promise { - const message: string = localize('taskFailed', 'Errors exist after running preDeployTask "{0}". See task output for more info.', preDeployResult.taskName); - const deployAnyway: vscode.MessageItem = { title: localize('deployAnyway', 'Deploy Anyway') }; - const openSettings: vscode.MessageItem = { title: localize('openSettings', 'Open Settings') }; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const message: string = vscode.l10n.t('Errors exist after running preDeployTask "{0}". See task output for more info.', preDeployResult.taskName!); + const deployAnyway: vscode.MessageItem = { title: vscode.l10n.t('Deploy Anyway') }; + const openSettings: vscode.MessageItem = { title: vscode.l10n.t('Open Settings') }; const result: vscode.MessageItem | undefined = await vscode.window.showErrorMessage(message, { modal: true }, deployAnyway, openSettings); if (result === deployAnyway) { context.telemetry.properties.preDeployTaskResponse = 'deployAnyway'; diff --git a/appservice/src/deploy/runWithZipStream.ts b/appservice/src/deploy/runWithZipStream.ts index d6cda37811..fc8a945252 100644 --- a/appservice/src/deploy/runWithZipStream.ts +++ b/appservice/src/deploy/runWithZipStream.ts @@ -12,9 +12,8 @@ import * as prettybytes from 'pretty-bytes'; import { Readable } from 'stream'; import * as vscode from 'vscode'; import * as yazl from 'yazl'; -import { ParsedSite } from '../SiteClient'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; +import { ParsedSite } from '../SiteClient'; import { getFileExtension } from '../utils/pathUtils'; export async function runWithZipStream(context: IActionContext, options: { @@ -26,7 +25,7 @@ export async function runWithZipStream(context: IActionContext, options: { function onFileSize(size: number): void { context.telemetry.measurements.zipFileSize = size; - ext.outputChannel.appendLog(localize('zipSize', 'Zip package size: {0}', prettybytes(size)), { resourceName: site.fullName }); + ext.outputChannel.appendLog(vscode.l10n.t('Zip package size: {0}', prettybytes(size)), { resourceName: site.fullName }); } let zipStream: Readable; @@ -42,7 +41,7 @@ export async function runWithZipStream(context: IActionContext, options: { onFileSize(stats.size); }); } else { - ext.outputChannel.appendLog(localize('zipCreate', 'Creating zip package...'), { resourceName: site.fullName }); + ext.outputChannel.appendLog(vscode.l10n.t('Creating zip package...'), { resourceName: site.fullName }); const zipFile: yazl.ZipFile = new yazl.ZipFile(); let filesToZip: string[] = []; let sizeOfZipFile: number = 0; @@ -107,7 +106,7 @@ async function getFilesFromGlob(folderPath: string, site: ParsedSite): Promise 0) { - ext.outputChannel.appendLog(localize('zipIgnoreFileMsg', `Ignoring files from \"{0}.{1}\"`, ext.prefix, zipIgnorePatternStr), { resourceName: site.fullName }); + ext.outputChannel.appendLog(vscode.l10n.t(`Ignoring files from \"{0}.{1}\"`, ext.prefix, zipIgnorePatternStr), { resourceName: site.fullName }); for (const pattern of ignorePatternList) { ext.outputChannel.appendLine(`\"${pattern}\"`); } diff --git a/appservice/src/deploy/showDeployConfirmation.ts b/appservice/src/deploy/showDeployConfirmation.ts index 1dc3849dbb..d6c20f313c 100644 --- a/appservice/src/deploy/showDeployConfirmation.ts +++ b/appservice/src/deploy/showDeployConfirmation.ts @@ -5,17 +5,16 @@ import { UserCancelledError } from '@microsoft/vscode-azext-utils'; import { join } from 'path'; -import { commands, MessageItem, Uri, window } from "vscode"; +import { commands, l10n, MessageItem, Uri, window } from "vscode"; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; import { delay } from '../utils/delay'; import { updateWorkspaceSetting } from '../utils/settings'; import { AppSource, IDeployContext } from './IDeployContext'; export async function showDeployConfirmation(context: IDeployContext, site: ParsedSite, deployCommandId: string): Promise { - const warning: string = localize('confirmDeploy', 'Are you sure you want to deploy to "{0}"? This will overwrite any previous deployment and cannot be undone.', site.fullName); - const items: MessageItem[] = [{ title: localize('deploy', 'Deploy') }]; + const warning: string = l10n.t('Are you sure you want to deploy to "{0}"? This will overwrite any previous deployment and cannot be undone.', site.fullName); + const items: MessageItem[] = [{ title: l10n.t('Deploy') }]; const resetDefault: MessageItem = { title: 'Reset default' }; if (context.appSource === AppSource.setting) { items.push(resetDefault); diff --git a/appservice/src/deploy/syncTriggersPostDeploy.ts b/appservice/src/deploy/syncTriggersPostDeploy.ts index e5b205c521..b9b05d8082 100644 --- a/appservice/src/deploy/syncTriggersPostDeploy.ts +++ b/appservice/src/deploy/syncTriggersPostDeploy.ts @@ -3,10 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as retry from 'p-retry'; import { IActionContext } from '@microsoft/vscode-azext-utils'; +import * as retry from 'p-retry'; +import * as vscode from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; import { delay } from '../utils/delay'; @@ -23,8 +23,8 @@ export async function syncTriggersPostDeploy(context: IActionContext, site: Pars await retry( async (currentAttempt: number) => { const message: string = currentAttempt === 1 ? - localize('syncingTriggers', 'Syncing triggers...') : - localize('syncingTriggersAttempt', 'Syncing triggers (Attempt {0}/{1})...', currentAttempt, retries + 1); + vscode.l10n.t('Syncing triggers...') : + vscode.l10n.t('Syncing triggers (Attempt {0}/{1})...', currentAttempt, retries + 1); ext.outputChannel.appendLog(message, { resourceName: site.fullName }); await client.syncFunctionTriggers(); }, diff --git a/appservice/src/deploy/waitForDeploymentToComplete.ts b/appservice/src/deploy/waitForDeploymentToComplete.ts index f4505b9f24..e9a7ebe38a 100644 --- a/appservice/src/deploy/waitForDeploymentToComplete.ts +++ b/appservice/src/deploy/waitForDeploymentToComplete.ts @@ -5,11 +5,10 @@ import { sendRequestWithTimeout } from '@microsoft/vscode-azext-azureutils'; import { IActionContext, IParsedError, nonNullProp, nonNullValue, parseError } from '@microsoft/vscode-azext-utils'; -import { CancellationToken, window } from 'vscode'; +import { CancellationToken, l10n, window } from 'vscode'; import type { KuduModels } from 'vscode-azurekudu'; -import { ParsedSite, SiteClient } from '../SiteClient'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; +import { ParsedSite, SiteClient } from '../SiteClient'; import { delay } from '../utils/delay'; import { ignore404Error, retryKuduCall } from '../utils/kuduUtils'; import { IDeployContext } from './IDeployContext'; @@ -57,7 +56,7 @@ export async function waitForDeploymentToComplete(context: IActionContext & Part continue; } - throw new Error(localize('failedToFindDeployment', 'Failed to get status of deployment.')); + throw new Error(l10n.t('Failed to get status of deployment.')); } const deploymentId: string = deployment.id; @@ -101,8 +100,8 @@ export async function waitForDeploymentToComplete(context: IActionContext & Part if (deployment.complete) { if (deployment.status === 3 /* Failed */ || deployment.isTemp) { // If the deployment completed without making it to the "permanent" phase, it must have failed - const message: string = localize('deploymentFailed', 'Deployment to "{0}" failed.', site.fullName); - const viewOutput: string = localize('viewOutput', 'View Output'); + const message: string = l10n.t('Deployment to "{0}" failed.', site.fullName); + const viewOutput: string = l10n.t('View Output'); // don't wait void window.showErrorMessage(message, viewOutput).then(result => { if (result === viewOutput) { @@ -110,7 +109,7 @@ export async function waitForDeploymentToComplete(context: IActionContext & Part } }); - const messageWithoutName: string = localize('deploymentFailedWithoutName', 'Deployment failed.'); + const messageWithoutName: string = l10n.t('Deployment failed.'); ext.outputChannel.appendLog(messageWithoutName, { resourceName: site.fullName }); context.errorHandling.suppressDisplay = true; // Hopefully the last line is enough to give us an idea why deployments are failing without excessively tracking everything diff --git a/appservice/src/disconnectRepo.ts b/appservice/src/disconnectRepo.ts index 2a651379cc..4889ecc801 100644 --- a/appservice/src/disconnectRepo.ts +++ b/appservice/src/disconnectRepo.ts @@ -5,17 +5,17 @@ import type { SiteSourceControl } from '@azure/arm-appservice'; import { IActionContext, ISubscriptionContext } from '@microsoft/vscode-azext-utils'; -import { MessageItem } from 'vscode'; +import { l10n, MessageItem } from 'vscode'; import { editScmType } from './editScmType'; -import { localize } from './localize'; import { ScmType } from './ScmType'; import { ParsedSite } from './SiteClient'; export async function disconnectRepo(context: IActionContext, site: ParsedSite, subscriptionContext: ISubscriptionContext): Promise { const client = await site.createClient(context); const sourceControl: SiteSourceControl = await client.getSourceControl(); - const disconnectButton: MessageItem = { title: localize('disconnect', 'Disconnect') }; - const disconnect: string = localize('disconnectFromRepo', 'Disconnect from "{0}"? This will not affect your app\'s active deployment. You may reconnect a repository at any time.', sourceControl.repoUrl); + const disconnectButton: MessageItem = { title: l10n.t('Disconnect') }; + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const disconnect: string = l10n.t('Disconnect from "{0}"? This will not affect your app\'s active deployment. You may reconnect a repository at any time.', sourceControl.repoUrl!); await context.ui.showWarningMessage(disconnect, { modal: true, stepName: 'disconnectRepo' }, disconnectButton); await editScmType(context, site, subscriptionContext, ScmType.None); } diff --git a/appservice/src/editScmType.ts b/appservice/src/editScmType.ts index d14461a523..a1c98fb44c 100644 --- a/appservice/src/editScmType.ts +++ b/appservice/src/editScmType.ts @@ -4,11 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import type { SiteConfigResource, User } from '@azure/arm-appservice'; -import { IActionContext, IAzureQuickPickItem, IAzureQuickPickOptions, ISubscriptionContext, nonNullProp, UserCancelledError } from '@microsoft/vscode-azext-utils'; -import { window } from 'vscode'; +import { IActionContext, IAzureQuickPickItem, IAzureQuickPickOptions, ISubscriptionContext, UserCancelledError, nonNullProp } from '@microsoft/vscode-azext-utils'; +import { l10n, window } from 'vscode'; import { ext } from './extensionVariables'; // import { connectToGitHub } from './github/connectToGitHub'; -import { localize } from './localize'; import { ScmType } from './ScmType'; import { ParsedSite } from './SiteClient'; @@ -16,7 +15,7 @@ export async function editScmType(context: IActionContext, site: ParsedSite, sub const client = await site.createClient(context); if (site.isLinux && await client.getIsConsumption(context)) { context.errorHandling.suppressReportIssue = true; - throw new Error(localize('noEditScmOnLinuxCons', 'Linux consumption plans only support zip deploy. See [here](https://aka.ms/AA7avjx) for more information.')); + throw new Error(l10n.t('Linux consumption plans only support zip deploy. See [here](https://aka.ms/AA7avjx) for more information.')); } const config: SiteConfigResource = await client.getSiteConfig(); @@ -33,7 +32,7 @@ export async function editScmType(context: IActionContext, site: ParsedSite, sub await client.updateConfiguration(config); } if (showToast) { - const scmTypeUpdated: string = localize('deploymentSourceUpdated,', 'Deployment source for "{0}" has been updated to "{1}".', site.fullName, newScmType); + const scmTypeUpdated: string = l10n.t('Deployment source for "{0}" has been updated to "{1}".', site.fullName, newScmType); ext.outputChannel.appendLog(scmTypeUpdated); void window.showInformationMessage(scmTypeUpdated); } @@ -43,7 +42,7 @@ export async function editScmType(context: IActionContext, site: ParsedSite, sub if (user.publishingUserName) { // first time users must set up deployment credentials via the Portal or they will not have a UserName const gitCloneUri: string = `https://${user.publishingUserName}@${site.gitUrl}`; - ext.outputChannel.appendLog(localize('gitCloneUri', 'Git Clone Uri for "{0}": "{1}"', site.fullName, gitCloneUri)); + ext.outputChannel.appendLog(l10n.t('Git Clone Uri for "{0}": "{1}"', site.fullName, gitCloneUri)); } } // returns the updated scmType @@ -51,7 +50,7 @@ export async function editScmType(context: IActionContext, site: ParsedSite, sub } async function showScmPrompt(context: IActionContext, currentScmType: string): Promise { - const currentSource: string = localize('currentSource', '(Current source)'); + const currentSource: string = l10n.t('(Current source)'); const scmQuickPicks: IAzureQuickPickItem[] = []; // generate quickPicks to not include current type for (const key of Object.keys(ScmType)) { @@ -65,7 +64,7 @@ async function showScmPrompt(context: IActionContext, currentScmType: string): P } const options: IAzureQuickPickOptions = { - placeHolder: localize('scmPrompt', 'Select a new source.'), + placeHolder: l10n.t('Select a new source.'), suppressPersistence: true, stepName: 'editScmType' }; diff --git a/appservice/src/extensionVariables.ts b/appservice/src/extensionVariables.ts index 91f30b1610..cfb1f43920 100644 --- a/appservice/src/extensionVariables.ts +++ b/appservice/src/extensionVariables.ts @@ -5,11 +5,10 @@ import { IAzureUtilsExtensionVariables, registerAzureUtilsExtensionVariables } from "@microsoft/vscode-azext-azureutils"; import { IAzExtOutputChannel, IAzureUserInput, registerUIExtensionVariables, UIExtensionVariables } from "@microsoft/vscode-azext-utils"; -import { ExtensionContext } from "vscode"; -import { localize } from "./localize"; +import { ExtensionContext, l10n } from "vscode"; class UninitializedExtensionVariables implements UIExtensionVariables, IAzureUtilsExtensionVariables { - private _error: Error = new Error(localize('uninitializedError', '"registerUIExtensionVariables" must be called before using the vscode-azureappservice package.')); + private _error: Error = new Error(l10n.t('"registerUIExtensionVariables" must be called before using the vscode-azureappservice package.')); public get context(): ExtensionContext { throw this._error; diff --git a/appservice/src/github/GitHubBranchListStep.ts b/appservice/src/github/GitHubBranchListStep.ts index e96b8475a4..69cd185abc 100644 --- a/appservice/src/github/GitHubBranchListStep.ts +++ b/appservice/src/github/GitHubBranchListStep.ts @@ -4,13 +4,13 @@ // *--------------------------------------------------------------------------------------------*/ // import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullProp } from '@microsoft/vscode-azext-utils'; -// import { localize } from '../localize'; +// import * as vscode from 'vscode'; // import { getGitHubQuickPicksWithLoadMore, gitHubBranchData, ICachedQuickPicks } from './connectToGitHub'; // import { IConnectToGitHubWizardContext } from './IConnectToGitHubWizardContext'; // export class GitHubBranchListStep extends AzureWizardPromptStep { // public async prompt(context: IConnectToGitHubWizardContext): Promise { -// const placeHolder: string = localize('chooseBranch', 'Choose branch'); +// const placeHolder: string = vscode.l10n.t('Choose branch'); // let branchData: gitHubBranchData | string; // const picksCache: ICachedQuickPicks = { picks: [] }; // let url: string = `${nonNullProp(context, 'repoData').url}/branches`; diff --git a/appservice/src/github/GitHubOrgListStep.ts b/appservice/src/github/GitHubOrgListStep.ts index 04c593f39d..60508d2254 100644 --- a/appservice/src/github/GitHubOrgListStep.ts +++ b/appservice/src/github/GitHubOrgListStep.ts @@ -4,13 +4,13 @@ // *--------------------------------------------------------------------------------------------*/ // import { AzureWizardPromptStep, IAzureQuickPickItem } from '@microsoft/vscode-azext-utils'; -// import { localize } from '../localize'; +// import * as vscode from 'vscode'; // import { createQuickPickFromJsons, getGitHubJsonResponse, gitHubOrgData } from './connectToGitHub'; // import { IConnectToGitHubWizardContext } from './IConnectToGitHubWizardContext'; // export class GitHubOrgListStep extends AzureWizardPromptStep { // public async prompt(context: IConnectToGitHubWizardContext): Promise { -// const placeHolder: string = localize('chooseOrg', 'Choose organization.'); +// const placeHolder: string = vscode.l10n.t('Choose organization.'); // context.orgData = (await context.ui.showQuickPick(this.getOrganizations(context), { placeHolder })).data; // } diff --git a/appservice/src/github/GitHubRepoListStep.ts b/appservice/src/github/GitHubRepoListStep.ts index 1755b0b18a..533921f921 100644 --- a/appservice/src/github/GitHubRepoListStep.ts +++ b/appservice/src/github/GitHubRepoListStep.ts @@ -4,13 +4,13 @@ // *--------------------------------------------------------------------------------------------*/ // import { AzureWizardPromptStep, IAzureQuickPickItem, nonNullProp } from '@microsoft/vscode-azext-utils'; -// import { localize } from '../localize'; +// import * as vscode from 'vscode'; // import { getGitHubQuickPicksWithLoadMore, gitHubRepoData, ICachedQuickPicks } from './connectToGitHub'; // import { IConnectToGitHubWizardContext } from './IConnectToGitHubWizardContext'; // export class GitHubRepoListStep extends AzureWizardPromptStep { // public async prompt(context: IConnectToGitHubWizardContext): Promise { -// const placeHolder: string = localize('chooseRepo', 'Choose repository'); +// const placeHolder: string = vscode.l10n.t('Choose repository'); // let repoData: gitHubRepoData | string; // const picksCache: ICachedQuickPicks = { picks: [] }; diff --git a/appservice/src/github/connectToGitHub.ts b/appservice/src/github/connectToGitHub.ts index 78981c518d..a157959ee5 100644 --- a/appservice/src/github/connectToGitHub.ts +++ b/appservice/src/github/connectToGitHub.ts @@ -12,7 +12,6 @@ // import * as vscode from 'vscode'; // import { ParsedSite } from '../SiteClient'; // import { ext } from '../extensionVariables'; -// import { localize } from '../localize'; // import { openUrl } from '../utils/openUrl'; // import { verifyNoRunFromPackageSetting } from '../verifyNoRunFromPackageSetting'; // import { GitHubBranchListStep } from './GitHubBranchListStep'; @@ -26,7 +25,7 @@ // export type gitHubLink = { prev?: string, next?: string, last?: string, first?: string }; // export async function connectToGitHub(site: ParsedSite, context: IConnectToGitHubWizardContext): Promise { -// const title: string = localize('connectGitHubRepo', 'Connect GitHub repository'); +// const title: string = vscode.l10n.t('Connect GitHub repository'); // context.site = site; // const wizard: AzureWizard = new AzureWizard(context, { @@ -52,8 +51,8 @@ // const client = await site.createClient(context); // try { -// const connectingToGithub: string = localize('ConnectingToGithub', '"{0}" is being connected to repo "{1}". This may take several minutes...', site.fullName, repoName); -// const connectedToGithub: string = localize('ConnectedToGithub', 'Repo "{0}" is connected and deployed to "{1}".', repoName, site.fullName); +// const connectingToGithub: string = vscode.l10n.t('"{0}" is being connected to repo "{1}". This may take several minutes...', site.fullName, repoName); +// const connectedToGithub: string = vscode.l10n.t('Repo "{0}" is connected and deployed to "{1}".', repoName, site.fullName); // await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, title: connectingToGithub }, async (): Promise => { // ext.outputChannel.appendLog(connectingToGithub); // await verifyNoRunFromPackageSetting(context, site); @@ -77,8 +76,8 @@ // } // async function showGitHubAuthPrompt(context: IConnectToGitHubWizardContext, site: ParsedSite): Promise { -// const invalidToken: string = localize('tokenExpired', 'Azure\'s GitHub token is invalid. Authorize in the "Deployment Center"'); -// const goToPortal: vscode.MessageItem = { title: localize('goToPortal', 'Go to Portal') }; +// const invalidToken: string = vscode.l10n.t('Azure\'s GitHub token is invalid. Authorize in the "Deployment Center"'); +// const goToPortal: vscode.MessageItem = { title: vscode.l10n.t('Go to Portal') }; // let input: vscode.MessageItem | undefined = DialogResponses.learnMore; // while (input === DialogResponses.learnMore) { // input = await vscode.window.showErrorMessage(invalidToken, { modal: true }, goToPortal, DialogResponses.learnMore); @@ -194,7 +193,7 @@ // if (!oAuth2Token) { // await showGitHubAuthPrompt(context, site); // context.errorHandling.suppressDisplay = true; -// const noToken: string = localize('noToken', 'No oAuth2 Token.'); +// const noToken: string = vscode.l10n.t('No oAuth2 Token.'); // throw new Error(noToken); // } diff --git a/appservice/src/localize.ts b/appservice/src/localize.ts deleted file mode 100644 index 2aee3fa12f..0000000000 --- a/appservice/src/localize.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'; - -export const localize: nls.LocalizeFunc = nls.loadMessageBundle(); diff --git a/appservice/src/registerSiteCommand.ts b/appservice/src/registerSiteCommand.ts index c6016ee148..5da20bb570 100644 --- a/appservice/src/registerSiteCommand.ts +++ b/appservice/src/registerSiteCommand.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { CommandCallback, IActionContext, IParsedError, parseError, registerCommand } from '@microsoft/vscode-azext-utils'; -import { localize } from './localize'; +import * as vscode from 'vscode'; /** * Use this to get extra error handling for commands that interact directly with site APIs. @@ -29,7 +29,7 @@ function handleSiteErrors(context: IActionContext, error: unknown): void { const parsedError: IParsedError = parseError(error); if (parsedError.errorType === '502' || parsedError.errorType === '503') { context.errorHandling.suppressReportIssue = true; - const troubleshooting: string = localize('502or503Troubleshooting', 'View troubleshooting tips [here](https://aka.ms/AA772mm).'); + const troubleshooting: string = vscode.l10n.t('View troubleshooting tips [here](https://aka.ms/AA772mm).'); throw new Error(`${parsedError.message} ${troubleshooting}`); } else { throw error; diff --git a/appservice/src/remoteDebug/remoteDebugCommon.ts b/appservice/src/remoteDebug/remoteDebugCommon.ts index f688b88a93..b9936fe5b9 100644 --- a/appservice/src/remoteDebug/remoteDebugCommon.ts +++ b/appservice/src/remoteDebug/remoteDebugCommon.ts @@ -7,7 +7,6 @@ import type { SiteConfigResource } from '@azure/arm-appservice'; import { callWithTelemetryAndErrorHandling, IActionContext, UserCancelledError } from '@microsoft/vscode-azext-utils'; import * as vscode from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; export function reportMessage(message: string, progress: vscode.Progress<{}>, token: vscode.CancellationToken): void { @@ -23,7 +22,7 @@ export async function setRemoteDebug(context: IActionContext, isRemoteDebuggingT const client = await site.createClient(context); const state: string | undefined = await client.getState(); if (state && state.toLowerCase() === 'stopped') { - throw new Error(localize('remoteDebugStopped', 'The app must be running, but is currently in state "Stopped". Start the app to continue.')); + throw new Error(vscode.l10n.t('The app must be running, but is currently in state "Stopped". Start the app to continue.')); } if (isRemoteDebuggingToBeEnabled !== siteConfig.remoteDebuggingEnabled) { @@ -32,7 +31,7 @@ export async function setRemoteDebug(context: IActionContext, isRemoteDebuggingT // don't have to check input as this handles cancels and learnMore responses await context.ui.showWarningMessage(confirmMessage, { modal: true, learnMoreLink }, confirmButton); siteConfig.remoteDebuggingEnabled = isRemoteDebuggingToBeEnabled; - reportMessage(localize('remoteDebugUpdate', 'Updating site configuration to set remote debugging...'), progress, token); + reportMessage(vscode.l10n.t('Updating site configuration to set remote debugging...'), progress, token); await callWithTelemetryAndErrorHandling('appService.remoteDebugUpdateConfiguration', async (updateContext: IActionContext) => { updateContext.errorHandling.suppressDisplay = true; @@ -40,7 +39,7 @@ export async function setRemoteDebug(context: IActionContext, isRemoteDebuggingT await client.updateConfiguration(siteConfig); }); - reportMessage(localize('remoteDebugUpdateDone', 'Updating site configuration done.'), progress, token); + reportMessage(vscode.l10n.t('Updating site configuration done.'), progress, token); } else { // Update not needed if (noopMessage) { diff --git a/appservice/src/remoteDebug/startRemoteDebug.ts b/appservice/src/remoteDebug/startRemoteDebug.ts index 9618be8de2..94420492ac 100644 --- a/appservice/src/remoteDebug/startRemoteDebug.ts +++ b/appservice/src/remoteDebug/startRemoteDebug.ts @@ -6,7 +6,6 @@ import type { SiteConfigResource, User } from '@azure/arm-appservice'; import { callWithTelemetryAndErrorHandling, findFreePort, IActionContext } from '@microsoft/vscode-azext-utils'; import * as vscode from 'vscode'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; import { TunnelProxy } from '../TunnelProxy'; import { reportMessage, setRemoteDebug } from './remoteDebugCommon'; @@ -22,7 +21,7 @@ export enum RemoteDebugLanguage { export async function startRemoteDebug(context: IActionContext, site: ParsedSite, siteConfig: SiteConfigResource, language: RemoteDebugLanguage): Promise { if (isRemoteDebugging) { - throw new Error(localize('remoteDebugAlreadyStarted', 'Azure Remote Debugging is currently starting or already started.')); + throw new Error(vscode.l10n.t('Azure Remote Debugging is currently starting or already started.')); } isRemoteDebugging = true; @@ -39,10 +38,10 @@ async function startRemoteDebugInternal(context: IActionContext, site: ParsedSit const localHostPortNumber: number = await findFreePort(); const debugConfig: vscode.DebugConfiguration = await getDebugConfiguration(language, localHostPortNumber); - const confirmEnableMessage: string = localize('remoteDebugEnablePrompt', 'The configuration will be updated to enable remote debugging. Would you like to continue? This will restart the app.'); + const confirmEnableMessage: string = vscode.l10n.t('The configuration will be updated to enable remote debugging. Would you like to continue? This will restart the app.'); await setRemoteDebug(context, true, confirmEnableMessage, undefined, site, siteConfig, progress, token, remoteDebugLink); - reportMessage(localize('remoteDebugStartingTunnel', 'Starting tunnel proxy...'), progress, token); + reportMessage(vscode.l10n.t('Starting tunnel proxy...'), progress, token); const client = await site.createClient(context); const publishCredential: User = await client.getWebAppPublishCredential(); @@ -53,7 +52,7 @@ async function startRemoteDebugInternal(context: IActionContext, site: ParsedSit await tunnelProxy.startProxy(context, token); }); - reportMessage(localize('remoteDebugAttaching', 'Attaching debugger...'), progress, token); + reportMessage(vscode.l10n.t('Attaching debugger...'), progress, token); await callWithTelemetryAndErrorHandling('appService.remoteDebugAttach', async (attachContext: IActionContext) => { attachContext.errorHandling.suppressDisplay = true; @@ -61,7 +60,7 @@ async function startRemoteDebugInternal(context: IActionContext, site: ParsedSit await vscode.debug.startDebugging(undefined, debugConfig); }); - reportMessage(localize('remoteDebugAttached', 'Attached!'), progress, token); + reportMessage(vscode.l10n.t('Attached!'), progress, token); const terminateDebugListener: vscode.Disposable = vscode.debug.onDidTerminateDebugSession(async (event: vscode.DebugSession) => { if (event.name === debugConfig.name) { @@ -72,7 +71,7 @@ async function startRemoteDebugInternal(context: IActionContext, site: ParsedSit } terminateDebugListener.dispose(); - const confirmDisableMessage: string = localize('remoteDebugDisablePrompt', 'Remaining in debugging mode may cause performance issues. Would you like to disable debugging? This will restart the app.'); + const confirmDisableMessage: string = vscode.l10n.t('Remaining in debugging mode may cause performance issues. Would you like to disable debugging? This will restart the app.'); await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: true }, async (innerProgress, innerToken): Promise => { await setRemoteDebug(context, false, confirmDisableMessage, undefined, site, siteConfig, innerProgress, innerToken, remoteDebugLink); }); @@ -91,7 +90,7 @@ async function getDebugConfiguration(language: RemoteDebugLanguage, portNumber: case RemoteDebugLanguage.Python: return await getPythonDebugConfiguration(sessionId, portNumber, host); default: - throw new Error(localize('remoteDebugLanguageNotSupported', 'The language "{0}" is not supported for remote debugging.', language)); + throw new Error(vscode.l10n.t('The language "{0}" is not supported for remote debugging.', language)); } } @@ -107,11 +106,11 @@ async function getDebugPath(): Promise { if (root) return root.uri.fsPath; else - throw new Error(localize('remoteDebugNoFolders', 'Please select a workspace folder before attaching a debugger.')); + throw new Error(vscode.l10n.t('Please select a workspace folder before attaching a debugger.')); } } else { // vscode will throw an error if you try to start debugging without any workspace folder open - throw new Error(localize('remoteDebugNoFolders', 'Please open a workspace folder before attaching a debugger.')); + throw new Error(vscode.l10n.t('Please open a workspace folder before attaching a debugger.')); } } diff --git a/appservice/src/startStreamingLogs.ts b/appservice/src/startStreamingLogs.ts index 799468cdf4..446606f375 100644 --- a/appservice/src/startStreamingLogs.ts +++ b/appservice/src/startStreamingLogs.ts @@ -13,7 +13,6 @@ import { setInterval } from 'timers'; import * as vscode from 'vscode'; import { ParsedSite } from './SiteClient'; import { ext } from './extensionVariables'; -import { localize } from './localize'; import { pingFunctionApp } from './pingFunctionApp'; export interface ILogStream extends vscode.Disposable { @@ -32,15 +31,15 @@ export async function startStreamingLogs(context: IActionContext, site: ParsedSi const logStream: ILogStream | undefined = logStreams.get(logStreamId); if (logStream && logStream.isConnected) { logStream.outputChannel.show(); - void context.ui.showWarningMessage(localize('logStreamAlreadyActive', 'The log-streaming service for "{0}" is already active.', logStreamLabel)); + void context.ui.showWarningMessage(vscode.l10n.t('The log-streaming service for "{0}" is already active.', logStreamLabel)); return logStream; } else { await verifyLoggingEnabled(); - const outputChannel: vscode.OutputChannel = logStream ? logStream.outputChannel : vscode.window.createOutputChannel(localize('logStreamLabel', '{0} - Log Stream', logStreamLabel)); + const outputChannel: vscode.OutputChannel = logStream ? logStream.outputChannel : vscode.window.createOutputChannel(vscode.l10n.t('{0} - Log Stream', logStreamLabel)); ext.context.subscriptions.push(outputChannel); outputChannel.show(); - outputChannel.appendLine(localize('connectingToLogStream', 'Connecting to log stream...')); + outputChannel.appendLine(vscode.l10n.t('Connecting to log stream...')); const client = await site.createClient(context); const creds: User = await client.getWebAppPublishCredential(); @@ -78,7 +77,7 @@ export async function startStreamingLogs(context: IActionContext, site: ParsedSi if (timerId) { clearInterval(timerId); } - outputChannel.appendLine(localize('logStreamDisconnected', 'Disconnected from log-streaming service.')); + outputChannel.appendLine(vscode.l10n.t('Disconnected from log-streaming service.')); newLogStream.isConnected = false; void onLogStreamEnded(); }, @@ -94,7 +93,7 @@ export async function startStreamingLogs(context: IActionContext, site: ParsedSi } newLogStream.isConnected = false; outputChannel.show(); - outputChannel.appendLine(localize('logStreamError', 'Error connecting to log-streaming service:')); + outputChannel.appendLine(vscode.l10n.t('Error connecting to log-streaming service:')); outputChannel.appendLine(parseError(err).message); reject(err); }).on('complete', () => { @@ -115,6 +114,6 @@ export async function stopStreamingLogs(site: ParsedSite, logsPath: string = '') if (logStream && logStream.isConnected) { logStream.dispose(); } else { - await vscode.window.showWarningMessage(localize('alreadyDisconnected', 'The log-streaming service is already disconnected.')); + await vscode.window.showWarningMessage(vscode.l10n.t('The log-streaming service is already disconnected.')); } } diff --git a/appservice/src/swapSlot.ts b/appservice/src/swapSlot.ts index d0984ec90e..88a42ca376 100644 --- a/appservice/src/swapSlot.ts +++ b/appservice/src/swapSlot.ts @@ -5,9 +5,8 @@ import type { WebSiteManagementClient } from '@azure/arm-appservice'; import { IActionContext, IAzureQuickPickItem } from '@microsoft/vscode-azext-utils'; -import { ProgressLocation, window } from 'vscode'; +import { l10n, ProgressLocation, window } from 'vscode'; import { ext } from './extensionVariables'; -import { localize } from './localize'; import { ParsedSite } from './SiteClient'; import { createWebSiteClient } from './utils/azureClients'; @@ -31,12 +30,13 @@ export async function swapSlot(context: IActionContext, sourceSlot: ParsedSite, } } - const placeHolder: string = localize('selectSlotToSwap', 'Select which slot to swap with "{0}".', sourceSlot.slotName); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const placeHolder: string = l10n.t('Select which slot to swap with "{0}".', sourceSlot.slotName!); const targetSlot = (await context.ui.showQuickPick(otherSlots, { placeHolder, stepName: 'swapSlot' })).data; const targetSlotLabel: string = targetSlot ? targetSlot.fullName : `${sourceSlot.siteName}-${productionSlotLabel}`; - const swappingSlots: string = localize('swapping', 'Swapping "{0}" with "{1}"...', targetSlotLabel, sourceSlot.fullName); - const successfullySwapped: string = localize('swapped', 'Successfully swapped "{0}" with "{1}".', targetSlotLabel, sourceSlot.fullName); + const swappingSlots: string = l10n.t('Swapping "{0}" with "{1}"...', targetSlotLabel, sourceSlot.fullName); + const successfullySwapped: string = l10n.t('Successfully swapped "{0}" with "{1}".', targetSlotLabel, sourceSlot.fullName); ext.outputChannel.appendLog(swappingSlots); const client: WebSiteManagementClient = await createWebSiteClient([context, sourceSlot.subscription]); await window.withProgress({ location: ProgressLocation.Notification, title: swappingSlots }, async () => { diff --git a/appservice/src/tree/DeploymentTreeItem.ts b/appservice/src/tree/DeploymentTreeItem.ts index 905329671a..b9a0e33149 100644 --- a/appservice/src/tree/DeploymentTreeItem.ts +++ b/appservice/src/tree/DeploymentTreeItem.ts @@ -4,13 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import type { SiteSourceControl } from '@azure/arm-appservice'; -import { AzExtTreeItem, IActionContext, TreeItemIconPath, createContextValue, nonNullProp, openReadOnlyContent } from '@microsoft/vscode-azext-utils'; +import { AzExtTreeItem, createContextValue, IActionContext, nonNullProp, openReadOnlyContent, TreeItemIconPath } from '@microsoft/vscode-azext-utils'; import * as os from 'os'; -import { ProgressLocation, ThemeIcon, window } from 'vscode'; +import { l10n, ProgressLocation, ThemeIcon, window } from 'vscode'; import type { KuduModels } from 'vscode-azurekudu'; import { waitForDeploymentToComplete } from '../deploy/waitForDeploymentToComplete'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ignore404Error, retryKuduCall } from '../utils/kuduUtils'; import { openUrl } from '../utils/openUrl'; import { DeploymentsTreeItem } from './DeploymentsTreeItem'; @@ -62,18 +61,18 @@ export class DeploymentTreeItem extends AzExtTreeItem { public get description(): string | undefined { if (this._deployResult.active) { - return localize('active', 'Active'); + return l10n.t('Active'); } switch (this._deployResult.status) { case DeployStatus.Building: - return localize('building', 'Building...'); + return l10n.t('Building...'); case DeployStatus.Deploying: - return localize('deploying', 'Deploying...'); + return l10n.t('Deploying...'); case DeployStatus.Pending: - return localize('pending', 'Pending...'); + return l10n.t('Pending...'); case DeployStatus.Failed: - return localize('failed', 'Failed'); + return l10n.t('Failed'); case DeployStatus.Success: default: return; @@ -86,12 +85,12 @@ export class DeploymentTreeItem extends AzExtTreeItem { public async redeployDeployment(context: IActionContext): Promise { if (this._deployResult.isReadonly) { - throw new Error(localize('redeployNotSupported', 'Redeploy is not supported for non-git deployments.')); + throw new Error(l10n.t('Redeploy is not supported for non-git deployments.')); } - const redeploying: string = localize('redeploying', 'Redeploying commit "{0}" to "{1}". Check [output window](command:{2}) for status.', this.id, this.parent.site.fullName, ext.prefix + '.showOutputChannel'); - const redeployed: string = localize('redeployed', 'Commit "{0}" has been redeployed to "{1}".', this.id, this.parent.site.fullName); + const redeploying: string = l10n.t('Redeploying commit "{0}" to "{1}". Check [output window](command:{2}) for status.', this.id, this.parent.site.fullName, ext.prefix + '.showOutputChannel'); + const redeployed: string = l10n.t('Commit "{0}" has been redeployed to "{1}".', this.id, this.parent.site.fullName); await window.withProgress({ location: ProgressLocation.Notification, title: redeploying }, async (): Promise => { - ext.outputChannel.appendLog(localize('reployingOutput', 'Redeploying commit "{0}" to "{1}"...', this.id, this.parent.site.fullName), { resourceName: this.parent.site.fullName }); + ext.outputChannel.appendLog(l10n.t('Redeploying commit "{0}" to "{1}"...', this.id, this.parent.site.fullName), { resourceName: this.parent.site.fullName }); const kuduClient = await this.parent.site.createClient(context); void kuduClient.deploy(context, this.id); @@ -139,7 +138,7 @@ export class DeploymentTreeItem extends AzExtTreeItem { } public async viewDeploymentLogs(context: IActionContext): Promise { - await this.runWithTemporaryDescription(context, localize('retrievingLogs', 'Retrieving logs...'), async () => { + await this.runWithTemporaryDescription(context, l10n.t('Retrieving logs...'), async () => { const logData: string = await this.getDeploymentLogs(context); await openReadOnlyContent(this, logData, '.log'); }); @@ -153,7 +152,8 @@ export class DeploymentTreeItem extends AzExtTreeItem { await openUrl(gitHubCommitUrl); return; } else { - throw new Error(localize('noRepoUrl', 'There is no GitHub repo url associated with deployment "{0}".', this._deployResult.id)); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + throw new Error(l10n.t('There is no GitHub repo url associated with deployment "{0}".', this._deployResult.id!)); } } diff --git a/appservice/src/tree/DeploymentsTreeItem.ts b/appservice/src/tree/DeploymentsTreeItem.ts index 51532f5b6f..565ed1cab4 100644 --- a/appservice/src/tree/DeploymentsTreeItem.ts +++ b/appservice/src/tree/DeploymentsTreeItem.ts @@ -4,13 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import type { SiteConfig, SiteSourceControl } from '@azure/arm-appservice'; -import { AzExtParentTreeItem, AzExtTreeItem, GenericTreeItem, IActionContext, TreeItemIconPath, createContextValue } from '@microsoft/vscode-azext-utils'; -import { ThemeIcon } from 'vscode'; +import { AzExtParentTreeItem, AzExtTreeItem, createContextValue, GenericTreeItem, IActionContext, TreeItemIconPath } from '@microsoft/vscode-azext-utils'; +import { l10n, ThemeIcon } from 'vscode'; import { KuduModels } from 'vscode-azurekudu'; +import { ext } from '../extensionVariables'; import { ScmType } from '../ScmType'; import { ParsedSite } from '../SiteClient'; -import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { retryKuduCall } from '../utils/kuduUtils'; import { DeploymentTreeItem } from './DeploymentTreeItem'; @@ -27,8 +26,8 @@ interface DeploymentsTreeItemOptions { export class DeploymentsTreeItem extends AzExtParentTreeItem { public static contextValueConnected: string = 'deploymentsConnected'; public static contextValueUnconnected: string = 'deploymentsUnconnected'; - public readonly label: string = localize('Deployments', 'Deployments'); - public readonly childTypeLabel: string = localize('Deployment', 'Deployment'); + public readonly label: string = l10n.t('Deployments'); + public readonly childTypeLabel: string = l10n.t('Deployment'); public readonly site: ParsedSite; public suppressMaskLabel: boolean = true; public readonly contextValuesToAdd: string[]; @@ -51,10 +50,10 @@ export class DeploymentsTreeItem extends AzExtParentTreeItem { public get description(): string { switch (this._scmType) { case ScmType.LocalGit: - return localize('git', 'Git'); + return l10n.t('Git'); case ScmType.GitHub: // remove github from the repoUrl which leaves only the org/repo names - return this._repoUrl ? this._repoUrl.substring('https://github.com/'.length) : localize('gitHub', 'GitHub'); + return this._repoUrl ? this._repoUrl.substring('https://github.com/'.length) : l10n.t('GitHub'); case ScmType.None: default: return ''; diff --git a/appservice/src/tree/FileTreeItem.ts b/appservice/src/tree/FileTreeItem.ts index c23725fee9..3880d518ba 100644 --- a/appservice/src/tree/FileTreeItem.ts +++ b/appservice/src/tree/FileTreeItem.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { AzExtTreeItem, createContextValue, IActionContext, openReadOnlyContent, TreeItemIconPath } from '@microsoft/vscode-azext-utils'; -import { ThemeIcon } from 'vscode'; +import { l10n, ThemeIcon } from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; import { getFile, ISiteFile } from '../siteFiles'; import { FolderTreeItem } from './FolderTreeItem'; @@ -43,7 +42,7 @@ export class FileTreeItem extends AzExtTreeItem { } public async openReadOnly(context: IActionContext): Promise { - await this.runWithTemporaryDescription(context, localize('opening', 'Opening...'), async () => { + await this.runWithTemporaryDescription(context, l10n.t('Opening...'), async () => { const file: ISiteFile = await getFile(context, this.site, this.path); await openReadOnlyContent(this, file.data, ''); }); diff --git a/appservice/src/tree/FolderTreeItem.ts b/appservice/src/tree/FolderTreeItem.ts index 282f2cfe00..cc4ae533a8 100644 --- a/appservice/src/tree/FolderTreeItem.ts +++ b/appservice/src/tree/FolderTreeItem.ts @@ -4,8 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { AzExtParentTreeItem, AzExtTreeItem, createContextValue, GenericTreeItem, IActionContext, TreeItemIconPath } from '@microsoft/vscode-azext-utils'; -import { ThemeIcon } from 'vscode'; -import { localize } from '../localize'; +import { l10n, ThemeIcon } from 'vscode'; import { ParsedSite } from '../SiteClient'; import { ISiteFileMetadata, listFiles } from '../siteFiles'; import { FileTreeItem } from './FileTreeItem'; @@ -20,7 +19,7 @@ export interface FolderTreeItemOptions { export class FolderTreeItem extends AzExtParentTreeItem { public static contextValue: string = 'folder'; - public readonly childTypeLabel: string = localize('fileOrFolder', 'file or folder'); + public readonly childTypeLabel: string = l10n.t('file or folder'); public readonly label: string; public readonly path: string; public readonly isReadOnly: boolean; @@ -52,7 +51,7 @@ export class FolderTreeItem extends AzExtParentTreeItem { } public get description(): string | undefined { - return this._isRoot && this.isReadOnly ? localize('readOnly', 'Read-only') : undefined; + return this._isRoot && this.isReadOnly ? l10n.t('Read-only') : undefined; } public async loadMoreChildrenImpl(_clearCache: boolean, context: IActionContext): Promise { diff --git a/appservice/src/tree/LogFilesTreeItem.ts b/appservice/src/tree/LogFilesTreeItem.ts index 716af295c3..6003eece43 100644 --- a/appservice/src/tree/LogFilesTreeItem.ts +++ b/appservice/src/tree/LogFilesTreeItem.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import { AzExtParentTreeItem, AzExtTreeItem, createContextValue, GenericTreeItem, IActionContext, parseError } from '@microsoft/vscode-azext-utils'; -import { ThemeIcon } from 'vscode'; +import { l10n, ThemeIcon } from 'vscode'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { ParsedSite } from '../SiteClient'; import { FolderTreeItem } from './FolderTreeItem'; @@ -28,7 +27,7 @@ export class LogFilesTreeItem extends FolderTreeItem { constructor(parent: AzExtParentTreeItem, options: LogFilesTreeItemOptions) { super(parent, { site: options.site, - label: localize('logFiles', 'Logs'), + label: l10n.t('Logs'), path: '/LogFiles', isReadOnly: true, contextValuesToAdd: options.contextValuesToAdd || [] @@ -48,7 +47,7 @@ export class LogFilesTreeItem extends FolderTreeItem { const message: string = parseError(error).message; context.telemetry.properties.logFilesError = message; children = [new GenericTreeItem(this, { - label: localize('errorTreeItem', 'Error: {0}', message), + label: l10n.t('Error: {0}', message), contextValue: 'logFilesError' })]; } @@ -58,7 +57,7 @@ export class LogFilesTreeItem extends FolderTreeItem { contextValue: 'logStream', commandId: ext.prefix + '.startStreamingLogs', iconPath: new ThemeIcon('play'), - label: localize('connectLogStream', 'Connect to Log Stream...') + label: l10n.t('Connect to Log Stream...') }); ti.commandArgs = [this.parent]; // should be the slot tree item children.push(ti); diff --git a/appservice/src/tree/SiteFilesTreeItem.ts b/appservice/src/tree/SiteFilesTreeItem.ts index 0e0cb63f8d..d84f68f906 100644 --- a/appservice/src/tree/SiteFilesTreeItem.ts +++ b/appservice/src/tree/SiteFilesTreeItem.ts @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import { AzExtParentTreeItem, createContextValue } from '@microsoft/vscode-azext-utils'; -import { localize } from '../localize'; +import * as vscode from 'vscode'; import { ParsedSite } from '../SiteClient'; import { FolderTreeItem } from './FolderTreeItem'; @@ -25,7 +25,7 @@ export class SiteFilesTreeItem extends FolderTreeItem { constructor(parent: AzExtParentTreeItem, options: SiteFilesTreeItemOptions) { super(parent, { site: options.site, - label: localize('siteFiles', 'Files'), + label: vscode.l10n.t('Files'), path: '/site/wwwroot', isReadOnly: options.isReadOnly }); diff --git a/appservice/src/utils/workspace.ts b/appservice/src/utils/workspace.ts index 836c185fec..f29ac8d02c 100644 --- a/appservice/src/utils/workspace.ts +++ b/appservice/src/utils/workspace.ts @@ -6,7 +6,6 @@ import { IActionContext, IAzureQuickPickItem } from '@microsoft/vscode-azext-utils'; import * as path from 'path'; import * as vscode from 'vscode'; -import { localize } from '../localize'; export async function selectWorkspaceFolder(context: IActionContext, placeHolder: string): Promise { return await selectWorkspaceItem( @@ -17,7 +16,7 @@ export async function selectWorkspaceFolder(context: IActionContext, placeHolder canSelectFolders: true, canSelectMany: false, defaultUri: vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0 ? vscode.workspace.workspaceFolders[0].uri : undefined, - openLabel: localize('select', 'Select') + openLabel: vscode.l10n.t('Select') }); } @@ -33,7 +32,7 @@ export async function selectWorkspaceFile(context: IActionContext, placeHolder: canSelectFiles: true, canSelectFolders: false, canSelectMany: false, - openLabel: localize('select', 'Select'), + openLabel: vscode.l10n.t('Select'), filters: filters }); } @@ -45,7 +44,7 @@ export async function selectWorkspaceItem(context: IActionContext, placeHolder: return { label: path.basename(f.uri.fsPath), description: f.uri.fsPath, data: f }; })); - folderPicks.push({ label: localize('azFunc.browse', '$(file-directory) Browse...'), description: '', data: undefined }); + folderPicks.push({ label: vscode.l10n.t('$(file-directory) Browse...'), description: '', data: undefined }); folder = (await context.ui.showQuickPick(folderPicks, { placeHolder })).data; } diff --git a/appservice/src/verifyNoRunFromPackageSetting.ts b/appservice/src/verifyNoRunFromPackageSetting.ts index 509083a54c..7b16f805a3 100644 --- a/appservice/src/verifyNoRunFromPackageSetting.ts +++ b/appservice/src/verifyNoRunFromPackageSetting.ts @@ -5,8 +5,8 @@ import type { StringDictionary } from "@azure/arm-appservice"; import { IActionContext } from "@microsoft/vscode-azext-utils"; +import * as vscode from 'vscode'; import { ext } from "./extensionVariables"; -import { localize } from "./localize"; import { ParsedSite } from "./SiteClient"; // prior to git deploying, these settings must be deleted or it will fail @@ -18,7 +18,7 @@ export async function verifyNoRunFromPackageSetting(context: IActionContext, sit for (const settingName of runFromPackageSettings) { if (applicationSettings.properties && applicationSettings.properties[settingName]) { delete applicationSettings.properties[settingName]; - ext.outputChannel.appendLog(localize('deletingSetting', 'Deleting setting "{0}"...', settingName), { resourceName: site.fullName }); + ext.outputChannel.appendLog(vscode.l10n.t('Deleting setting "{0}"...', settingName), { resourceName: site.fullName }); updateSettings = true; } } diff --git a/appsettings/package-lock.json b/appsettings/package-lock.json index 539b8f9d2e..a94104b015 100644 --- a/appsettings/package-lock.json +++ b/appsettings/package-lock.json @@ -9,8 +9,7 @@ "version": "0.0.2", "license": "MIT", "dependencies": { - "@microsoft/vscode-azext-utils": "^1.1.0", - "vscode-nls": "^5.0.1" + "@microsoft/vscode-azext-utils": "^1.1.0" }, "devDependencies": { "@azure/arm-appservice": "^13.0.2", diff --git a/appsettings/package.json b/appsettings/package.json index adffc01bc2..4a179291e1 100644 --- a/appsettings/package.json +++ b/appsettings/package.json @@ -32,8 +32,7 @@ "test": "node ./out/test/runTest.js" }, "dependencies": { - "@microsoft/vscode-azext-utils": "^1.1.0", - "vscode-nls": "^5.0.1" + "@microsoft/vscode-azext-utils": "^1.1.0" }, "devDependencies": { "@azure/arm-appservice": "^13.0.2", diff --git a/appsettings/src/localize.ts b/appsettings/src/localize.ts deleted file mode 100644 index 2aee3fa12f..0000000000 --- a/appsettings/src/localize.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'; - -export const localize: nls.LocalizeFunc = nls.loadMessageBundle(); diff --git a/appsettings/src/tree/AppSettingTreeItem.ts b/appsettings/src/tree/AppSettingTreeItem.ts index f43958f0ba..0c67246c2b 100644 --- a/appsettings/src/tree/AppSettingTreeItem.ts +++ b/appsettings/src/tree/AppSettingTreeItem.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import type { SlotConfigNamesResource, StringDictionary } from '@azure/arm-appservice'; -import { AzExtTreeItem, createContextValue, DialogResponses, IActionContext, TreeItemIconPath } from '@microsoft/vscode-azext-utils'; -import { ThemeIcon } from 'vscode'; -import { localize } from '../localize'; +import { AzExtTreeItem, DialogResponses, IActionContext, TreeItemIconPath, createContextValue } from '@microsoft/vscode-azext-utils'; +import { ThemeIcon, l10n } from 'vscode'; import { AppSettingsTreeItem, validateAppSettingKey } from './AppSettingsTreeItem'; /** @@ -112,7 +111,7 @@ export class AppSettingTreeItem extends AzExtTreeItem { await client.updateSlotConfigurationNames(slotSettings); await this.refresh(context); } else { - throw Error(localize('toggleSlotSettingsNotSupported', 'Toggling slot settings is not supported.')); + throw Error(l10n.t('Toggling slot settings is not supported.')); } } @@ -121,7 +120,7 @@ export class AppSettingTreeItem extends AzExtTreeItem { if (client.listSlotConfigurationNames) { const slotSettings: SlotConfigNamesResource = await client.listSlotConfigurationNames(); if (slotSettings.appSettingNames && slotSettings.appSettingNames.find((value: string) => { return value === this._key; })) { - this.description = localize('slotSetting', 'Slot Setting'); + this.description = l10n.t('Slot Setting'); } else { this.description = undefined; } diff --git a/azure/package-lock.json b/azure/package-lock.json index 66b8742f73..f62bc9393f 100644 --- a/azure/package-lock.json +++ b/azure/package-lock.json @@ -19,8 +19,7 @@ "@azure/logger": "^1.0.4", "@microsoft/vscode-azext-utils": "^1.0.0", "semver": "^7.3.7", - "uuid": "^9.0.0", - "vscode-nls": "^5.0.1" + "uuid": "^9.0.0" }, "devDependencies": { "@azure/core-auth": "^1.3.2", diff --git a/azure/package.json b/azure/package.json index e3902677e4..4abcb0e3a4 100644 --- a/azure/package.json +++ b/azure/package.json @@ -42,8 +42,7 @@ "@azure/logger": "^1.0.4", "@microsoft/vscode-azext-utils": "^1.0.0", "semver": "^7.3.7", - "uuid": "^9.0.0", - "vscode-nls": "^5.0.1" + "uuid": "^9.0.0" }, "devDependencies": { "@azure/core-auth": "^1.3.2", diff --git a/azure/src/createAzureClient.ts b/azure/src/createAzureClient.ts index 72e89ed067..30c5144ebb 100644 --- a/azure/src/createAzureClient.ts +++ b/azure/src/createAzureClient.ts @@ -10,7 +10,6 @@ import { Agent as HttpsAgent } from 'https'; import { v4 as uuidv4 } from "uuid"; import * as vscode from "vscode"; import * as types from '../index'; -import { localize } from './localize'; import { parseJson, removeBom } from './utils/parseJson'; export type InternalAzExtClientContext = ISubscriptionActionContext | [IActionContext, ISubscriptionContext | AzExtTreeItem]; @@ -227,7 +226,7 @@ class StatusCodePolicy implements PipelinePolicy { // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment const errorMessage: string = response.bodyAsText ? parseError(response.parsedBody || response.bodyAsText).message : - localize('unexpectedStatusCode', 'Unexpected status code: {0}', response.status); + vscode.l10n.t('Unexpected status code: {0}', response.status); throw new RestError(errorMessage, { code: response.bodyAsText || '', statusCode: response.status, diff --git a/azure/src/extensionVariables.ts b/azure/src/extensionVariables.ts index c6384143e1..90b8c8d96e 100644 --- a/azure/src/extensionVariables.ts +++ b/azure/src/extensionVariables.ts @@ -3,12 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { ExtensionContext } from "vscode"; import { IAzExtOutputChannel, IAzureUserInput, registerUIExtensionVariables, UIExtensionVariables } from '@microsoft/vscode-azext-utils'; -import { localize } from "./localize"; +import { ExtensionContext, l10n } from "vscode"; class UninitializedExtensionVariables implements UIExtensionVariables { - private _error: Error = new Error(localize('uninitializedError', '"registerAzureUtilsExtensionVariables" must be called before using the vscode-azext-azureutilsa package.')); + private _error: Error = new Error(l10n.t('"registerAzureUtilsExtensionVariables" must be called before using the vscode-azext-azureutilsa package.')); public get context(): ExtensionContext { throw this._error; diff --git a/azure/src/localize.ts b/azure/src/localize.ts deleted file mode 100644 index 2aee3fa12f..0000000000 --- a/azure/src/localize.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'; - -export const localize: nls.LocalizeFunc = nls.loadMessageBundle(); diff --git a/azure/src/tree/AzureAccountTreeItemBase.ts b/azure/src/tree/AzureAccountTreeItemBase.ts index 6fff556dae..13da4f3db7 100644 --- a/azure/src/tree/AzureAccountTreeItemBase.ts +++ b/azure/src/tree/AzureAccountTreeItemBase.ts @@ -3,19 +3,18 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { addExtensionValueToMask, AzExtParentTreeItem, AzExtServiceClientCredentials, AzExtTreeItem, AzureWizardPromptStep, GenericTreeItem, IActionContext, ISubscriptionActionContext, ISubscriptionContext, nonNullProp, nonNullValue, registerEvent, TreeItemIconPath, UserCancelledError } from '@microsoft/vscode-azext-utils'; import * as semver from 'semver'; -import { commands, Disposable, Extension, extensions, MessageItem, ProgressLocation, ThemeIcon, window } from 'vscode'; +import { commands, Disposable, Extension, extensions, l10n, MessageItem, ProgressLocation, ThemeIcon, window } from 'vscode'; import * as types from '../../index'; import { AzureAccountExtensionApi, AzureLoginStatus, AzureResourceFilter } from '../azure-account.api'; -import { localize } from '../localize'; import { getIconPath } from './IconPath'; import { SubscriptionTreeItemBase } from './SubscriptionTreeItemBase'; -import { addExtensionValueToMask, AzExtParentTreeItem, AzExtServiceClientCredentials, AzExtTreeItem, AzureWizardPromptStep, GenericTreeItem, IActionContext, ISubscriptionActionContext, ISubscriptionContext, nonNullProp, nonNullValue, registerEvent, TreeItemIconPath, UserCancelledError } from '@microsoft/vscode-azext-utils'; -const signInLabel: string = localize('signInLabel', 'Sign in to Azure...'); -const createAccountLabel: string = localize('createAccountLabel', 'Create an Azure Account...'); -const createStudentAccountLabel: string = localize('createStudentAccount', 'Create an Azure for Students Account...'); -const selectSubscriptionsLabel: string = localize('noSubscriptions', 'Select Subscriptions...'); +const signInLabel: string = l10n.t('Sign in to Azure...'); +const createAccountLabel: string = l10n.t('Create an Azure Account...'); +const createStudentAccountLabel: string = l10n.t('Create an Azure for Students Account...'); +const selectSubscriptionsLabel: string = l10n.t('Select Subscriptions...'); const signInCommandId: string = 'azure-account.login'; const createAccountCommandId: string = 'azure-account.createAccount'; const createStudentAccountCommandId: string = 'azure-account.createStudentAccount'; @@ -30,7 +29,7 @@ export abstract class AzureAccountTreeItemBase extends AzExtParentTreeItem imple public static contextValue: string = 'azureextensionui.azureAccount'; public readonly contextValue: string = AzureAccountTreeItemBase.contextValue; public readonly label: string = 'Azure'; - public childTypeLabel: string = localize('subscription', 'subscription'); + public childTypeLabel: string = l10n.t('subscription'); public autoSelectInTreeItemPicker: boolean = true; public disposables: Disposable[] = []; public suppressMaskLabel: boolean = true; @@ -72,8 +71,8 @@ export abstract class AzureAccountTreeItemBase extends AzExtParentTreeItem imple if (typeof azureAccount === 'string') { context.telemetry.properties.accountStatus = azureAccount; const label: string = azureAccount === 'notInstalled' ? - localize('installAzureAccount', 'Install Azure Account Extension...') : - localize('updateAzureAccount', 'Update Azure Account Extension to at least version "{0}"...', minAccountExtensionVersion); + l10n.t('Install Azure Account Extension...') : + l10n.t('Update Azure Account Extension to at least version "{0}"...', minAccountExtensionVersion); const iconPath: TreeItemIconPath = new ThemeIcon('warning'); const result: AzExtTreeItem = new GenericTreeItem(this, { label, commandId: extensionOpenCommand, contextValue: 'azureAccount' + azureAccount, includeInTreeItemPicker: true, iconPath }); result.commandArgs = [azureAccountExtensionId]; @@ -87,7 +86,7 @@ export abstract class AzureAccountTreeItemBase extends AzExtParentTreeItem imple const contextValue: string = 'azureCommand'; if (azureAccount.status === 'Initializing' || azureAccount.status === 'LoggingIn') { return [new GenericTreeItem(this, { - label: azureAccount.status === 'Initializing' ? localize('loadingTreeItem', 'Loading...') : localize('signingIn', 'Waiting for Azure sign-in...'), + label: azureAccount.status === 'Initializing' ? l10n.t('Loading...') : l10n.t('Waiting for Azure sign-in...'), commandId: signInCommandId, contextValue, id: signInCommandId, @@ -186,7 +185,7 @@ export abstract class AzureAccountTreeItemBase extends AzExtParentTreeItem imple public async pickTreeItemImpl(_expectedContextValues: (string | RegExp)[]): Promise { const azureAccount: AzureAccountResult = await this._azureAccountTask; if (typeof azureAccount !== 'string' && (azureAccount.status === 'LoggingIn' || azureAccount.status === 'Initializing')) { - const title: string = localize('waitingForAzureSignin', 'Waiting for Azure sign-in...'); + const title: string = l10n.t('Waiting for Azure sign-in...'); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion await window.withProgress({ location: ProgressLocation.Notification, title }, async (): Promise => await azureAccount!.waitForSubscriptions()); } @@ -252,13 +251,13 @@ export abstract class AzureAccountTreeItemBase extends AzExtParentTreeItem imple let stepName: string; if (azureAccount === 'notInstalled') { stepName = 'requiresAzureAccount'; - message = localize('requiresAzureAccount', "This functionality requires installing the Azure Account extension."); + message = l10n.t("This functionality requires installing the Azure Account extension."); } else { stepName = 'requiresUpdateToAzureAccount'; - message = localize('requiresUpdateToAzureAccount', 'This functionality requires updating the Azure Account extension to at least version "{0}".', minAccountExtensionVersion); + message = l10n.t('This functionality requires updating the Azure Account extension to at least version "{0}".', minAccountExtensionVersion); } - const viewInMarketplace: MessageItem = { title: localize('viewInMarketplace', "View in Marketplace") }; + const viewInMarketplace: MessageItem = { title: l10n.t("View in Marketplace") }; if (await context.ui.showWarningMessage(message, { stepName }, viewInMarketplace) === viewInMarketplace) { await commands.executeCommand(extensionOpenCommand, azureAccountExtensionId); } diff --git a/azure/src/utils/parseAzureResourceId.ts b/azure/src/utils/parseAzureResourceId.ts index 0fc833b960..e1269ecba4 100644 --- a/azure/src/utils/parseAzureResourceId.ts +++ b/azure/src/utils/parseAzureResourceId.ts @@ -3,14 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import * as vscode from 'vscode'; import * as types from '../../index'; -import { localize } from "../localize"; export function parseAzureResourceId(id: string): types.ParsedAzureResourceId { const matches: RegExpMatchArray | null = id.match(/\/subscriptions\/(.*)\/resourceGroups\/(.*)\/providers\/(.*)\/(.*)/i); if (matches === null || matches.length < 3) { - throw new Error(localize('InvalidResourceId', 'Invalid Azure Resource Id')); + throw new Error(vscode.l10n.t('Invalid Azure Resource Id')); } return { diff --git a/azure/src/wizard/LocationListStep.ts b/azure/src/wizard/LocationListStep.ts index 9ced29b708..1cdf997a2e 100644 --- a/azure/src/wizard/LocationListStep.ts +++ b/azure/src/wizard/LocationListStep.ts @@ -5,11 +5,11 @@ import type { ExtendedLocation, Provider } from '@azure/arm-resources'; import type { Location } from '@azure/arm-resources-subscriptions'; +import { AzureWizardPromptStep, IActionContext, IAzureQuickPickItem, IAzureQuickPickOptions, nonNullProp, nonNullValue } from '@microsoft/vscode-azext-utils'; +import * as vscode from 'vscode'; import * as types from '../../index'; import { createResourcesClient, createSubscriptionsClient } from '../clients'; import { resourcesProvider } from '../constants'; -import { AzureWizardPromptStep, IActionContext, IAzureQuickPickItem, IAzureQuickPickOptions, nonNullProp, nonNullValue } from '@microsoft/vscode-azext-utils'; -import { localize } from '../localize'; import { ext } from '../extensionVariables'; import { uiUtils } from '../utils/uiUtils'; @@ -95,7 +95,8 @@ export class LocationListStep extends let location: types.AzExtLocation = nonNullProp(wizardContext, '_location'); function warnAboutRelatedLocation(loc: types.AzExtLocation): void { - ext.outputChannel.appendLog(localize('relatedLocWarning', 'WARNING: Provider "{0}" does not support location "{1}". Using "{2}" instead.', provider, location.displayName, loc.displayName)); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + ext.outputChannel.appendLog(vscode.l10n.t('WARNING: Provider "{0}" does not support location "{1}". Using "{2}" instead.', provider!, location.displayName, loc.displayName)); } if (location.type === 'EdgeZone') { @@ -108,7 +109,7 @@ export class LocationListStep extends const allLocations = await allLocationsTask; const homeLocation = nonNullValue(allLocations.find(l => LocationListStep.locationMatchesName(l, homeLocName)), 'homeLocation'); wizardContext.telemetry.properties.relatedLocationSource = 'home'; - ext.outputChannel.appendLog(localize('homeLocationWarning', 'WARNING: Resource does not support extended location "{0}". Using "{1}" instead.', location.displayName, homeLocation.displayName)); + ext.outputChannel.appendLog(vscode.l10n.t('WARNING: Resource does not support extended location "{0}". Using "{1}" instead.', location.displayName, homeLocation.displayName)); location = homeLocation; } } @@ -174,7 +175,7 @@ export class LocationListStep extends } public async prompt(wizardContext: T): Promise { - const options: IAzureQuickPickOptions = { placeHolder: localize('selectLocation', 'Select a location for new resources.'), enableGrouping: true, ...this.options }; + const options: IAzureQuickPickOptions = { placeHolder: vscode.l10n.t('Select a location for new resources.'), enableGrouping: true, ...this.options }; wizardContext._location = (await wizardContext.ui.showQuickPick(this.getQuickPicks(wizardContext), options)).data; wizardContext.telemetry.properties.locationType = wizardContext._location.type; } @@ -236,6 +237,6 @@ function isRecommended(l: types.AzExtLocation): boolean { class ProviderResourceTypeNotFoundError extends Error { constructor(provider: Provider, expectedResourceType: string) { - super(localize('noResourceType', 'Provider "{0}" does not have resource type "{1}".', provider.id, expectedResourceType)); + super(vscode.l10n.t('Provider "{0}" does not have resource type "{1}".', provider.id || 'undefined', expectedResourceType)); } } diff --git a/azure/src/wizard/ResourceGroupCreateStep.ts b/azure/src/wizard/ResourceGroupCreateStep.ts index 8fc6140f3c..c962c1c7ba 100644 --- a/azure/src/wizard/ResourceGroupCreateStep.ts +++ b/azure/src/wizard/ResourceGroupCreateStep.ts @@ -4,13 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import type { ResourceGroup, ResourceManagementClient } from '@azure/arm-resources'; -import { MessageItem, Progress } from 'vscode'; import { AzureWizardExecuteStep, parseError } from '@microsoft/vscode-azext-utils'; +import { l10n, MessageItem, Progress } from 'vscode'; import * as types from '../../index'; import { createResourcesClient } from '../clients'; import { resourcesProvider } from '../constants'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { uiUtils } from '../utils/uiUtils'; import { LocationListStep } from './LocationListStep'; import { ResourceGroupListStep } from './ResourceGroupListStep'; @@ -27,14 +26,14 @@ export class ResourceGroupCreateStep if (!this._suppressCreate) { picks.push({ - label: localize('NewResourceGroup', '$(plus) Create new resource group'), + label: vscode.l10n.t('$(plus) Create new resource group'), description: '', data: undefined }); diff --git a/azure/src/wizard/ResourceGroupNameStep.ts b/azure/src/wizard/ResourceGroupNameStep.ts index 9a76f03f1c..a7e8445618 100644 --- a/azure/src/wizard/ResourceGroupNameStep.ts +++ b/azure/src/wizard/ResourceGroupNameStep.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as types from '../../index'; -import { localize } from '../localize'; import { AzureWizardPromptStep } from '@microsoft/vscode-azext-utils'; +import * as vscode from 'vscode'; +import * as types from '../../index'; import { ResourceGroupListStep, resourceGroupNamingRules } from './ResourceGroupListStep'; export class ResourceGroupNameStep extends AzureWizardPromptStep implements types.ResourceGroupNameStep { @@ -27,13 +27,13 @@ export class ResourceGroupNameStep name = name.trim(); if (name.length < resourceGroupNamingRules.minLength || name.length > resourceGroupNamingRules.maxLength) { - return localize('invalidLength', 'The name must be between {0} and {1} characters.', resourceGroupNamingRules.minLength, resourceGroupNamingRules.maxLength); + return vscode.l10n.t('The name must be between {0} and {1} characters.', resourceGroupNamingRules.minLength, resourceGroupNamingRules.maxLength); } else if (name.match(resourceGroupNamingRules.invalidCharsRegExp) !== null) { - return localize('invalidChars', "The name can only contain alphanumeric characters or the symbols ._-()"); + return vscode.l10n.t("The name can only contain alphanumeric characters or the symbols ._-()"); } else if (name.endsWith('.')) { - return localize('invalidEndingChar', "The name cannot end in a period."); + return vscode.l10n.t("The name cannot end in a period."); } else if (!await ResourceGroupListStep.isNameAvailable(wizardContext, name)) { - return localize('nameAlreadyExists', 'Resource group "{0}" already exists in subscription "{1}".', name, wizardContext.subscriptionDisplayName); + return vscode.l10n.t('Resource group "{0}" already exists in subscription "{1}".', name, wizardContext.subscriptionDisplayName); } else { return undefined; } diff --git a/azure/src/wizard/StorageAccountCreateStep.ts b/azure/src/wizard/StorageAccountCreateStep.ts index 0639dd6bd2..89a22672e8 100644 --- a/azure/src/wizard/StorageAccountCreateStep.ts +++ b/azure/src/wizard/StorageAccountCreateStep.ts @@ -5,12 +5,11 @@ import type { SkuName, StorageManagementClient } from '@azure/arm-storage'; import { AzureWizardExecuteStep } from '@microsoft/vscode-azext-utils'; -import { Progress } from 'vscode'; +import { l10n, Progress } from 'vscode'; import * as types from '../../index'; import { createStorageClient } from '../clients'; import { storageProvider } from '../constants'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { LocationListStep } from './LocationListStep'; export class StorageAccountCreateStep extends AzureWizardExecuteStep implements types.StorageAccountCreateStep { @@ -28,7 +27,7 @@ export class StorageAccountCreateStep`${this._defaults.performance}_${this._defaults.replication}`; - const creatingStorageAccount: string = localize('CreatingStorageAccount', 'Creating storage account "{0}" in location "{1}" with sku "{2}"...', newName, newLocation, newSkuName); + const creatingStorageAccount: string = l10n.t('Creating storage account "{0}" in location "{1}" with sku "{2}"...', newName, newLocation, newSkuName); ext.outputChannel.appendLog(creatingStorageAccount); progress.report({ message: creatingStorageAccount }); const storageClient: StorageManagementClient = await createStorageClient(wizardContext); @@ -44,7 +43,7 @@ export class StorageAccountCreateStep): Promise[]> { const picks: IAzureQuickPickItem[] = [{ - label: localize('NewStorageAccount', '$(plus) Create new storage account'), + label: vscode.l10n.t('$(plus) Create new storage account'), description: '', data: undefined }]; @@ -144,7 +144,7 @@ export class StorageAccountListStep { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion await openUrl(this._filters.learnMoreLink!); @@ -155,7 +155,7 @@ export class StorageAccountListStep { /* do nothing */ }, data: undefined }); diff --git a/azure/src/wizard/StorageAccountNameStep.ts b/azure/src/wizard/StorageAccountNameStep.ts index 53832f804e..f83ecb0a6d 100644 --- a/azure/src/wizard/StorageAccountNameStep.ts +++ b/azure/src/wizard/StorageAccountNameStep.ts @@ -3,12 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import type { CheckNameAvailabilityResult, StorageManagementClient } from '@azure/arm-storage'; import { AzureNameStep } from '@microsoft/vscode-azext-utils'; +import * as vscode from 'vscode'; import * as types from '../../index'; -import type { CheckNameAvailabilityResult, StorageManagementClient, } from '@azure/arm-storage'; import { createStorageClient } from '../clients'; import { storageProviderType } from '../constants'; -import { localize } from '../localize'; import { ResourceGroupListStep, resourceGroupNamingRules } from './ResourceGroupListStep'; import { storageAccountNamingRules } from './StorageAccountListStep'; @@ -40,9 +40,9 @@ export class StorageAccountNameStep { name = name.trim(); if (!name || name.length < storageAccountNamingRules.minLength || name.length > storageAccountNamingRules.maxLength) { - return localize('invalidLength', 'The name must be between {0} and {1} characters.', storageAccountNamingRules.minLength, storageAccountNamingRules.maxLength); + return vscode.l10n.t('The name must be between {0} and {1} characters.', storageAccountNamingRules.minLength, storageAccountNamingRules.maxLength); } else if (name.match(storageAccountNamingRules.invalidCharsRegExp) !== null) { - return localize('invalidChars', "The name can only contain lowercase letters and numbers."); + return vscode.l10n.t("The name can only contain lowercase letters and numbers."); } else { const nameAvailabilityResult: CheckNameAvailabilityResult = await client.storageAccounts.checkNameAvailability({ name, type: storageProviderType }); if (!nameAvailabilityResult.nameAvailable) { diff --git a/azure/src/wizard/VerifyProvidersStep.ts b/azure/src/wizard/VerifyProvidersStep.ts index 9a5577256b..02a31f6d8b 100644 --- a/azure/src/wizard/VerifyProvidersStep.ts +++ b/azure/src/wizard/VerifyProvidersStep.ts @@ -5,10 +5,9 @@ import type { Provider, ResourceManagementClient } from '@azure/arm-resources'; import { AzureWizardExecuteStep, ISubscriptionActionContext, parseError } from '@microsoft/vscode-azext-utils'; -import { Progress } from 'vscode'; +import { l10n, Progress } from 'vscode'; import * as types from '../../index'; import { createResourcesClient } from '../clients'; -import { localize } from '../localize'; import { delay } from '../utils/delay'; export class VerifyProvidersStep extends AzureWizardExecuteStep implements types.VerifyProvidersStep { @@ -21,7 +20,7 @@ export class VerifyProvidersStep extends A } public async execute(context: T, progress: Progress<{ message?: string; increment?: number }>): Promise { - progress.report({ message: localize('registeringProviders', 'Registering Providers...') }); + progress.report({ message: l10n.t('Registering Providers...') }); const client: ResourceManagementClient = await createResourcesClient(context); await Promise.all(this._providers.map(async providerName => { diff --git a/dev/src/webpack/getDefaultWebpackConfig.ts b/dev/src/webpack/getDefaultWebpackConfig.ts index 612af7c803..42ffdfa412 100644 --- a/dev/src/webpack/getDefaultWebpackConfig.ts +++ b/dev/src/webpack/getDefaultWebpackConfig.ts @@ -240,17 +240,6 @@ export function getDefaultWebpackConfig(options: DefaultWebpackOptions): webpack }] }, - // Note: If you use`vscode-nls` to localize your extension than you likely also use`vscode-nls-dev` to create language bundles at build time. - // To support webpack, a loader has been added to vscode-nls-dev .Add the section below to the`modules/rules` configuration. - // { - // // vscode-nls-dev loader: - // // * rewrite nls-calls - // loader: require.resolve('vscode-nls-dev/lib/webpack-loader'), - // options: { - // base: path.join(options.projectRoot, 'src') - // } - // } - // Caller-supplied rules ...(options.loaderRules || []) ] diff --git a/utils/package-lock.json b/utils/package-lock.json index 8259a7cc79..714c3e1cee 100644 --- a/utils/package-lock.json +++ b/utils/package-lock.json @@ -16,7 +16,6 @@ "html-to-text": "^8.2.0", "semver": "^7.3.7", "uuid": "^9.0.0", - "vscode-nls": "^5.0.1", "vscode-tas-client": "^0.1.47", "vscode-uri": "^3.0.6" }, @@ -5718,11 +5717,6 @@ "uuid": "dist/bin/uuid" } }, - "node_modules/vscode-nls": { - "version": "5.2.0", - "resolved": "https://registry.npmjs.org/vscode-nls/-/vscode-nls-5.2.0.tgz", - "integrity": "sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==" - }, "node_modules/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/utils/package.json b/utils/package.json index a28a6eb728..a6cf3ce875 100644 --- a/utils/package.json +++ b/utils/package.json @@ -39,7 +39,6 @@ "html-to-text": "^8.2.0", "semver": "^7.3.7", "uuid": "^9.0.0", - "vscode-nls": "^5.0.1", "vscode-tas-client": "^0.1.47", "vscode-uri": "^3.0.6" }, diff --git a/utils/src/AzExtTreeFileSystem.ts b/utils/src/AzExtTreeFileSystem.ts index a0b2663a4c..0bd5b18edd 100644 --- a/utils/src/AzExtTreeFileSystem.ts +++ b/utils/src/AzExtTreeFileSystem.ts @@ -4,13 +4,12 @@ *--------------------------------------------------------------------------------------------*/ import { parse as parseQuery, ParsedUrlQuery, stringify as stringifyQuery } from "querystring"; -import { Disposable, Event, EventEmitter, FileChangeEvent, FileStat, FileSystemError, FileSystemProvider, FileType, TextDocumentShowOptions, Uri, window } from "vscode"; +import { Disposable, Event, EventEmitter, FileChangeEvent, FileStat, FileSystemError, FileSystemProvider, FileType, l10n, TextDocumentShowOptions, Uri, window } from "vscode"; import * as types from '../index'; import { callWithTelemetryAndErrorHandling } from "./callWithTelemetryAndErrorHandling"; -import { localize } from "./localize"; import { nonNullProp } from "./utils/nonNull"; -const unsupportedError: Error = new Error(localize('notSupported', 'This operation is not supported.')); +const unsupportedError: Error = new Error(l10n.t('This operation is not supported.')); export abstract class AzExtTreeFileSystem implements FileSystemProvider { diff --git a/utils/src/DialogResponses.ts b/utils/src/DialogResponses.ts index 7fd195be70..d5e345d02e 100644 --- a/utils/src/DialogResponses.ts +++ b/utils/src/DialogResponses.ts @@ -3,20 +3,19 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { MessageItem } from 'vscode'; -import * as constants from './constants'; -import { localize } from './localize'; +import { l10n, MessageItem } from 'vscode'; +import * as constants from './constants'; export namespace DialogResponses { - export const yes: MessageItem = { title: localize('yes', 'Yes') }; - export const no: MessageItem = { title: localize('no', 'No') }; - export const cancel: MessageItem = { title: localize('cancel', 'Cancel'), isCloseAffordance: true }; - export const deleteResponse: MessageItem = { title: localize('delete', 'Delete') }; + export const yes: MessageItem = { title: l10n.t('Yes') }; + export const no: MessageItem = { title: l10n.t('No') }; + export const cancel: MessageItem = { title: l10n.t('Cancel'), isCloseAffordance: true }; + export const deleteResponse: MessageItem = { title: l10n.t('Delete') }; export const learnMore: MessageItem = { title: constants.learnMore }; - export const dontWarnAgain: MessageItem = { title: localize('dontWarnAgain', 'Don\'t warn again') }; - export const skipForNow: MessageItem = { title: localize('skipForNow', 'Skip for now') }; - export const upload: MessageItem = { title: localize('upload', "Upload") }; - export const alwaysUpload: MessageItem = { title: localize('alwaysUpload', "Always upload") }; - export const dontUpload: MessageItem = { title: localize('dontUpload', "Don't upload"), isCloseAffordance: true }; - export const reportAnIssue: MessageItem = { title: localize('reportAnIssue', "Report an issue") }; + export const dontWarnAgain: MessageItem = { title: l10n.t('Don\'t warn again') }; + export const skipForNow: MessageItem = { title: l10n.t('Skip for now') }; + export const upload: MessageItem = { title: l10n.t("Upload") }; + export const alwaysUpload: MessageItem = { title: l10n.t("Always upload") }; + export const dontUpload: MessageItem = { title: l10n.t("Don't upload"), isCloseAffordance: true }; + export const reportAnIssue: MessageItem = { title: l10n.t("Report an issue") }; } diff --git a/utils/src/activityLog/activities/ExecuteActivity.ts b/utils/src/activityLog/activities/ExecuteActivity.ts index 55fbdecc1c..14a98a84dc 100644 --- a/utils/src/activityLog/activities/ExecuteActivity.ts +++ b/utils/src/activityLog/activities/ExecuteActivity.ts @@ -3,9 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import * as vscode from 'vscode'; import * as hTypes from '../../../hostapi'; import * as types from '../../../index'; -import { localize } from "../../localize"; import { AzExtParentTreeItem } from "../../tree/AzExtParentTreeItem"; import { GenericTreeItem } from "../../tree/GenericTreeItem"; import { ActivityBase } from "../Activity"; @@ -31,7 +31,7 @@ export class ExecuteActivitymaybeAzureExtensionApiFactory).createApi !== undefined; @@ -17,7 +17,7 @@ function isAzureExtensionApiFactory(maybeAzureExtensionApiFactory: AzureExtensio export function createApiProvider(azExts: (AzureExtensionApiFactory | AzureExtensionApi)[]): apiUtils.AzureExtensionApiProvider { for (const azExt of azExts) { if (!semver.valid(azExt.apiVersion)) { - throw new Error(localize('invalidVersion', 'Invalid semver "{0}".', azExt.apiVersion)); + throw new Error(vscode.l10n.t('Invalid semver "{0}".', azExt.apiVersion)); } } const extensionId: string = getPackageInfo().extensionId; @@ -68,11 +68,11 @@ function getApiInternal(azExts: AzureExtensionApiFa let code: ApiVersionCode; if (minApiVersion && semver.gtr(minApiVersion, apiVersionRange)) { // This case will hopefully never happen if we maintain backwards compat - message = localize('notSupported', 'API version "{0}" for extension id "{1}" is no longer supported. Minimum version is "{2}".', apiVersionRange, extensionId, minApiVersion); + message = vscode.l10n.t('API version "{0}" for extension id "{1}" is no longer supported. Minimum version is "{2}".', apiVersionRange, extensionId, minApiVersion); code = 'NoLongerSupported'; } else { // This case is somewhat likely - so keep the error message simple and just tell user to update their extenion - message = localize('updateExtension', 'Extension dependency with id "{0}" must be updated.', extensionId); + message = vscode.l10n.t('Extension dependency with id "{0}" must be updated.', extensionId); code = 'NotYetSupported'; } diff --git a/utils/src/errors.ts b/utils/src/errors.ts index 53b54053d3..8d56ecc5b4 100644 --- a/utils/src/errors.ts +++ b/utils/src/errors.ts @@ -3,14 +3,14 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import * as vscode from 'vscode'; import { ITreeItemPickerContext } from ".."; -import { localize } from "./localize"; export class UserCancelledError extends Error { _isUserCancelledError = true; public stepName: string | undefined; constructor(stepName?: string) { - super(localize('userCancelledError', 'Operation cancelled.')); + super(vscode.l10n.t('Operation cancelled.')); this.stepName = stepName; } } @@ -24,13 +24,13 @@ export function isUserCancelledError(error: unknown): error is UserCancelledErro export class GoBackError extends Error { constructor() { - super(localize('backError', 'Go back.')); + super(vscode.l10n.t('Go back.')); } } export class NotImplementedError extends Error { constructor(methodName: string, obj: object) { - super(localize('notImplementedError', '"{0}" is not implemented on "{1}".', methodName, obj.constructor.name)); + super(vscode.l10n.t('"{0}" is not implemented on "{1}".', methodName, obj.constructor.name)); } } @@ -40,7 +40,7 @@ export class NoResourceFoundError extends Error { super(context.noItemFoundErrorMessage); context.errorHandling.suppressReportIssue = true; } else { - super(localize('noResourcesError', 'No matching resources found.')); + super(vscode.l10n.t('No matching resources found.')); } } } diff --git a/utils/src/extensionVariables.ts b/utils/src/extensionVariables.ts index f1c30d9f40..a3e56d411b 100644 --- a/utils/src/extensionVariables.ts +++ b/utils/src/extensionVariables.ts @@ -4,11 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import * as assert from 'assert'; -import { commands, ExtensionContext } from "vscode"; +import { commands, ExtensionContext, l10n } from "vscode"; import * as types from "../index"; import { registerErrorHandler } from './callWithTelemetryAndErrorHandling'; import { createTelemetryReporter, IInternalTelemetryReporter } from './createTelemetryReporter'; -import { localize } from "./localize"; import { parseError } from './parseError'; interface IInternalExtensionVariables extends types.UIExtensionVariables { @@ -16,7 +15,7 @@ interface IInternalExtensionVariables extends types.UIExtensionVariables { } class UninitializedExtensionVariables implements types.UIExtensionVariables { - private _error: Error = new Error(localize('uninitializedError', '"registerUIExtensionVariables" must be called before using the vscode-azureextensionui package.')); + private _error: Error = new Error(l10n.t('"registerUIExtensionVariables" must be called before using the vscode-azureextensionui package.')); public get context(): ExtensionContext { throw this._error; @@ -57,11 +56,11 @@ export function registerUIExtensionVariables(extVars: types.UIExtensionVariables */ async function handleEntryNotFound(context: types.IErrorHandlerContext): Promise { if (parseError(context.error).message === 'Entry not found in cache.') { - context.error = new Error(localize('mustReload', 'Your VS Code window must be reloaded to perform this action.')); + context.error = new Error(l10n.t('Your VS Code window must be reloaded to perform this action.')); context.errorHandling.suppressReportIssue = true; context.errorHandling.buttons = [ { - title: localize('reloadWindow', 'Reload Window'), + title: l10n.t('Reload Window'), callback: async (): Promise => { await commands.executeCommand('workbench.action.reloadWindow'); } diff --git a/utils/src/localize.ts b/utils/src/localize.ts deleted file mode 100644 index 2aee3fa12f..0000000000 --- a/utils/src/localize.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'; - -export const localize: nls.LocalizeFunc = nls.loadMessageBundle(); diff --git a/utils/src/parseError.ts b/utils/src/parseError.ts index ccbc0f7cf3..7250b20381 100644 --- a/utils/src/parseError.ts +++ b/utils/src/parseError.ts @@ -6,9 +6,9 @@ /* eslint-disable */ import * as htmlToText from 'html-to-text'; +import * as vscode from 'vscode'; import { IParsedError } from '../index'; import { isUserCancelledError } from './errors'; -import { localize } from './localize'; import { parseJson } from './utils/parseJson'; export function parseError(error: any): IParsedError { @@ -72,7 +72,7 @@ export function parseError(error: any): IParsedError { [message, errorType] = parseIfFileSystemError(message, errorType); errorType ||= typeof (error); - message ||= localize('unknownError', 'Unknown Error'); + message ||= vscode.l10n.t('Unknown Error'); message = parseIfHtml(message); @@ -98,7 +98,7 @@ function convertCodeToError(errorType: string | undefined): string | undefined { if (errorType) { const code: number = parseInt(errorType, 10); if (!isNaN(code)) { - return localize('failedWithCode', 'Failed with code "{0}".', code); + return vscode.l10n.t('Failed with code "{0}".', code); } } diff --git a/utils/src/pickTreeItem/GenericQuickPickStep.ts b/utils/src/pickTreeItem/GenericQuickPickStep.ts index f73309ea3f..48736a033f 100644 --- a/utils/src/pickTreeItem/GenericQuickPickStep.ts +++ b/utils/src/pickTreeItem/GenericQuickPickStep.ts @@ -3,12 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as types from '../../index'; import * as vscode from 'vscode'; -import { getLastNode } from './getLastNode'; +import * as types from '../../index'; import { AzureWizardPromptStep } from '../wizard/AzureWizardPromptStep'; +import { getLastNode } from './getLastNode'; import { PickFilter } from './PickFilter'; -import { localize } from '../localize'; export abstract class GenericQuickPickStep extends AzureWizardPromptStep { public readonly supportsDuplicateSteps = true; @@ -23,7 +22,7 @@ export abstract class GenericQuickPickStep = (context: types.IActionContext) => TNode | Promise; @@ -34,7 +34,8 @@ export class CompatibilityRecursiveQuickPickStep() : lastPickedItem; if (isAzExtParentTreeItem(lastPickedItemTi)) { - this.promptOptions.placeHolder = localize('selectTreeItem', 'Select {0}', lastPickedItemTi.childTypeLabel); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + this.promptOptions.placeHolder = vscode.l10n.t('Select {0}', lastPickedItemTi.childTypeLabel!); this.promptOptions.stepName = `treeItemPicker|${lastPickedItemTi.contextValue}`; this.promptOptions.noPicksMessage = wizardContext.noItemFoundErrorMessage ?? this.promptOptions.noPicksMessage; this.promptOptions.ignoreFocusOut = wizardContext.ignoreFocusOut; @@ -44,7 +45,8 @@ export class CompatibilityRecursiveQuickPickStep[]; @@ -129,7 +131,7 @@ export class CompatibilityRecursiveQuickPickStep { return { - label: options.label || localize('createQuickPickLabel', '$(add) Create...'), + label: options.label || vscode.l10n.t('$(add) Create...'), data: options.callback, }; } diff --git a/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts b/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts index 196c03611e..c601da21e5 100644 --- a/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts +++ b/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureResourceStep.ts @@ -4,19 +4,18 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { AzureResourceQuickPickWizardContext } from '../../../index'; import * as types from '../../../index'; +import { AzureResourceQuickPickWizardContext } from '../../../index'; import { parseContextValue } from '../../utils/contextUtils'; -import { PickFilter } from '../PickFilter'; import { GenericQuickPickStep } from '../GenericQuickPickStep'; +import { PickFilter } from '../PickFilter'; import { AzureResourceItem, ResourceGroupsItem } from './tempTypes'; -import { localize } from '../../localize'; export class QuickPickAzureResourceStep extends GenericQuickPickStep { public constructor(tdp: vscode.TreeDataProvider, options?: types.AzureResourceQuickPickOptions, promptOptions?: types.IAzureQuickPickOptions) { super(tdp, options ?? {}, { - placeHolder: localize('selectResource', 'Select resource'), + placeHolder: vscode.l10n.t('Select resource'), ...promptOptions, }); } diff --git a/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts b/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts index b6c9baca52..20f941a612 100644 --- a/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts +++ b/utils/src/pickTreeItem/quickPickAzureResource/QuickPickAzureSubscriptionStep.ts @@ -4,11 +4,10 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { PickFilter } from '../PickFilter'; -import { ResourceGroupsItem, SubscriptionItem } from './tempTypes'; -import { localize } from '../../localize'; import { AzureResourceQuickPickWizardContext, GenericQuickPickOptions, SkipIfOneQuickPickOptions } from '../../../index'; import { GenericQuickPickStepWithCommands } from '../GenericQuickPickStepWithCommands'; +import { PickFilter } from '../PickFilter'; +import { ResourceGroupsItem, SubscriptionItem } from './tempTypes'; export class QuickPickAzureSubscriptionStep extends GenericQuickPickStepWithCommands { public constructor(tdp: vscode.TreeDataProvider, options?: GenericQuickPickOptions) { @@ -16,8 +15,8 @@ export class QuickPickAzureSubscriptionStep extends GenericQuickPickStepWithComm ...options, skipIfOne: true, // Subscription is always skip-if-one }, { - placeHolder: localize('selectSubscription', 'Select subscription'), - noPicksMessage: localize('noSubscriptions', 'No subscriptions found'), + placeHolder: vscode.l10n.t('Select subscription'), + noPicksMessage: vscode.l10n.t('No subscriptions found'), }); } diff --git a/utils/src/registerReportIssueCommand.ts b/utils/src/registerReportIssueCommand.ts index 4f4f82a3ad..375272b21d 100644 --- a/utils/src/registerReportIssueCommand.ts +++ b/utils/src/registerReportIssueCommand.ts @@ -6,8 +6,8 @@ import * as dayjs from 'dayjs'; // eslint-disable-next-line import/no-internal-modules import * as relativeTime from 'dayjs/plugin/relativeTime'; +import * as vscode from 'vscode'; import * as types from '../index'; -import { localize } from './localize'; import { registerCommand } from "./registerCommand"; import { IReportableIssue, reportAnIssue } from './reportAnIssue'; import { nonNullValue } from './utils/nonNull'; @@ -50,10 +50,10 @@ export function registerReportIssueCommand(commandId: string): void { }; }); picks.unshift({ - label: localize('emptyIssue', '$(keyboard) Manually enter error'), + label: vscode.l10n.t('$(keyboard) Manually enter error'), data: undefined }); - const placeHolder: string = localize('selectError', 'Select the error you would like to report'); + const placeHolder: string = vscode.l10n.t('Select the error you would like to report'); const issue: IReportableIssue | undefined = (await context.ui.showQuickPick(picks, { placeHolder, stepName: 'reportIssue', suppressPersistence: true })).data; await reportAnIssue(issue); } diff --git a/utils/src/reportAnIssue.ts b/utils/src/reportAnIssue.ts index e049675138..ef8628b6ea 100644 --- a/utils/src/reportAnIssue.ts +++ b/utils/src/reportAnIssue.ts @@ -7,7 +7,6 @@ import * as os from 'os'; import * as vscode from 'vscode'; import * as types from '../index'; import { getPackageInfo } from "./getPackageInfo"; -import { localize } from './localize'; import { openUrl } from './utils/openUrl'; // Some browsers don't have very long URLs @@ -36,11 +35,11 @@ export async function getReportAnIssueLink(issue: IReportableIssue | undefined): const stack: string = (issue?.error.stack || '').replace(/\r\n/g, '\n'); let body: string = ` - + -${localize('reportIssue_isItConsistent', "Does this occur consistently? ")} +${vscode.l10n.t("Does this occur consistently? ")} Repro steps: - + 1. 2.`; @@ -77,7 +76,7 @@ Language: ${vscode.env.language}`; // If it's too long, paste it to the clipboard await vscode.env.clipboard.writeText(body); - return createNewIssueLinkFromBody(localize('pasteIssue', "The issue text was copied to the clipboard. Please paste it into this window.")); + return createNewIssueLinkFromBody(vscode.l10n.t("The issue text was copied to the clipboard. Please paste it into this window.")); } function createNewIssueLinkFromBody(issueBody: string): string { diff --git a/utils/src/tree/AzExtParentTreeItem.ts b/utils/src/tree/AzExtParentTreeItem.ts index 114721d8f3..8edccef0ab 100644 --- a/utils/src/tree/AzExtParentTreeItem.ts +++ b/utils/src/tree/AzExtParentTreeItem.ts @@ -4,10 +4,9 @@ *--------------------------------------------------------------------------------------------*/ import { isNullOrUndefined } from 'util'; -import { commands, ThemeIcon, TreeItemCollapsibleState } from 'vscode'; +import { commands, l10n, ThemeIcon, TreeItemCollapsibleState } from 'vscode'; import * as types from '../../index'; import { NoResourceFoundError, NotImplementedError, UserCancelledError } from '../errors'; -import { localize } from '../localize'; import { randomUtils } from '../utils/randomUtils'; import { AzExtTreeItem } from './AzExtTreeItem'; import { GenericTreeItem } from './GenericTreeItem'; @@ -71,7 +70,7 @@ export abstract class AzExtParentTreeItem extends AzExtTreeItem implements types Object.assign(context, { showCreatingTreeItem: (label: string): void => { creatingTreeItem = new GenericTreeItem(this, { - label: localize('creatingLabel', 'Creating {0}...', label), + label: l10n.t('Creating {0}...', label), contextValue: `azureextensionui.creating${label}`, iconPath: new ThemeIcon('loading~spin') }); @@ -111,7 +110,8 @@ export abstract class AzExtParentTreeItem extends AzExtTreeItem implements types } } - const placeHolder: string = localize('selectTreeItem', 'Select {0}', this.childTypeLabel); + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + const placeHolder: string = l10n.t('Select {0}', this.childTypeLabel!); const stepName = `treeItemPicker|${this.contextValue}`; let getTreeItem: GetTreeItemFunction; @@ -171,7 +171,7 @@ export abstract class AzExtParentTreeItem extends AzExtTreeItem implements types } public async loadAllChildren(context: types.ILoadingTreeContext): Promise { - context.loadingMessage ||= localize('loadingTreeItem', 'Loading "{0}"...', this.label); + context.loadingMessage ||= l10n.t('Loading "{0}"...', this.label); await runWithLoadingNotification(context, async (cancellationToken) => { do { if (cancellationToken.isCancellationRequested) { @@ -230,7 +230,7 @@ export abstract class AzExtParentTreeItem extends AzExtTreeItem implements types if (!isNullOrUndefined(lastUnknownItemError)) { // Display a generic error if there are any unknown items. Only the last error will be displayed - const label: string = localize('cantShowItems', 'Some items could not be displayed'); + const label: string = l10n.t('Some items could not be displayed'); treeItems.push(new InvalidTreeItem(this, lastUnknownItemError, { label, description: '', @@ -282,7 +282,7 @@ export abstract class AzExtParentTreeItem extends AzExtTreeItem implements types id: ti.fullId, data: async (): Promise => { if (!ti.commandId) { - throw new Error(localize('noCommand', 'Failed to find commandId on generic tree item.')); + throw new Error(l10n.t('Failed to find commandId on generic tree item.')); } else { const commandArgs: unknown[] = ti.commandArgs || [ti]; await commands.executeCommand(ti.commandId, ...commandArgs); @@ -302,12 +302,12 @@ export abstract class AzExtParentTreeItem extends AzExtTreeItem implements types }); if (this.createChildImpl && this.childTypeLabel && !context.suppressCreatePick) { - const createNewLabel: string = this.createNewLabel || localize('treePickerCreateNew', 'Create new {0}...', this.childTypeLabel); + const createNewLabel: string = this.createNewLabel || l10n.t('Create new {0}...', this.childTypeLabel); if (this.supportsAdvancedCreation) { picks.unshift({ label: `$(plus) ${createNewLabel}`, - description: localize('advanced', 'Advanced'), + description: l10n.t('Advanced'), data: async (): Promise => await this.createChild(Object.assign(context, { advancedCreation: true })) }); } @@ -357,7 +357,7 @@ export class InvalidTreeItem extends AzExtParentTreeItem implements types.Invali this._error = error; this.contextValue = options.contextValue; this.data = options.data; - this.description = options.description !== undefined ? options.description : localize('invalid', 'Invalid'); + this.description = options.description !== undefined ? options.description : l10n.t('Invalid'); } public get id(): string { diff --git a/utils/src/tree/AzExtTreeDataProvider.ts b/utils/src/tree/AzExtTreeDataProvider.ts index c556c3e271..1ae1d16a7f 100644 --- a/utils/src/tree/AzExtTreeDataProvider.ts +++ b/utils/src/tree/AzExtTreeDataProvider.ts @@ -3,11 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CancellationToken, Disposable, Event, EventEmitter, ThemeIcon, TreeItem, TreeView } from 'vscode'; +import { CancellationToken, Disposable, Event, EventEmitter, l10n, ThemeIcon, TreeItem, TreeView } from 'vscode'; import * as types from '../../index'; import { callWithTelemetryAndErrorHandling } from '../callWithTelemetryAndErrorHandling'; import { NoResourceFoundError, UserCancelledError } from '../errors'; -import { localize } from '../localize'; import { parseError } from '../parseError'; import { addTreeItemValuesToMask } from './addTreeItemValuesToMask'; import { AzExtParentTreeItem, InvalidTreeItem } from './AzExtParentTreeItem'; @@ -114,7 +113,7 @@ export class AzExtTreeDataProvider implements IAzExtTreeDataProviderInternal, ty const result: AzExtTreeItem[] = Array.from(resultMap.values()); result.push(...duplicateChildren.map(c => { - const message: string = localize('elementWithId', 'An element with the following id already exists: {0}', c.fullId); + const message: string = l10n.t('An element with the following id already exists: {0}', c.fullId); return new InvalidTreeItem(treeItem, new Error(message), { contextValue: 'azureextensionui.duplicate', label: c.label }); })); @@ -134,7 +133,7 @@ export class AzExtTreeDataProvider implements IAzExtTreeDataProviderInternal, ty }); } catch (error) { return [new GenericTreeItem(arg, { - label: localize('errorTreeItem', 'Error: {0}', parseError(error).message), + label: l10n.t('Error: {0}', parseError(error).message), contextValue: 'azureextensionui.error' })]; } diff --git a/utils/src/tree/AzExtTreeItem.ts b/utils/src/tree/AzExtTreeItem.ts index d31b5fda6f..3fccb97d15 100644 --- a/utils/src/tree/AzExtTreeItem.ts +++ b/utils/src/tree/AzExtTreeItem.ts @@ -3,14 +3,13 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { MarkdownString, ThemeIcon, TreeItemCollapsibleState } from 'vscode'; +import { l10n, MarkdownString, ThemeIcon, TreeItemCollapsibleState } from 'vscode'; import * as types from '../../index'; +import { showContextValueSetting } from '../constants'; import { NotImplementedError } from '../errors'; -import { localize } from '../localize'; import { nonNullProp } from '../utils/nonNull'; -import { IAzExtParentTreeItemInternal, IAzExtTreeDataProviderInternal } from "./InternalInterfaces"; import { settingUtils } from '../utils/settingUtils'; -import { showContextValueSetting } from '../constants'; +import { IAzExtParentTreeItemInternal, IAzExtTreeDataProviderInternal } from "./InternalInterfaces"; import { isAzExtParentTreeItem } from './isAzExtTreeItem'; export abstract class AzExtTreeItem implements types.AzExtTreeItem { @@ -145,7 +144,7 @@ export abstract class AzExtTreeItem implements types.AzExtTreeItem { public get subscription(): types.ISubscriptionContext { const result = this._subscription || this.parent?.subscription; if (!result) { - throw Error(localize('noSubscriptionFound', 'No Azure subscription found for this tree item.')); + throw Error(l10n.t('No Azure subscription found for this tree item.')); } else { return result; } @@ -183,7 +182,7 @@ export abstract class AzExtTreeItem implements types.AzExtTreeItem { } public async deleteTreeItem(context: types.IActionContext): Promise { - await this.runWithTemporaryDescription(context, localize('deleting', 'Deleting...'), async () => { + await this.runWithTemporaryDescription(context, l10n.t('Deleting...'), async () => { if (this.deleteTreeItemImpl) { await this.deleteTreeItemImpl(context); if (this.parent) { diff --git a/utils/src/tree/runWithLoadingNotification.ts b/utils/src/tree/runWithLoadingNotification.ts index e3da8a0f78..7fb8ed4e1e 100644 --- a/utils/src/tree/runWithLoadingNotification.ts +++ b/utils/src/tree/runWithLoadingNotification.ts @@ -3,13 +3,12 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { CancellationToken, ProgressLocation, window } from 'vscode'; +import { CancellationToken, l10n, ProgressLocation, window } from 'vscode'; import * as types from '../../index'; -import { localize } from '../localize'; export async function runWithLoadingNotification(context: types.ILoadingTreeContext, callback: (cancellationToken: CancellationToken) => Promise): Promise { return await window.withProgress({ location: ProgressLocation.Notification, cancellable: true }, async (progress, cancellationToken) => { - const message: string = context.loadingMessage || localize('loadingAll', 'Loading resources...'); + const message: string = context.loadingMessage || l10n.t('Loading resources...'); const messageDelay: number = context.loadingMessageDelay !== undefined ? context.loadingMessageDelay : 2; const timer: NodeJS.Timer = setTimeout(() => progress.report({ message }), messageDelay * 1000); diff --git a/utils/src/tree/treeConstants.ts b/utils/src/tree/treeConstants.ts index 27d161927d..3e827a15ab 100644 --- a/utils/src/tree/treeConstants.ts +++ b/utils/src/tree/treeConstants.ts @@ -3,6 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { localize } from '../localize'; +import * as vscode from 'vscode'; -export const loadMoreLabel: string = localize('LoadMore', 'Load More...'); +export const loadMoreLabel: string = vscode.l10n.t('Load More...'); diff --git a/utils/src/tree/v2/TreeElementStateManager.ts b/utils/src/tree/v2/TreeElementStateManager.ts index 91919354aa..053430a8b0 100644 --- a/utils/src/tree/v2/TreeElementStateManager.ts +++ b/utils/src/tree/v2/TreeElementStateManager.ts @@ -4,9 +4,8 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { createGenericElement } from './createGenericElement'; import * as types from '../../../index'; -import { localize } from '../../localize'; +import { createGenericElement } from './createGenericElement'; export class TreeElementStateManager implements vscode.Disposable { private readonly store: Record = {}; @@ -26,7 +25,7 @@ export class TreeElementStateManager Promise): Promise { - await this.runWithTemporaryDescription(id, localize('deleting', 'Deleting...'), callback, true); + await this.runWithTemporaryDescription(id, vscode.l10n.t('Deleting...'), callback, true); } async showCreatingChild(id: string, label: string, callback: () => Promise): Promise { diff --git a/utils/src/userInput/showQuickPick.ts b/utils/src/userInput/showQuickPick.ts index a161ebc450..7fadc38ca6 100644 --- a/utils/src/userInput/showQuickPick.ts +++ b/utils/src/userInput/showQuickPick.ts @@ -3,12 +3,11 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { Disposable, Memento, QuickInputButton, QuickInputButtons, QuickPick, QuickPickItemKind, window } from 'vscode'; +import { Disposable, l10n, Memento, QuickInputButton, QuickInputButtons, QuickPick, QuickPickItemKind, window } from 'vscode'; import * as types from '../../index'; import { AzExtQuickInputButtons } from '../constants'; import { GoBackError, UserCancelledError } from '../errors'; import { ext } from '../extensionVariables'; -import { localize } from '../localize'; import { nonNullProp } from '../utils/nonNull'; import { openUrl } from '../utils/openUrl'; import { randomUtils } from '../utils/randomUtils'; @@ -121,7 +120,7 @@ export function createQuickPick } if (options.canPickMany && options.placeHolder) { - options.placeHolder += localize('canPickManyInstructions', " (Press 'Space' to select and 'Enter' to confirm)"); + options.placeHolder += l10n.t(" (Press 'Space' to select and 'Enter' to confirm)"); } // Copy settings that are common between options and quickPick @@ -185,7 +184,7 @@ async function bumpHighPriorityAndRecentlyUsed= 0) { const recentlyUsedItem: T = picks[recentlyUsedIndex]; if (!recentlyUsedItem.suppressPersistence) { - const recentlyUsed: string = localize('recentlyUsed', '(recently used)'); + const recentlyUsed: string = l10n.t('(recently used)'); if (!recentlyUsedItem.description) { recentlyUsedItem.description = recentlyUsed; } else if (!recentlyUsedItem.description.includes(recentlyUsed)) { diff --git a/utils/src/userInput/showWarningMessage.ts b/utils/src/userInput/showWarningMessage.ts index 040f98b01d..5374f4c5fa 100644 --- a/utils/src/userInput/showWarningMessage.ts +++ b/utils/src/userInput/showWarningMessage.ts @@ -3,11 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { MessageItem, MessageOptions, window } from 'vscode'; +import { l10n, MessageItem, MessageOptions, window } from 'vscode'; import * as types from '../../index'; import { DialogResponses } from '../DialogResponses'; import { GoBackError, UserCancelledError } from '../errors'; -import { localize } from '../localize'; import { openUrl } from '../utils/openUrl'; import { IInternalActionContext } from './IInternalActionContext'; @@ -21,7 +20,7 @@ export async function showWarningMessage(context: IIntern args.push(DialogResponses.learnMore); } - const back: MessageItem = { title: localize('back', 'Back') }; + const back: MessageItem = { title: l10n.t('Back') }; if (context.ui.wizard?.showBackButton) { args.push(back); } diff --git a/utils/src/utils/credentialUtils.ts b/utils/src/utils/credentialUtils.ts index e2fdf6ffc0..14d805222d 100644 --- a/utils/src/utils/credentialUtils.ts +++ b/utils/src/utils/credentialUtils.ts @@ -3,10 +3,9 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as vscode from 'vscode'; import { AzureSubscription } from '@microsoft/vscode-azureresources-api'; +import * as vscode from 'vscode'; import { AzExtServiceClientCredentials, ISubscriptionContext } from '../../index'; -import { localize } from '../localize'; /** * Converts a VS Code authentication session to an Azure Track 1 & 2 compatible compatible credential. @@ -29,7 +28,7 @@ export function createCredential(getSession: (scopes?: string[]) => vscode.Provi } }, signRequest: async () => { - throw new Error((localize('signRequestError', 'Track 1 credentials are not (currently) supported.'))); + throw new Error((vscode.l10n.t('Track 1 credentials are not (currently) supported.'))); } }; } diff --git a/utils/src/utils/timeout.ts b/utils/src/utils/timeout.ts index b9d12a8d2e..4a2ed31e0a 100644 --- a/utils/src/utils/timeout.ts +++ b/utils/src/utils/timeout.ts @@ -3,8 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { localize } from "../localize"; - +import * as vscode from 'vscode'; class TimeoutError extends Error { } /** @@ -31,7 +30,7 @@ export async function rejectOnTimeout(timeoutMs: number, action: () => Promis let timer: NodeJS.Timer | undefined = setTimeout( () => { timer = undefined; - reject(new TimeoutError(callerTimeOutMessage || localize('timeout', 'Execution timed out.'))); + reject(new TimeoutError(callerTimeOutMessage || vscode.l10n.t('Execution timed out.'))); }, timeoutMs); diff --git a/utils/src/wizard/AzureWizard.ts b/utils/src/wizard/AzureWizard.ts index 047d190eec..ef778e2071 100644 --- a/utils/src/wizard/AzureWizard.ts +++ b/utils/src/wizard/AzureWizard.ts @@ -9,7 +9,6 @@ import { ProgressLocation } from 'vscode'; import * as types from '../../index'; import { ExecuteActivity } from '../activityLog/activities/ExecuteActivity'; import { GoBackError, UserCancelledError } from '../errors'; -import { localize } from '../localize'; import { parseError } from '../parseError'; import { IInternalActionContext, IInternalAzureWizard } from '../userInput/IInternalActionContext'; import { createQuickPick } from '../userInput/showQuickPick'; @@ -93,7 +92,7 @@ export class AzureWizard { @@ -14,7 +14,7 @@ export class ConfirmPreviousInputStep extends AzureWizardPromptStep { await context.ui.showInputBox({ - prompt: this.options?.prompt ?? localize('verifyPreviousInput', 'Please confirm by re-entering the previous value.'), + prompt: this.options?.prompt ?? vscode.l10n.t('Please confirm by re-entering the previous value.'), password: this.options?.isPassword, validateInput: (value?: string) => this.validateInput(context, value) }); @@ -25,7 +25,7 @@ export class ConfirmPreviousInputStep extends AzureWizardPromptStep