Skip to content

Commit 6684350

Browse files
Onboard GitHub & Microsoft auth extensions to l10n (microsoft#163662)
* onboard github-auth completely to l10n * onboard microsoft-authentication entirely on to l10n
1 parent f83ad50 commit 6684350

File tree

8 files changed

+39
-45
lines changed

8 files changed

+39
-45
lines changed

extensions/github-authentication/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@
3434
"id": "github"
3535
},
3636
{
37-
"label": "GitHub Enterprise",
37+
"label": "GitHub Enterprise Server",
3838
"id": "github-enterprise"
3939
}
4040
],
4141
"configuration": {
42-
"title": "GitHub Enterprise Authentication Provider",
42+
"title": "GitHub Enterprise Server Authentication Provider",
4343
"properties": {
4444
"github-enterprise.uri": {
4545
"type": "string",
46-
"description": "URI of your GitHub Enterprise Instance"
46+
"description": "GitHub Enterprise Server URI"
4747
}
4848
}
4949
}
@@ -65,7 +65,6 @@
6565
"node-fetch": "2.6.7",
6666
"uuid": "8.1.0",
6767
"@vscode/extension-telemetry": "0.6.2",
68-
"vscode-nls": "^5.2.0",
6968
"vscode-tas-client": "^0.1.47"
7069
},
7170
"devDependencies": {

extensions/github-authentication/src/github.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid
256256
*/
257257
this._telemetryReporter?.sendTelemetryEvent('loginFailed');
258258

259-
vscode.window.showErrorMessage(`Sign in failed: ${e}`);
259+
vscode.window.showErrorMessage(vscode.l10n.t('Sign in failed: {0}', `${e}`));
260260
this._logger.error(e);
261261
throw e;
262262
}
@@ -299,7 +299,7 @@ export class GitHubAuthenticationProvider implements vscode.AuthenticationProvid
299299
*/
300300
this._telemetryReporter?.sendTelemetryEvent('logoutFailed');
301301

302-
vscode.window.showErrorMessage(`Sign out failed: ${e}`);
302+
vscode.window.showErrorMessage(vscode.l10n.t('Sign out failed: {0}', `${e}`));
303303
this._logger.error(e);
304304
throw e;
305305
}

extensions/github-authentication/src/githubServer.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as nls from 'vscode-nls';
76
import * as vscode from 'vscode';
87
import fetch, { Response } from 'node-fetch';
98
import { v4 as uuid } from 'uuid';
@@ -15,7 +14,6 @@ import { isSupportedEnvironment } from './common/env';
1514
import { LoopbackAuthServer } from './authServer';
1615
import path = require('path');
1716

