mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Engineering - adopt l10n for git-base/git/github extesions (#164566)
Co-authored-by: Tyler James Leonhardt <me@tylerleonhardt.com>
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { API as GitAPI, Repository } from './typings/git';
|
||||
import { getOctokit } from './auth';
|
||||
import { TextEncoder } from 'util';
|
||||
@@ -12,8 +11,6 @@ import { basename } from 'path';
|
||||
import { Octokit } from '@octokit/rest';
|
||||
import { isInCodespaces } from './pushErrorHandler';
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
function sanitizeRepositoryName(value: string): string {
|
||||
return value.trim().replace(/[^a-z0-9_.]/ig, '-');
|
||||
}
|
||||
@@ -41,7 +38,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
|
||||
folder = vscode.workspace.workspaceFolders[0].uri;
|
||||
} else {
|
||||
const picks = vscode.workspace.workspaceFolders.map(folder => ({ label: folder.name, folder }));
|
||||
const placeHolder = localize('pick folder', "Pick a folder to publish to GitHub");
|
||||
const placeHolder = vscode.l10n.t('Pick a folder to publish to GitHub');
|
||||
const pick = await vscode.window.showQuickPick(picks, { placeHolder });
|
||||
|
||||
if (!pick) {
|
||||
@@ -130,7 +127,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
|
||||
|
||||
if (shouldGenerateGitignore) {
|
||||
quickpick = vscode.window.createQuickPick();
|
||||
quickpick.placeholder = localize('ignore', "Select which files should be included in the repository.");
|
||||
quickpick.placeholder = vscode.l10n.t('Select which files should be included in the repository.');
|
||||
quickpick.canSelectMany = true;
|
||||
quickpick.show();
|
||||
|
||||
@@ -171,8 +168,8 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
|
||||
const githubRepository = await vscode.window.withProgress({ location: vscode.ProgressLocation.Notification, cancellable: false, title: 'Publish to GitHub' }, async progress => {
|
||||
progress.report({
|
||||
message: isPrivate
|
||||
? localize('publishing_private', "Publishing to a private GitHub repository")
|
||||
: localize('publishing_public', "Publishing to a public GitHub repository"),
|
||||
? vscode.l10n.t('Publishing to a private GitHub repository')
|
||||
: vscode.l10n.t('Publishing to a public GitHub repository'),
|
||||
increment: 25
|
||||
});
|
||||
|
||||
@@ -190,7 +187,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
|
||||
}
|
||||
|
||||
if (createdGithubRepository) {
|
||||
progress.report({ message: localize('publishing_firstcommit', "Creating first commit"), increment: 25 });
|
||||
progress.report({ message: vscode.l10n.t('Creating first commit'), increment: 25 });
|
||||
|
||||
if (!repository) {
|
||||
repository = await gitAPI.init(folder) || undefined;
|
||||
@@ -202,7 +199,7 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
|
||||
await repository.commit('first commit', { all: true, postCommitCommand: null });
|
||||
}
|
||||
|
||||
progress.report({ message: localize('publishing_uploading', "Uploading files"), increment: 25 });
|
||||
progress.report({ message: vscode.l10n.t('Uploading files'), increment: 25 });
|
||||
|
||||
const branch = await repository.getBranch('HEAD');
|
||||
const protocol = vscode.workspace.getConfiguration('github').get<'https' | 'ssh'>('gitProtocol');
|
||||
@@ -218,8 +215,8 @@ export async function publishRepository(gitAPI: GitAPI, repository?: Repository)
|
||||
return;
|
||||
}
|
||||
|
||||
const openOnGitHub = localize('openingithub', "Open on GitHub");
|
||||
vscode.window.showInformationMessage(localize('publishing_done', "Successfully published the '{0}' repository to GitHub.", `${owner}/${repo}`), openOnGitHub).then(action => {
|
||||
const openOnGitHub = vscode.l10n.t('Open on GitHub');
|
||||
vscode.window.showInformationMessage(vscode.l10n.t('Successfully published the "{0}" repository to GitHub.', `${owner}/${repo}`), openOnGitHub).then(action => {
|
||||
if (action === openOnGitHub) {
|
||||
vscode.commands.executeCommand('vscode.open', vscode.Uri.parse(githubRepository.html_url));
|
||||
}
|
||||
|
||||
@@ -4,14 +4,11 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { TextDecoder } from 'util';
|
||||
import { commands, env, ProgressLocation, Uri, window, workspace, QuickPickOptions, FileType } from 'vscode';
|
||||
import * as nls from 'vscode-nls';
|
||||
import { commands, env, ProgressLocation, Uri, window, workspace, QuickPickOptions, FileType, l10n } from 'vscode';
|
||||
import { getOctokit } from './auth';
|
||||
import { GitErrorCodes, PushErrorHandler, Remote, Repository } from './typings/git';
|
||||
import path = require('path');
|
||||
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
type Awaited<T> = T extends PromiseLike<infer U> ? Awaited<U> : T;
|
||||
|
||||
export function isInCodespaces(): boolean {
|
||||
@@ -19,9 +16,9 @@ export function isInCodespaces(): boolean {
|
||||
}
|
||||
|
||||
async function handlePushError(repository: Repository, remote: Remote, refspec: string, owner: string, repo: string): Promise<void> {
|
||||
const yes = localize('create a fork', "Create Fork");
|
||||
const no = localize('no', "No");
|
||||
const askFork = localize('fork', "You don't have permissions to push to '{0}/{1}' on GitHub. Would you like to create a fork and push to it instead?", owner, repo);
|
||||
const yes = l10n.t('Create Fork');
|
||||
const no = l10n.t('No');
|
||||
const askFork = l10n.t('You don\'t have permissions to push to "{0}/{1}" on GitHub.Would you like to create a fork and push to it instead?', owner, repo);
|
||||
|
||||
const answer = await window.showInformationMessage(askFork, yes, no);
|
||||
if (answer !== yes) {
|
||||
@@ -32,8 +29,8 @@ async function handlePushError(repository: Repository, remote: Remote, refspec:
|
||||
const localName = match ? match[1] : refspec;
|
||||
let remoteName = match ? match[2] : refspec;
|
||||
|
||||
const [octokit, ghRepository] = await window.withProgress({ location: ProgressLocation.Notification, cancellable: false, title: localize('create fork', 'Create GitHub fork') }, async progress => {
|
||||
progress.report({ message: localize('forking', "Forking '{0}/{1}'...", owner, repo), increment: 33 });
|
||||
const [octokit, ghRepository] = await window.withProgress({ location: ProgressLocation.Notification, cancellable: false, title: l10n.t('Create GitHub fork') }, async progress => {
|
||||
progress.report({ message: l10n.t('Forking "{0}/{1}"...', owner, repo), increment: 33 });
|
||||
|
||||
const octokit = await getOctokit();
|
||||
|
||||
@@ -68,7 +65,7 @@ async function handlePushError(repository: Repository, remote: Remote, refspec:
|
||||
throw ex;
|
||||
}
|
||||
|
||||
progress.report({ message: localize('forking_pushing', "Pushing changes..."), increment: 33 });
|
||||
progress.report({ message: l10n.t('Pushing changes...'), increment: 33 });
|
||||
|
||||
// Issue: what if there's already an `upstream` repo?
|
||||
await repository.renameRemote(remote.name, 'upstream');
|
||||
@@ -92,14 +89,14 @@ async function handlePushError(repository: Repository, remote: Remote, refspec:
|
||||
|
||||
// yield
|
||||
(async () => {
|
||||
const openOnGitHub = localize('openingithub', "Open on GitHub");
|
||||
const createPR = localize('createpr', "Create PR");
|
||||
const action = await window.showInformationMessage(localize('forking_done', "The fork '{0}' was successfully created on GitHub.", ghRepository.full_name), openOnGitHub, createPR);
|
||||
const openOnGitHub = l10n.t('Open on GitHub');
|
||||
const createPR = l10n.t('Create PR');
|
||||
const action = await window.showInformationMessage(l10n.t('The fork "{0}" was successfully created on GitHub.', ghRepository.full_name), openOnGitHub, createPR);
|
||||
|
||||
if (action === openOnGitHub) {
|
||||
await commands.executeCommand('vscode.open', Uri.parse(ghRepository.html_url));
|
||||
} else if (action === createPR) {
|
||||
const pr = await window.withProgress({ location: ProgressLocation.Notification, cancellable: false, title: localize('createghpr', "Creating GitHub Pull Request...") }, async _ => {
|
||||
const pr = await window.withProgress({ location: ProgressLocation.Notification, cancellable: false, title: l10n.t('Creating GitHub Pull Request...') }, async _ => {
|
||||
let title = `Update ${remoteName}`;
|
||||
const head = repository.state.HEAD?.name;
|
||||
|
||||
@@ -138,8 +135,8 @@ async function handlePushError(repository: Repository, remote: Remote, refspec:
|
||||
return pr;
|
||||
});
|
||||
|
||||
const openPR = localize('openpr', "Open PR");
|
||||
const action = await window.showInformationMessage(localize('donepr', "The PR '{0}/{1}#{2}' was successfully created on GitHub.", owner, repo, pr.number), openPR);
|
||||
const openPR = l10n.t('Open PR');
|
||||
const action = await window.showInformationMessage(l10n.t('The PR "{0}/{1}#{2}" was successfully created on GitHub.', owner, repo, pr.number), openPR);
|
||||
|
||||
if (action === openPR) {
|
||||
await commands.executeCommand('vscode.open', Uri.parse(pr.html_url));
|
||||
@@ -196,14 +193,14 @@ export async function pickPullRequestTemplate(repositoryRootUri: Uri, templates:
|
||||
const quickPickItemFromUri = (x: Uri) => ({ label: path.relative(repositoryRootUri.path, x.path), template: x });
|
||||
const quickPickItems = [
|
||||
{
|
||||
label: localize('no pr template', "No template"),
|
||||
label: l10n.t('No template'),
|
||||
picked: true,
|
||||
template: undefined,
|
||||
},
|
||||
...templates.map(quickPickItemFromUri)
|
||||
];
|
||||
const quickPickOptions: QuickPickOptions = {
|
||||
placeHolder: localize('select pr template', "Select the Pull Request template"),
|
||||
placeHolder: l10n.t('Select the Pull Request template'),
|
||||
ignoreFocusOut: true
|
||||
};
|
||||
const pickedTemplate = await window.showQuickPick(quickPickItems, quickPickOptions);
|
||||
|
||||
Reference in New Issue
Block a user