Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ resources:
extends:
template: azure-pipelines/extension/stable.yml@templates
parameters:
# Once localization supports notebook renderers we can include that folder here
l10nSourcePaths: ./src/extension
buildSteps:
- bash: |
/usr/bin/Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
{
"name": "vscode-github-issue-notebooks",
"displayName": "GitHub Issue Notebooks",
"description": "GitHub Issue Notebooks for VS Code",
"description": "%description%",
"publisher": "ms-vscode",
"preview": true,
"version": "0.0.119",
"repository": {
"url": "https://github.com/microsoft/vscode-github-issue-notebooks"
},
"engines": {
"vscode": "^1.67.0"
"vscode": "^1.72.0-insider"
},
"categories": [
"Other"
],
"enabledApiProposals": [
"localization"
],
"capabilities": {
"untrustedWorkspaces": {
"supported": true
Expand All @@ -28,6 +31,7 @@
],
"main": "./dist/extension-node.js",
"browser": "./dist/extension-web.js",
"l10n": "./l10n",
"contributes": {
"languages": [
{
Expand Down Expand Up @@ -70,17 +74,17 @@
],
"commands": [
{
"title": "New GitHub Issue Notebook",
"title": "%github-issues.new.title%",
"shortTitle": "GitHub Issue Notebook",
"command": "github-issues.new"
},
{
"title": "Open All In Browser",
"title": "%github-issues.openAll.title%",
"command": "github-issues.openAll",
"icon": "$(globe)"
},
{
"title": "Open Query In Browser",
"title": "%github-issues.openUrl.title%",
"command": "github-issues.openUrl",
"icon": "$(home)"
}
Expand Down Expand Up @@ -147,4 +151,4 @@
"@octokit/rest": "^18.5.3",
"abort-controller": "^3.0.0"
}
}
}
17 changes: 17 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"description": {
"message": "GitHub Issue Notebooks for VS Code",
"comment": [
"{Locked='GitHub Issue Notebooks'}",
"{Locked='VS Code'}"
]
},
"github-issues.new.title": {
"message": "New GitHub Issue Notebook",
"comment": [
"{Locked='GitHub Issue Notebook'}"
]
},
"github-issues.openAll.title": "Open All In Browser",
"github-issues.openUrl.title": "Open Query In Browser"
}
7 changes: 4 additions & 3 deletions src/extension/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ export function registerCommands(projectContainer: ProjectContainer, octokit: Oc
}

if (items.length > 10) {
const ok = vscode.l10n.t('OK');
const option = await vscode.window.showInformationMessage(
`This will open ${items.length} browser tabs. Do you want to continue?`,
vscode.l10n.t('This will open {0} browser tabs. Do you want to continue?', items.length),
{ modal: true },
'OK'
ok
);
if (option !== 'OK') {
if (option !== ok) {
return;
}
}
Expand Down
15 changes: 8 additions & 7 deletions src/extension/languageProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,10 @@ export class QuickFixProvider implements vscode.CodeActionProvider {
}

if (diag.code === Code.GitHubLoginNeeded) {
const action = new vscode.CodeAction('Login for @me', vscode.CodeActionKind.QuickFix);
const loginForAtMe = vscode.l10n.t('Login for {0}', '@me');
const action = new vscode.CodeAction(loginForAtMe, vscode.CodeActionKind.QuickFix);
action.diagnostics = [diag];
action.command = { command: 'github-issues.authNow', title: 'Login for @me' };
action.command = { command: 'github-issues.authNow', title: loginForAtMe };
result.push(action);

}
Expand Down Expand Up @@ -737,21 +738,21 @@ export class GithubValidation extends IProjectValidation {
if (info?.placeholderType === ValuePlaceholderType.Label) {
work.push(this._checkLabels(value, repos).then(missing => {
if (missing.length === repos.length) {
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), `Label '${value}' is unknown`, vscode.DiagnosticSeverity.Warning);
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), vscode.l10n.t("Label '{0}' is unknown", value), vscode.DiagnosticSeverity.Warning);
newDiagnostics.push(diag);
} else if (missing.length > 0) {
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), `Label '${value}' is unknown in these repositories: ${missing.map(info => `${info.owner}/${info.repo}`).join(', ')}`, vscode.DiagnosticSeverity.Hint);
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), vscode.l10n.t("Label '{0}' is unknown in these repositories: {1}", value, missing.map(info => `${info.owner}/${info.repo}`).join(', ')), vscode.DiagnosticSeverity.Hint);
newDiagnostics.push(diag);
}
}));

} else if (info?.placeholderType === ValuePlaceholderType.Milestone) {
work.push(this._checkMilestones(value, repos).then(missing => {
if (missing.length === repos.length) {
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), `Milestone '${value}' is unknown`, vscode.DiagnosticSeverity.Warning);
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), vscode.l10n.t("Milestone '{0}' is unknown", value), vscode.DiagnosticSeverity.Warning);
newDiagnostics.push(diag);
} else if (missing.length > 0) {
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), `Milestone '${value}' is unknown in these repositories: ${missing.map(info => `${info.owner}/${info.repo}`).join(', ')}`, vscode.DiagnosticSeverity.Hint);
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), vscode.l10n.t("Milestone '{0}' is unknown in these repositories: {1}", value, missing.map(info => `${info.owner}/${info.repo}`).join(', ')), vscode.DiagnosticSeverity.Hint);
newDiagnostics.push(diag);
}
}));
Expand All @@ -760,7 +761,7 @@ export class GithubValidation extends IProjectValidation {
if (value === '@me') {
work.push(this.octokit.lib().then(() => {
if (!this.octokit.isAuthenticated) {
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), `@me requires that you are logged in`, vscode.DiagnosticSeverity.Warning);
const diag = new vscode.Diagnostic(project.rangeOf(valueNode), vscode.l10n.t('{0} requires that you are logged in', '@me'), vscode.DiagnosticSeverity.Warning);
diag.code = Code.GitHubLoginNeeded;
newDiagnostics.push(diag);
}
Expand Down
43 changes: 36 additions & 7 deletions src/extension/notebookProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import { isRunnable, isUsingAtMe } from './utils';

export const mimeGithubIssues = 'x-application/github-issues';

const atMeLink = '[`@me`](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#queries-with-usernames)';

// --- running queries

export class IssuesNotebookKernel {
Expand Down Expand Up @@ -74,8 +76,22 @@ export class IssuesNotebookKernel {
const atMe = isUsingAtMe(query, project);
if (atMe > 0) {
const message = atMe > 1
? 'This query depends on [`@me`](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#queries-with-usernames) to specify the current user. For that to work you need to be [logged in](command:github-issues.authNow).'
: 'This query uses [`@me`](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#queries-with-usernames) to specify the current user. For that to work you need to be [logged in](command:github-issues.authNow).';
? vscode.l10n.t({
message: 'This query depends on {0} to specify the current user. For that to work you need to be [logged in](command:github-issues.authNow).',
args: [atMeLink],
comment: [
'The [...](command:...) will be rendered as a markdown link. Only the contents of the square brackets should be translated',
'{Locked="](command:github-issues.authNow)"}'
]
})
: vscode.l10n.t({
message: 'This query uses {0} to specify the current user. For that to work you need to be [logged in](command:github-issues.authNow).',
args: [atMeLink],
comment: [
'The [...](command:...) will be rendered as a markdown link. Only the contents of the square brackets should be translated',
'{Locked="](command:github-issues.authNow)"}'
]
});
exec.replaceOutput(new vscode.NotebookCellOutput([vscode.NotebookCellOutputItem.text(message, 'text/markdown')]));
exec.end(false);
return;
Expand Down Expand Up @@ -117,10 +133,23 @@ export class IssuesNotebookKernel {
} catch (err) {
if (err instanceof Error && err.message.includes('Authenticated requests get a higher rate limit')) {
// ugly error-message checking for anon-rate-limit. where are the error codes?
const message = 'You have exceeded the rate limit for anonymous querying. You can [log in](command:github-issues.authNow) to continue querying.';
const message = vscode.l10n.t({
message: 'You have exceeded the rate limit for anonymous querying. You can [log in](command:github-issues.authNow) to continue querying.',
comment: [
'The [...](command:...) will be rendered as a markdown link. Only the contents of the square brackets should be translated',
'{Locked="](command:github-issues.authNow)"}'
]
});
exec.replaceOutput(new vscode.NotebookCellOutput([vscode.NotebookCellOutputItem.text(message, 'text/markdown')]));
} else if (err instanceof Error && err.message.includes('The listed users cannot be searched')) {
const message = 'This query uses [`@me`](https://docs.github.com/en/search-github/getting-started-with-searching-on-github/understanding-the-search-syntax#queries-with-usernames) to specify the current user. For that to work you need to be [logged in](command:github-issues.authNow).';
const message = vscode.l10n.t({
message: 'This query uses {0} to specify the current user. For that to work you need to be [logged in](command:github-issues.authNow).',
args: [atMeLink],
comment: [
'The [...](command:...) will be rendered as a markdown link. Only the contents of the square brackets should be translated',
'{Locked="](command:github-issues.authNow)"}'
]
});
exec.replaceOutput(new vscode.NotebookCellOutput([vscode.NotebookCellOutputItem.text(message, 'text/markdown')]));
} else {
// print as error
Expand Down Expand Up @@ -152,7 +181,7 @@ export class IssuesNotebookKernel {
md += ` [${item.labels.map(label => `${label.name}`).join(', ')}] `;
}
if (item.assignee) {
md += `- [@${item.assignee.login}](${item.assignee.html_url} "Issue ${item.number} is assigned to ${item.assignee.login}")\n`;
md += `- [@${item.assignee.login}](${item.assignee.html_url} "${vscode.l10n.t('Issue {0} is assigned to {1}', item.number, item.assignee.login)}")\n`;
}
md += '\n';
}
Expand Down Expand Up @@ -212,11 +241,11 @@ export class IssuesStatusBarProvider implements vscode.NotebookCellStatusBarItem
return;
}
const item = new vscode.NotebookCellStatusBarItem(
`$(globe) Open ${count} results`,
'$(globe) ' + vscode.l10n.t('Open {0} results', count),
vscode.NotebookCellStatusBarAlignment.Right,
);
item.command = 'github-issues.openAll';
item.tooltip = `Open ${count} results in browser`;
item.tooltip = vscode.l10n.t('Open {0} results in browser', count);
return item;
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/extension/vscode.proposed.localization.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

declare module 'vscode' {
export namespace l10n {
/**
* A string that can be pulled out of a localization bundle if it exists.
*/
export function t(message: string, ...args: any[]): string;
/**
* A string that can be pulled out of a localization bundle if it exists.
*/
export function t(options: { message: string; args?: any[]; comment: string[]; }): string;
/**
* The bundle of localized strings that have been loaded for the extension.
*/
export const bundle: { [key: string]: string; };
/**
* The URI of the localization bundle that has been loaded for the extension.
*/
export const uri: Uri | undefined;
}
}