18-
const localize = nls.loadMessageBundle();
1917
const CLIENT_ID = '01ab8ac9400c4e429b23';
2018
const GITHUB_TOKEN_URL = 'https://vscode.dev/codeExchangeProxyEndpoints/github/login/oauth/access_token';
2119
const NETWORK_ERROR = 'network error';
@@ -157,15 +155,15 @@ export class GitHubServer implements IGitHubServer {
157155
// Used for showing a friendlier message to the user when the explicitly cancel a flow.
158156
let userCancelled: boolean | undefined;
159157
const yes = vscode.l10n.t('Yes');
160-
const no = localize('no', "No");
158+
const no = vscode.l10n.t('No');
161159
const promptToContinue = async () => {
162160
if (userCancelled === undefined) {
163161
// We haven't had a failure yet so wait to prompt
164162
return;
165163
}
166164
const message = userCancelled
167-
? localize('userCancelledMessage', "Having trouble logging in? Would you like to try a different way?")
168-
: localize('otherReasonMessage', "You have not yet finished authorizing this extension to use GitHub. Would you like to keep trying?");
165+
? vscode.l10n.t('Having trouble logging in? Would you like to try a different way?')
166+
: vscode.l10n.t('otherReasonMessage', 'You have not yet finished authorizing this extension to use GitHub. Would you like to keep trying?');
169167
const result = await vscode.window.showWarningMessage(message, yes, no);
170168
if (result !== yes) {
171169
throw new Error('Cancelled');
@@ -221,7 +219,11 @@ export class GitHubServer implements IGitHubServer {
221219
this._logger.info(`Trying without local server... (${scopes})`);
222220
return await vscode.window.withProgress<string>({
223221
location: vscode.ProgressLocation.Notification,
224-
title: localize('signingIn', 'Signing in to {0}...', this.baseUri.authority),
222+
title: vscode.l10n.t({
223+
message: 'Signing in to {0}...',
224+
args: [this.baseUri.authority],
225+
comment: ['The {0} will be a url, e.g. github.com']
226+
}),
225227
cancellable: true
226228
}, async (_, token) => {
227229
const existingNonces = this._pendingNonces.get(scopes) || [];
@@ -266,7 +268,11 @@ export class GitHubServer implements IGitHubServer {
266268
this._logger.info(`Trying with local server... (${scopes})`);
267269
return await vscode.window.withProgress<string>({
268270
location: vscode.ProgressLocation.Notification,
269-
title: localize('signingInAnotherWay', "Signing in to {0}...", this.baseUri.authority),
271+
title: vscode.l10n.t({
272+
message: 'Signing in to {0}...',
273+
args: [this.baseUri.authority],
274+
comment: ['The {0} will be a url, e.g. github.com']
275+
}),
270276
cancellable: true
271277
}, async (_, token) => {
272278
const redirectUri = await this.getRedirectEndpoint();
@@ -323,15 +329,15 @@ export class GitHubServer implements IGitHubServer {
323329

324330
const json = await result.json() as IGitHubDeviceCodeResponse;
325331

326-
332+
const button = vscode.l10n.t('Copy & Continue to GitHub');
327333
const modalResult = await vscode.window.showInformationMessage(
328-
localize('code.title', "Your Code: {0}", json.user_code),
334+
vscode.l10n.t({ message: 'Your Code: {0}', args: [json.user_code], comment: ['The {0} will be a code, e.g. 123-456'] }),
329335
{
330336
modal: true,
331-
detail: localize('code.detail', "To finish authenticating, navigate to GitHub and paste in the above one-time code.")
332-
}, 'Copy & Continue to GitHub');
337+
detail: vscode.l10n.t('To finish authenticating, navigate to GitHub and paste in the above one-time code.')
338+
}, button);
333339

334-
if (modalResult !== 'Copy & Continue to GitHub') {
340+
if (modalResult !== button) {
335341
throw new Error('User Cancelled');
336342
}
337343

@@ -372,11 +378,14 @@ export class GitHubServer implements IGitHubServer {
372378
return await vscode.window.withProgress<string>({
373379
location: vscode.ProgressLocation.Notification,
374380
cancellable: true,
375-
title: localize(
376-
'progress',
377-
"Open [{0}]({0}) in a new tab and paste your one-time code: {1}",
378-
json.verification_uri,
379-
json.user_code)
381+
title: vscode.l10n.t({
382+
message: 'Open [{0}]({0}) in a new tab and paste your one-time code: {1}',
383+
args: [json.verification_uri, json.user_code],
384+
comment: [
385+
'The [{0}]({0}) will be a url and the {1} will be a code, e.g. 123-456',
386+
'{Locked="[{0}]({0})"}'
387+
]
388+
})
380389
}, async (_, token) => {
381390
const refreshTokenUri = this.baseUri.with({
382391
path: '/login/oauth/access_token',

extensions/github-authentication/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,6 @@ [email protected]:
143143
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.1.0.tgz#6f1536eb43249f473abc6bd58ff983da1ca30d8d"
144144
integrity sha512-CI18flHDznR0lq54xBycOVmphdCYnQLKn8abKn7PXUiKUGdEd+/l9LWNJmugXel4hXq7S+RMNl34ecyC9TntWg==
145145

146-
vscode-nls@^5.2.0:
147-
version "5.2.0"
148-
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
149-
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
150-
151146
vscode-tas-client@^0.1.47:
152147
version "0.1.47"
153148
resolved "https://registry.yarnpkg.com/vscode-tas-client/-/vscode-tas-client-0.1.47.tgz#d66795cbbaa231aba659b6c40d43927d73596375"

extensions/microsoft-authentication/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@
6161
"sha.js": "2.4.11",
6262
"stream": "0.0.2",
6363
"uuid": "^8.2.0",
64-
"@vscode/extension-telemetry": "0.6.2",
65-
"vscode-nls": "^5.2.0"
64+
"@vscode/extension-telemetry": "0.6.2"
6665
},
6766
"repository": {
6867
"type": "git",

extensions/microsoft-authentication/src/AADHelper.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import * as randomBytes from 'randombytes';
77
import * as querystring from 'querystring';
88
import { Buffer } from 'buffer';
99
import * as vscode from 'vscode';
10-
import * as nls from 'vscode-nls';
1110
import { v4 as uuid } from 'uuid';
1211
import fetch, { Response } from 'node-fetch';
1312
import Logger from './logger';
@@ -17,8 +16,6 @@ import { BetterTokenStorage, IDidChangeInOtherWindowEvent } from './betterSecret
1716
import { LoopbackAuthServer } from './authServer';
1817
import path = require('path');
1918

20-
const localize = nls.loadMessageBundle();
21-
2219
const redirectUrl = 'https://vscode.dev/redirect';
2320
const loginEndpointUrl = 'https://login.microsoftonline.com/';
2421
const DEFAULT_CLIENT_ID = 'aebc6443-996d-45c2-90f0-388ff96faa56';
@@ -139,7 +136,7 @@ export class AzureActiveDirectoryService {
139136
sessionId: session.id
140137
});
141138
} else {
142-
vscode.window.showErrorMessage(localize('signOut', "You have been signed out because reading stored authentication information failed."));
139+
vscode.window.showErrorMessage(vscode.l10n.t('You have been signed out because reading stored authentication information failed.'));
143140
Logger.error(e);
144141
await this.removeSessionByIToken({
145142
accessToken: undefined,
@@ -446,7 +443,7 @@ export class AzureActiveDirectoryService {
446443
onDidChangeSessions.fire({ added: [], removed: [], changed: [this.convertToSessionSync(refreshedToken)] });
447444
} catch (e) {
448445
if (e.message !== REFRESH_NETWORK_FAILURE) {
449-
vscode.window.showErrorMessage(localize('signOut', "You have been signed out because reading stored authentication information failed."));
446+
vscode.window.showErrorMessage(vscode.l10n.t('You have been signed out because reading stored authentication information failed.'));
450447
await this.removeSessionById(sessionId);
451448
}
452449
}
@@ -683,9 +680,9 @@ export class AzureActiveDirectoryService {
683680

684681
private async handleCodeInputBox(inputBox: vscode.InputBox, verifier: string, scopeData: IScopeData): Promise<vscode.AuthenticationSession> {
685682
inputBox.ignoreFocusOut = true;
686-
inputBox.title = localize('pasteCodeTitle', 'Microsoft Authentication');
687-
inputBox.prompt = localize('pasteCodePrompt', 'Provide the authorization code to complete the sign in flow.');
688-
inputBox.placeholder = localize('pasteCodePlaceholder', 'Paste authorization code here...');
683+
inputBox.title = vscode.l10n.t('Microsoft Authentication');
684+
inputBox.prompt = vscode.l10n.t('Provide the authorization code to complete the sign in flow.');
685+
inputBox.placeholder = vscode.l10n.t('Paste authorization code here...');
689686
return new Promise((resolve: (value: vscode.AuthenticationSession) => void, reject) => {
690687
inputBox.show();
691688
inputBox.onDidAccept(async () => {
@@ -829,7 +826,7 @@ export class AzureActiveDirectoryService {
829826
} catch (e) {
830827
// Network failures will automatically retry on next poll.
831828
if (e.message !== REFRESH_NETWORK_FAILURE) {
832-
vscode.window.showErrorMessage(localize('signOut', "You have been signed out because reading stored authentication information failed."));
829+
vscode.window.showErrorMessage(vscode.l10n.t('You have been signed out because reading stored authentication information failed.'));
833830
await this.removeSessionById(session.id);
834831
}
835832
return;

extensions/microsoft-authentication/src/logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@
55

66
import * as vscode from 'vscode';
77

8-
const Logger = vscode.window.createOutputChannel('Microsoft Authentication', { log: true });
8+
const Logger = vscode.window.createOutputChannel(vscode.l10n.t('Microsoft Authentication'), { log: true });
99
export default Logger;

extensions/microsoft-authentication/yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ uuid@^8.2.0:
198198
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.2.0.tgz#cb10dd6b118e2dada7d0cd9730ba7417c93d920e"
199199
integrity sha512-CYpGiFTUrmI6OBMkAdjSDM0k5h8SkkiTP4WAjQgDgNB1S3Ou9VBEvr6q0Kv2H1mMk7IWfxYGpMH5sd5AvcIV2Q==
200200

201-
vscode-nls@^5.2.0:
202-
version "5.2.0"
203-
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
204-
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
205-
206201
webidl-conversions@^3.0.0:
207202
version "3.0.1"
208203
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"

0 commit comments

Comments
 (0)