Engineering - adopt l10n for git-base/git/github extesions (#164566)

Co-authored-by: Tyler James Leonhardt <me@tylerleonhardt.com>
This commit is contained in:
Ladislau Szomoru 2022-10-28 11:27:08 +02:00 committed by GitHub
parent 8cc0246a78
commit f09c4124a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 366 additions and 432 deletions

View File

@ -99,9 +99,6 @@
}
]
},
"dependencies": {
"vscode-nls": "^5.2.0"
},
"devDependencies": {
"@types/node": "16.x"
},

View File

@ -3,14 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { QuickPickItem, window, QuickPick, QuickPickItemKind } from 'vscode';
import * as nls from 'vscode-nls';
import { QuickPickItem, window, QuickPick, QuickPickItemKind, l10n } from 'vscode';
import { RemoteSourceProvider, RemoteSource, PickRemoteSourceOptions, PickRemoteSourceResult } from './api/git-base';
import { Model } from './model';
import { throttle, debounce } from './decorators';
const localize = nls.loadMessageBundle();
async function getQuickPickResult<T extends QuickPickItem>(quickpick: QuickPick<T>): Promise<T | undefined> {
const result = await new Promise<T | undefined>(c => {
quickpick.onDidAccept(() => c(quickpick.selectedItems[0]));
@ -33,10 +30,10 @@ class RemoteSourceProviderQuickPick {
this.quickpick = window.createQuickPick();
this.quickpick.ignoreFocusOut = true;
if (this.provider.supportsQuery) {
this.quickpick.placeholder = this.provider.placeholder ?? localize('type to search', "Repository name (type to search)");
this.quickpick.placeholder = this.provider.placeholder ?? l10n.t('Repository name (type to search)');
this.quickpick.onDidChangeValue(this.onDidChangeValue, this);
} else {
this.quickpick.placeholder = this.provider.placeholder ?? localize('type to filter', "Repository name");
this.quickpick.placeholder = this.provider.placeholder ?? l10n.t('Repository name');
}
}
}
@ -57,7 +54,7 @@ class RemoteSourceProviderQuickPick {
if (remoteSources.length === 0) {
this.quickpick!.items = [{
label: localize('none found', "No remote repositories found."),
label: l10n.t('No remote repositories found.'),
alwaysShow: true
}];
} else {
@ -70,7 +67,7 @@ class RemoteSourceProviderQuickPick {
}));
}
} catch (err) {
this.quickpick!.items = [{ label: localize('error', "{0} Error: {1}", '$(error)', err.message), alwaysShow: true }];
this.quickpick!.items = [{ label: l10n.t('{0} Error: {1}', '$(error)', err.message), alwaysShow: true }];
console.error(err);
} finally {
this.quickpick!.busy = false;
@ -118,19 +115,19 @@ export async function pickRemoteSource(model: Model, options: PickRemoteSourceOp
}
const items = [
{ kind: QuickPickItemKind.Separator, label: localize('remote sources', 'remote sources') },
{ kind: QuickPickItemKind.Separator, label: l10n.t('remote sources') },
...remoteProviders,
{ kind: QuickPickItemKind.Separator, label: localize('recently opened', 'recently opened') },
{ kind: QuickPickItemKind.Separator, label: l10n.t('recently opened') },
...recentSources.sort((a, b) => b.timestamp - a.timestamp)
];
quickpick.placeholder = options.placeholder ?? (remoteProviders.length === 0
? localize('provide url', "Provide repository URL")
: localize('provide url or pick', "Provide repository URL or pick a repository source."));
? l10n.t('Provide repository URL')
: l10n.t('Provide repository URL or pick a repository source.'));
const updatePicks = (value?: string) => {
if (value) {
const label = (typeof options.urlLabel === 'string' ? options.urlLabel : options.urlLabel?.(value)) ?? localize('url', "URL");
const label = (typeof options.urlLabel === 'string' ? options.urlLabel : options.urlLabel?.(value)) ?? l10n.t('URL');
quickpick.items = [{
label: label,
description: value,
@ -170,7 +167,7 @@ async function pickProviderSource(provider: RemoteSourceProvider, options: PickR
if (typeof remote.url === 'string') {
url = remote.url;
} else if (remote.url.length > 0) {
url = await window.showQuickPick(remote.url, { ignoreFocusOut: true, placeHolder: localize('pick url', "Choose a URL to clone from.") });
url = await window.showQuickPick(remote.url, { ignoreFocusOut: true, placeHolder: l10n.t('Choose a URL to clone from.') });
}
}
@ -189,7 +186,7 @@ async function pickProviderSource(provider: RemoteSourceProvider, options: PickR
}
const branch = await window.showQuickPick(branches, {
placeHolder: localize('branch name', "Branch name")
placeHolder: l10n.t('Branch name')
});
if (!branch) {

View File

@ -6,8 +6,3 @@
version "16.11.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.21.tgz#474d7589a30afcf5291f59bd49cca9ad171ffde4"
integrity sha512-Pf8M1XD9i1ksZEcCP8vuSNwooJ/bZapNmIzpmsMaL+jMI+8mEYU3PKvs+xDNuQcJWF/x24WzY4qxLtB0zNow9A==
vscode-nls@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==

View File

@ -2737,7 +2737,6 @@
"file-type": "16.5.4",
"jschardet": "3.0.0",
"picomatch": "2.3.1",
"vscode-nls": "^5.2.0",
"vscode-uri": "^2.0.0",
"which": "^1.3.0"
},

View File

@ -3,15 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
import { Command, Disposable, Event, EventEmitter, SourceControlActionButton, Uri, workspace } from 'vscode';
import { Command, Disposable, Event, EventEmitter, SourceControlActionButton, Uri, workspace, l10n } from 'vscode';
import { Branch, Status } from './api/git';
import { CommitCommandsCenter } from './postCommitCommands';
import { Repository, Operation } from './repository';
import { dispose } from './util';
const localize = nls.loadMessageBundle();
interface ActionButtonState {
readonly HEAD: Branch | undefined;
readonly isCommitInProgress: boolean;
@ -106,8 +103,8 @@ export class ActionButtonCommand {
if (this.state.isRebaseInProgress) {
return {
command: 'git.commit',
title: localize('scm button continue title', "{0} Continue", '$(check)'),
tooltip: this.state.isCommitInProgress ? localize('scm button continuing tooltip', "Continuing Rebase...") : localize('scm button continue tooltip', "Continue Rebase"),
title: l10n.t('{0} Continue', '$(check)'),
tooltip: this.state.isCommitInProgress ? l10n.t('Continuing Rebase...') : l10n.t('Continue Rebase'),
arguments: [this.repository.sourceControl, '']
};
}
@ -143,10 +140,10 @@ export class ActionButtonCommand {
return {
command: {
command: 'git.publish',
title: localize({ key: 'scm publish branch action button title', comment: ['{Locked="Branch"}', 'Do not translate "Branch" as it is a git term'] }, "{0} Publish Branch", '$(cloud-upload)'),
title: l10n.t({ message: '{0} Publish Branch', args: ['$(cloud-upload)'], comment: ['{Locked="Branch"}', 'Do not translate "Branch" as it is a git term'] }),
tooltip: this.state.isSyncInProgress ?
localize({ key: 'scm button publish branch running', comment: ['{Locked="Branch"}', 'Do not translate "Branch" as it is a git term'] }, "Publishing Branch...") :
localize({ key: 'scm button publish branch', comment: ['{Locked="Branch"}', 'Do not translate "Branch" as it is a git term'] }, "Publish Branch"),
l10n.t({ message: 'Publishing Branch...', comment: ['{Locked="Branch"}', 'Do not translate "Branch" as it is a git term'] }) :
l10n.t({ message: 'Publish Branch', comment: ['{Locked="Branch"}', 'Do not translate "Branch" as it is a git term'] }),
arguments: [this.repository.sourceControl],
},
enabled: !this.state.isSyncInProgress
@ -170,11 +167,11 @@ export class ActionButtonCommand {
command: 'git.sync',
title: `${icon}${behind}${ahead}`,
tooltip: this.state.isSyncInProgress ?
localize('syncing changes', "Synchronizing Changes...")
l10n.t('Synchronizing Changes...')
: this.repository.syncTooltip,
arguments: [this.repository.sourceControl],
},
description: localize('scm button sync description', "{0} Sync Changes{1}{2}", icon, behind, ahead),
description: l10n.t('{0} Sync Changes{1}{2}', icon, behind, ahead),
enabled: !this.state.isSyncInProgress
};
}

View File

@ -4,13 +4,11 @@
*--------------------------------------------------------------------------------------------*/
import * as fs from 'fs';
import * as nls from 'vscode-nls';
import { l10n } from 'vscode';
import { IPCClient } from './ipc/ipcClient';
const localize = nls.loadMessageBundle();
function fatal(err: any): void {
console.error(localize('missOrInvalid', "Missing or invalid credentials."));
console.error(l10n.t('Missing or invalid credentials.'));
console.error(err);
process.exit(1);
}

View File

@ -3,16 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
import { window, InputBoxOptions, Uri, Disposable, workspace, QuickPickOptions } from 'vscode';
import { window, InputBoxOptions, Uri, Disposable, workspace, QuickPickOptions, l10n } from 'vscode';
import { IDisposable, EmptyDisposable, toDisposable } from './util';
import * as path from 'path';
import { IIPCHandler, IIPCServer } from './ipc/ipcServer';
import { CredentialsProvider, Credentials } from './api/git';
import { ITerminalEnvironmentProvider } from './terminal';
const localize = nls.loadMessageBundle();
export class Askpass implements IIPCHandler, ITerminalEnvironmentProvider {
private env: { [key: string]: string };
@ -102,7 +99,7 @@ export class Askpass implements IIPCHandler, ITerminalEnvironmentProvider {
if (/passphrase/i.test(request)) {
const options: InputBoxOptions = {
password: true,
placeHolder: localize('ssh passphrase', "Passphrase"),
placeHolder: l10n.t('Passphrase'),
prompt: `SSH Key: ${file}`,
ignoreFocusOut: true
};
@ -114,13 +111,10 @@ export class Askpass implements IIPCHandler, ITerminalEnvironmentProvider {
const options: QuickPickOptions = {
canPickMany: false,
ignoreFocusOut: true,
placeHolder: localize('ssh authenticity prompt', "Are you sure you want to continue connecting?"),
title: localize('ssh authenticity title', "\"{0}\" has fingerprint \"{1}\"", host, fingerprint)
placeHolder: l10n.t('Are you sure you want to continue connecting?'),
title: l10n.t('"{0}" has fingerprint "{1}"', host ?? '', fingerprint ?? '')
};
const items = [
localize('ssh authenticity prompt yes', "yes"),
localize('ssh authenticity prompt no', "no")
];
const items = [l10n.t('yes'), l10n.t('no')];
return await window.showQuickPick(items, options) ?? '';
}

View File

@ -3,14 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workspace, Disposable, EventEmitter, Memento, window, MessageItem, ConfigurationTarget, Uri, ConfigurationChangeEvent } from 'vscode';
import { workspace, Disposable, EventEmitter, Memento, window, MessageItem, ConfigurationTarget, Uri, ConfigurationChangeEvent, l10n } from 'vscode';
import { Repository, Operation } from './repository';
import { eventToPromise, filterEvent, onceEvent } from './util';
import * as nls from 'vscode-nls';
import { GitErrorCodes } from './api/git';
const localize = nls.loadMessageBundle();
function isRemoteOperation(operation: Operation): boolean {
return operation === Operation.Pull || operation === Operation.Push || operation === Operation.Sync || operation === Operation.Fetch;
}
@ -51,10 +48,10 @@ export class AutoFetcher {
return;
}
const yes: MessageItem = { title: localize('yes', "Yes") };
const no: MessageItem = { isCloseAffordance: true, title: localize('no', "No") };
const askLater: MessageItem = { title: localize('not now', "Ask Me Later") };
const result = await window.showInformationMessage(localize('suggest auto fetch', "Would you like Code to [periodically run 'git fetch']({0})?", 'https://go.microsoft.com/fwlink/?linkid=865294'), yes, no, askLater);
const yes: MessageItem = { title: l10n.t('Yes') };
const no: MessageItem = { isCloseAffordance: true, title: l10n.t('No') };
const askLater: MessageItem = { title: l10n.t('Ask Me Later') };
const result = await window.showInformationMessage(l10n.t('Would you like Code to [periodically run "git fetch"]({0})?', 'https://go.microsoft.com/fwlink/?linkid=865294'), yes, no, askLater);
if (result === askLater) {
return;

File diff suppressed because it is too large Load Diff

View File

@ -3,10 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { env, ExtensionContext, workspace, window, Disposable, commands, Uri, version as vscodeVersion, WorkspaceFolder, LogOutputChannel } from 'vscode';
import { env, ExtensionContext, workspace, window, Disposable, commands, Uri, version as vscodeVersion, WorkspaceFolder, LogOutputChannel, l10n } from 'vscode';
import { findGit, Git, IGit } from './git';
import { Model } from './model';
import { CommandCenter } from './commands';
@ -50,7 +47,7 @@ async function createModel(context: ExtensionContext, logger: LogOutputChannel,
}
const info = await findGit(pathHints, gitPath => {
logger.info(localize('validating', "Validating found git in: {0}", gitPath));
logger.info(l10n.t('Validating found git in: "{0}"', gitPath));
if (excludes.length === 0) {
return true;
}
@ -58,7 +55,7 @@ async function createModel(context: ExtensionContext, logger: LogOutputChannel,
const normalized = path.normalize(gitPath).replace(/[\r\n]+$/, '');
const skip = excludes.some(e => normalized.startsWith(e));
if (skip) {
logger.info(localize('skipped', "Skipped found git in: {0}", gitPath));
logger.info(l10n.t('Skipped found git in: "{0}"', gitPath));
}
return !skip;
});
@ -81,7 +78,7 @@ async function createModel(context: ExtensionContext, logger: LogOutputChannel,
const terminalEnvironmentManager = new TerminalEnvironmentManager(context, [askpass, gitEditor, ipcServer]);
disposables.push(terminalEnvironmentManager);
logger.info(localize('using git', "Using git {0} from {1}", info.version, info.path));
logger.info(l10n.t('Using git "{0}" from "{1}"', info.version, info.path));
const git = new Git({
gitPath: info.path,
@ -159,10 +156,10 @@ async function warnAboutMissingGit(): Promise<void> {
return;
}
const download = localize('downloadgit', "Download Git");
const neverShowAgain = localize('neverShowAgain', "Don't Show Again");
const download = l10n.t('Download Git');
const neverShowAgain = l10n.t('Don\'t Show Again');
const choice = await window.showWarningMessage(
localize('notfound', "Git not found. Install it or configure it using the 'git.path' setting."),
l10n.t('Git not found. Install it or configure it using the "git.path" setting.'),
download,
neverShowAgain
);
@ -249,11 +246,11 @@ async function checkGitv1(info: IGit): Promise<void> {
return;
}
const update = localize('updateGit', "Update Git");
const neverShowAgain = localize('neverShowAgain', "Don't Show Again");
const update = l10n.t('Update Git');
const neverShowAgain = l10n.t('Don\'t Show Again');
const choice = await window.showWarningMessage(
localize('git20', "You seem to have git {0} installed. Code works best with git >= 2", info.version),
l10n.t('You seem to have git "{0}" installed. Code works best with git >= 2', info.version),
update,
neverShowAgain
);
@ -277,10 +274,10 @@ async function checkGitWindows(info: IGit): Promise<void> {
return;
}
const update = localize('updateGit', "Update Git");
const neverShowAgain = localize('neverShowAgain', "Don't Show Again");
const update = l10n.t('Update Git');
const neverShowAgain = l10n.t('Don\'t Show Again');
const choice = await window.showWarningMessage(
localize('git2526', "There are known issues with the installed Git {0}. Please update to Git >= 2.27 for the git features to work correctly.", info.version),
l10n.t('There are known issues with the installed Git "{0}". Please update to Git >= 2.27 for the git features to work correctly.', info.version),
update,
neverShowAgain
);

View File

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { workspace, WorkspaceFoldersChangeEvent, Uri, window, Event, EventEmitter, QuickPickItem, Disposable, SourceControl, SourceControlResourceGroup, TextEditor, Memento, commands, LogOutputChannel } from 'vscode';
import { workspace, WorkspaceFoldersChangeEvent, Uri, window, Event, EventEmitter, QuickPickItem, Disposable, SourceControl, SourceControlResourceGroup, TextEditor, Memento, commands, LogOutputChannel, l10n } from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';
import { Operation, Repository, RepositoryState } from './repository';
import { memoize, sequentialize, debounce } from './decorators';
@ -11,7 +11,6 @@ import { dispose, anyEvent, filterEvent, isDescendant, pathEquals, toDisposable,
import { Git } from './git';
import * as path from 'path';
import * as fs from 'fs';
import * as nls from 'vscode-nls';
import { fromGitUri } from './uri';
import { APIState as State, CredentialsProvider, PushErrorHandler, PublishEvent, RemoteSourcePublisher, PostCommitCommandsProvider } from './api/git';
import { Askpass } from './askpass';
@ -20,8 +19,6 @@ import { ApiRepository } from './api/api1';
import { IRemoteSourcePublisherRegistry } from './remotePublisher';
import { IPostCommitCommandsProviderRegistry } from './postCommitCommands';
const localize = nls.loadMessageBundle();
class RepositoryPick implements QuickPickItem {
@memoize get label(): string {
return path.basename(this.repository.root);
@ -187,7 +184,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
}
if (path.isAbsolute(scanPath)) {
const notSupportedMessage = localize('not supported', "Absolute paths not supported in 'git.scanRepositories' setting.");
const notSupportedMessage = l10n.t('Absolute paths not supported in "git.scanRepositories" setting.');
this.logger.warn(notSupportedMessage);
console.warn(notSupportedMessage);
continue;
@ -376,7 +373,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
if (!isRepoInWorkspaceFolders) {
if (this.showRepoOnHomeDriveRootWarning) {
window.showWarningMessage(localize('repoOnHomeDriveRootWarning', "Unable to automatically open the git repository at '{0}'. To open that git repository, open it directly as a folder in VS Code.", repositoryRoot));
window.showWarningMessage(l10n.t('Unable to automatically open the git repository at "{0}". To open that git repository, open it directly as a folder in VS Code.', repositoryRoot));
this.showRepoOnHomeDriveRootWarning = false;
}
@ -439,7 +436,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
}
if (repository.submodules.length > submodulesLimit) {
window.showWarningMessage(localize('too many submodules', "The '{0}' repository has {1} submodules which won't be opened automatically. You can still open each one individually by opening a file within.", path.basename(repository.root), repository.submodules.length));
window.showWarningMessage(l10n.t('The "{0}" repository has {1} submodules which won\'t be opened automatically. You can still open each one individually by opening a file within.', path.basename(repository.root), repository.submodules.length));
statusListener.dispose();
}
@ -513,7 +510,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
async pickRepository(): Promise<Repository | undefined> {
if (this.openRepositories.length === 0) {
throw new Error(localize('no repositories', "There are no available repositories"));
throw new Error(l10n.t('There are no available repositories'));
}
const picks = this.openRepositories.map((e, index) => new RepositoryPick(e.repository, index));
@ -526,7 +523,7 @@ export class Model implements IRemoteSourcePublisherRegistry, IPostCommitCommand
picks.unshift(...picks.splice(index, 1));
}
const placeHolder = localize('pick repo', "Choose a repository");
const placeHolder = l10n.t('Choose a repository');
const pick = await window.showQuickPick(picks, { placeHolder });
return pick && pick.repository;

View File

@ -3,8 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
import { Command, commands, Disposable, Event, EventEmitter, Memento, Uri, workspace } from 'vscode';
import { Command, commands, Disposable, Event, EventEmitter, Memento, Uri, workspace, l10n } from 'vscode';
import { PostCommitCommandsProvider } from './api/git';
import { Operation, Repository } from './repository';
import { ApiRepository } from './api/api1';
@ -17,8 +16,6 @@ export interface IPostCommitCommandsProviderRegistry {
registerPostCommitCommandsProvider(provider: PostCommitCommandsProvider): Disposable;
}
const localize = nls.loadMessageBundle();
export class GitPostCommitCommandsProvider implements PostCommitCommandsProvider {
getCommands(apiRepository: ApiRepository): Command[] {
const config = workspace.getConfiguration('git', Uri.file(apiRepository.repository.root));
@ -34,33 +31,33 @@ export class GitPostCommitCommandsProvider implements PostCommitCommandsProvider
// Tooltip (default)
let pushCommandTooltip = !alwaysCommitToNewBranch ?
localize('scm button commit and push tooltip', "Commit & Push Changes") :
localize('scm button commit to new branch and push tooltip', "Commit to New Branch & Push Changes");
l10n.t('Commit & Push Changes') :
l10n.t('Commit to New Branch & Push Changes');
let syncCommandTooltip = !alwaysCommitToNewBranch ?
localize('scm button commit and sync tooltip', "Commit & Sync Changes") :
localize('scm button commit to new branch and sync tooltip', "Commit to New Branch & Synchronize Changes");
l10n.t('Commit & Sync Changes') :
l10n.t('Commit to New Branch & Synchronize Changes');
// Tooltip (in progress)
if (apiRepository.repository.operations.isRunning(Operation.Commit)) {
pushCommandTooltip = !alwaysCommitToNewBranch ?
localize('scm button committing and pushing tooltip', "Committing & Pushing Changes...") :
localize('scm button committing to new branch and pushing tooltip', "Committing to New Branch & Pushing Changes...");
l10n.t('Committing & Pushing Changes...') :
l10n.t('Committing to New Branch & Pushing Changes...');
syncCommandTooltip = !alwaysCommitToNewBranch ?
localize('scm button committing and syncing tooltip', "Committing & Synchronizing Changes...") :
localize('scm button committing to new branch and syncing tooltip', "Committing to New Branch & Synchronizing Changes...");
l10n.t('Committing & Synchronizing Changes...') :
l10n.t('Committing to New Branch & Synchronizing Changes...');
}
return [
{
command: 'git.push',
title: localize('scm button commit and push title', "{0} Commit & Push", icon ?? '$(arrow-up)'),
title: l10n.t('{0} Commit & Push', icon ?? '$(arrow-up)'),
tooltip: pushCommandTooltip
},
{
command: 'git.sync',
title: localize('scm button commit and sync title', "{0} Commit & Sync", icon ?? '$(sync)'),
title: l10n.t('{0} Commit & Sync', icon ?? '$(sync)'),
tooltip: syncCommandTooltip
},
];
@ -151,17 +148,17 @@ export class CommitCommandsCenter {
// Tooltip (default)
let tooltip = !alwaysCommitToNewBranch ?
localize('scm button commit tooltip', "Commit Changes") :
localize('scm button commit to new branch tooltip', "Commit Changes to New Branch");
l10n.t('Commit Changes') :
l10n.t('Commit Changes to New Branch');
// Tooltip (in progress)
if (this.repository.operations.isRunning(Operation.Commit)) {
tooltip = !alwaysCommitToNewBranch ?
localize('scm button committing tooltip', "Committing Changes...") :
localize('scm button committing to new branch tooltip', "Committing Changes to New Branch...");
l10n.t('Committing Changes...') :
l10n.t('Committing Changes to New Branch...');
}
return { command: 'git.commit', title: localize('scm button commit title', "{0} Commit", icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, ''] };
return { command: 'git.commit', title: l10n.t('{0} Commit', icon ?? '$(check)'), tooltip, arguments: [this.repository.sourceControl, ''] };
}
private getPostCommitCommandStringFromSetting(): string | undefined {

View File

@ -3,10 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();
import { UriHandler, Uri, window, Disposable, commands, LogOutputChannel } from 'vscode';
import { UriHandler, Uri, window, Disposable, commands, LogOutputChannel, l10n } from 'vscode';
import { dispose } from './util';
import * as querystring from 'querystring';
@ -76,8 +73,8 @@ export class GitProtocolHandler implements UriHandler {
if (!(await commands.getCommands(true)).includes('git.clone')) {
this.logger.error('Could not complete git clone operation as git installation was not found.');
const errorMessage = localize('no git', 'Could not clone your repository as Git is not installed.');
const downloadGit = localize('download git', 'Download Git');
const errorMessage = l10n.t('Could not clone your repository as Git is not installed.');
const downloadGit = l10n.t('Download Git');
if (await window.showErrorMessage(errorMessage, { modal: true }, downloadGit) === downloadGit) {
commands.executeCommand('vscode.open', Uri.parse('https://aka.ms/vscode-download-git'));

View File

@ -6,9 +6,8 @@
import * as fs from 'fs';
import * as path from 'path';
import * as picomatch from 'picomatch';
import { CancellationToken, Command, Disposable, Event, EventEmitter, Memento, ProgressLocation, ProgressOptions, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, ThemeColor, Uri, window, workspace, WorkspaceEdit, FileDecoration, commands, Tab, TabInputTextDiff, TabInputNotebookDiff, RelativePattern, CancellationTokenSource, LogOutputChannel, LogLevel, CancellationError } from 'vscode';
import { CancellationToken, Command, Disposable, Event, EventEmitter, Memento, ProgressLocation, ProgressOptions, scm, SourceControl, SourceControlInputBox, SourceControlInputBoxValidation, SourceControlInputBoxValidationType, SourceControlResourceDecorations, SourceControlResourceGroup, SourceControlResourceState, ThemeColor, Uri, window, workspace, WorkspaceEdit, FileDecoration, commands, Tab, TabInputTextDiff, TabInputNotebookDiff, RelativePattern, CancellationTokenSource, LogOutputChannel, LogLevel, CancellationError, l10n } from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';
import * as nls from 'vscode-nls';
import { Branch, Change, ForcePushMode, GitErrorCodes, LogOptions, Ref, RefType, Remote, Status, CommitOptions, BranchQuery, FetchOptions } from './api/git';
import { AutoFetcher } from './autofetch';
import { debounce, memoize, throttle } from './decorators';
@ -25,7 +24,6 @@ import { IPostCommitCommandsProviderRegistry, CommitCommandsCenter } from './pos
const timeout = (millis: number) => new Promise(c => setTimeout(c, millis));
const localize = nls.loadMessageBundle();
const iconsRootPath = path.join(path.dirname(__dirname), 'resources', 'icons');
function getIconUri(iconName: string, theme: string): Uri {
@ -48,23 +46,23 @@ export class Resource implements SourceControlResourceState {
static getStatusText(type: Status) {
switch (type) {
case Status.INDEX_MODIFIED: return localize('index modified', "Index Modified");
case Status.MODIFIED: return localize('modified', "Modified");
case Status.INDEX_ADDED: return localize('index added', "Index Added");
case Status.INDEX_DELETED: return localize('index deleted', "Index Deleted");
case Status.DELETED: return localize('deleted', "Deleted");
case Status.INDEX_RENAMED: return localize('index renamed', "Index Renamed");
case Status.INDEX_COPIED: return localize('index copied', "Index Copied");
case Status.UNTRACKED: return localize('untracked', "Untracked");
case Status.IGNORED: return localize('ignored', "Ignored");
case Status.INTENT_TO_ADD: return localize('intent to add', "Intent to Add");
case Status.BOTH_DELETED: return localize('both deleted', "Conflict: Both Deleted");
case Status.ADDED_BY_US: return localize('added by us', "Conflict: Added By Us");
case Status.DELETED_BY_THEM: return localize('deleted by them', "Conflict: Deleted By Them");
case Status.ADDED_BY_THEM: return localize('added by them', "Conflict: Added By Them");
case Status.DELETED_BY_US: return localize('deleted by us', "Conflict: Deleted By Us");
case Status.BOTH_ADDED: return localize('both added', "Conflict: Both Added");
case Status.BOTH_MODIFIED: return localize('both modified', "Conflict: Both Modified");
case Status.INDEX_MODIFIED: return l10n.t('Index Modified');
case Status.MODIFIED: return l10n.t('Modified');
case Status.INDEX_ADDED: return l10n.t('Index Added');
case Status.INDEX_DELETED: return l10n.t('Index Deleted');
case Status.DELETED: return l10n.t('Deleted');
case Status.INDEX_RENAMED: return l10n.t('Index Renamed');
case Status.INDEX_COPIED: return l10n.t('Index Copied');
case Status.UNTRACKED: return l10n.t('Untracked');
case Status.IGNORED: return l10n.t('Ignored');
case Status.INTENT_TO_ADD: return l10n.t('Intent to Add');
case Status.BOTH_DELETED: return l10n.t('Conflict: Both Deleted');
case Status.ADDED_BY_US: return l10n.t('Conflict: Added By Us');
case Status.DELETED_BY_THEM: return l10n.t('Conflict: Deleted By Them');
case Status.ADDED_BY_THEM: return l10n.t('Conflict: Added By Them');
case Status.DELETED_BY_US: return l10n.t('Conflict: Deleted By Us');
case Status.BOTH_ADDED: return l10n.t('Conflict: Both Added');
case Status.BOTH_MODIFIED: return l10n.t('Conflict: Both Modified');
default: return '';
}
}
@ -529,7 +527,7 @@ class FileEventLogger {
private onDidChangeLogLevel(logLevel: LogLevel): void {
this.eventDisposable.dispose();
this.logger.appendLine(localize('logLevel', "Log level: {0}", LogLevel[logLevel]));
this.logger.appendLine(l10n.t('Log level: {0}', LogLevel[logLevel]));
if (logLevel > LogLevel.Debug) {
return;
@ -612,7 +610,7 @@ class ResourceCommandResolver {
resolveFileCommand(resource: Resource): Command {
return {
command: 'vscode.open',
title: localize('open', "Open"),
title: l10n.t('Open'),
arguments: [resource.resourceUri]
};
}
@ -625,20 +623,20 @@ class ResourceCommandResolver {
if (resource.rightUri && workspace.getConfiguration('git').get<boolean>('mergeEditor', false) && (bothModified || resource.type === Status.BOTH_ADDED)) {
return {
command: 'git.openMergeEditor',
title: localize('open.merge', "Open Merge"),
title: l10n.t('Open Merge'),
arguments: [resource.rightUri]
};
} else {
return {
command: 'vscode.open',
title: localize('open', "Open"),
title: l10n.t('Open'),
arguments: [resource.rightUri, { override: bothModified ? false : undefined }, title]
};
}
} else {
return {
command: 'vscode.diff',
title: localize('open', "Open"),
title: l10n.t('Open'),
arguments: [resource.leftUri, resource.rightUri, title]
};
}
@ -718,25 +716,25 @@ class ResourceCommandResolver {
case Status.INDEX_MODIFIED:
case Status.INDEX_RENAMED:
case Status.INDEX_ADDED:
return localize('git.title.index', '{0} (Index)', basename);
return l10n.t('{0} (Index)', basename);
case Status.MODIFIED:
case Status.BOTH_ADDED:
case Status.BOTH_MODIFIED:
return localize('git.title.workingTree', '{0} (Working Tree)', basename);
return l10n.t('{0} (Working Tree)', basename);
case Status.INDEX_DELETED:
case Status.DELETED:
return localize('git.title.deleted', '{0} (Deleted)', basename);
return l10n.t('{0} (Deleted)', basename);
case Status.DELETED_BY_US:
return localize('git.title.theirs', '{0} (Theirs)', basename);
return l10n.t('{0} (Theirs)', basename);
case Status.DELETED_BY_THEM:
return localize('git.title.ours', '{0} (Ours)', basename);
return l10n.t('{0} (Ours)', basename);
case Status.UNTRACKED:
return localize('git.title.untracked', '{0} (Untracked)', basename);
return l10n.t('{0} (Untracked)', basename);
default:
return '';
@ -940,7 +938,7 @@ export class Repository implements Disposable {
const root = Uri.file(repository.root);
this._sourceControl = scm.createSourceControl('git', 'Git', root);
this._sourceControl.acceptInputCommand = { command: 'git.commit', title: localize('commit', "Commit"), arguments: [this._sourceControl] };
this._sourceControl.acceptInputCommand = { command: 'git.commit', title: l10n.t('Commit'), arguments: [this._sourceControl] };
this._sourceControl.quickDiffProvider = this;
this._sourceControl.inputBox.validateInput = this.validateInput.bind(this);
this.disposables.push(this._sourceControl);
@ -948,10 +946,10 @@ export class Repository implements Disposable {
this.updateInputBoxPlaceholder();
this.disposables.push(this.onDidRunGitStatus(() => this.updateInputBoxPlaceholder()));
this._mergeGroup = this._sourceControl.createResourceGroup('merge', localize('merge changes', "Merge Changes"));
this._indexGroup = this._sourceControl.createResourceGroup('index', localize('staged changes', "Staged Changes"));
this._workingTreeGroup = this._sourceControl.createResourceGroup('workingTree', localize('changes', "Changes"));
this._untrackedGroup = this._sourceControl.createResourceGroup('untracked', localize('untracked changes', "Untracked Changes"));
this._mergeGroup = this._sourceControl.createResourceGroup('merge', l10n.t('Merge Changes'));
this._indexGroup = this._sourceControl.createResourceGroup('index', l10n.t('Staged Changes'));
this._workingTreeGroup = this._sourceControl.createResourceGroup('workingTree', l10n.t('Changes'));
this._untrackedGroup = this._sourceControl.createResourceGroup('untracked', l10n.t('Untracked Changes'));
const updateIndexGroupVisibility = () => {
const config = workspace.getConfiguration('git', root);
@ -1011,7 +1009,7 @@ export class Repository implements Disposable {
const gitConfig = workspace.getConfiguration('git');
if (gitConfig.get<boolean>('showPushSuccessNotification')) {
window.showInformationMessage(localize('push success', "Successfully pushed."));
window.showInformationMessage(l10n.t('Successfully pushed.'));
}
}, null, this.disposables);
@ -1044,7 +1042,7 @@ export class Repository implements Disposable {
let tooManyChangesWarning: SourceControlInputBoxValidation | undefined;
if (this.isRepositoryHuge) {
tooManyChangesWarning = {
message: localize('tooManyChangesWarning', "Too many changes were detected. Only the first {0} changes will be shown below.", this.isRepositoryHuge.limit),
message: l10n.t('Too many changes were detected. Only the first {0} changes will be shown below.', this.isRepositoryHuge.limit),
type: SourceControlInputBoxValidationType.Warning
};
}
@ -1052,7 +1050,7 @@ export class Repository implements Disposable {
if (this.rebaseCommit) {
if (this.rebaseCommit.message !== text) {
return {
message: localize('commit in rebase', "It's not possible to change the commit message in the middle of a rebase. Please complete the rebase operation and use interactive rebase instead."),
message: l10n.t('It\'s not possible to change the commit message in the middle of a rebase. Please complete the rebase operation and use interactive rebase instead.'),
type: SourceControlInputBoxValidationType.Warning
};
}
@ -1067,7 +1065,7 @@ export class Repository implements Disposable {
if (/^\s+$/.test(text)) {
return {
message: localize('commitMessageWhitespacesOnlyWarning', "Current commit message only contains whitespace characters"),
message: l10n.t('Current commit message only contains whitespace characters'),
type: SourceControlInputBoxValidationType.Warning
};
}
@ -1102,12 +1100,12 @@ export class Repository implements Disposable {
}
return {
message: localize('commitMessageCountdown', "{0} characters left in current line", threshold - line.length),
message: l10n.t('{0} characters left in current line', threshold - line.length),
type: SourceControlInputBoxValidationType.Information
};
} else {
return {
message: localize('commitMessageWarning', "{0} characters over {1} in current line", line.length - threshold, threshold),
message: l10n.t('{0} characters over {1} in current line', line.length - threshold, threshold),
type: SourceControlInputBoxValidationType.Warning
};
}
@ -1606,7 +1604,7 @@ export class Repository implements Disposable {
if (supportCancellation) {
const opts: ProgressOptions = {
location: ProgressLocation.Notification,
title: localize('sync is unpredictable', "Syncing. Cancelling may cause serious damages to the repository"),
title: l10n.t('Syncing. Cancelling may cause serious damages to the repository'),
cancellable: true
};
@ -1655,13 +1653,13 @@ export class Repository implements Disposable {
return true;
}
const always = { title: localize('always pull', "Always Pull") };
const pull = { title: localize('pull', "Pull") };
const cancel = { title: localize('dont pull', "Don't Pull") };
const always = { title: l10n.t('Always Pull') };
const pull = { title: l10n.t('Pull') };
const cancel = { title: l10n.t('Don\'t Pull') };
const result = await window.showWarningMessage(
currentBranch
? localize('pull branch maybe rebased', "It looks like the current branch \'{0}\' might have been rebased. Are you sure you still want to pull into it?", currentBranch)
: localize('pull maybe rebased', "It looks like the current branch might have been rebased. Are you sure you still want to pull into it?"),
? l10n.t('It looks like the current branch "{0}" might have been rebased. Are you sure you still want to pull into it?', currentBranch)
: l10n.t('It looks like the current branch might have been rebased. Are you sure you still want to pull into it?'),
always, pull, cancel
);
@ -2054,16 +2052,16 @@ export class Repository implements Disposable {
if (didHitLimit && !shouldIgnore && !this.didWarnAboutLimit) {
const knownHugeFolderPaths = await this.findKnownHugeFolderPathsToIgnore();
const gitWarn = localize('huge', "The git repository at '{0}' has too many active changes, only a subset of Git features will be enabled.", this.repository.root);
const neverAgain = { title: localize('neveragain', "Don't Show Again") };
const gitWarn = l10n.t('The git repository at "{0}" has too many active changes, only a subset of Git features will be enabled.', this.repository.root);
const neverAgain = { title: l10n.t('Don\'t Show Again') };
if (knownHugeFolderPaths.length > 0) {
const folderPath = knownHugeFolderPaths[0];
const folderName = path.basename(folderPath);
const addKnown = localize('add known', "Would you like to add '{0}' to .gitignore?", folderName);
const yes = { title: localize('yes', "Yes") };
const no = { title: localize('no', "No") };
const addKnown = l10n.t('Would you like to add "{0}" to .gitignore?', folderName);
const yes = { title: l10n.t('Yes') };
const no = { title: l10n.t('No') };
const result = await window.showWarningMessage(`${gitWarn} ${addKnown}`, yes, no, neverAgain);
if (result === yes) {
@ -2076,7 +2074,7 @@ export class Repository implements Disposable {
this.didWarnAboutLimit = true;
}
} else {
const ok = { title: localize('ok', "OK") };
const ok = { title: l10n.t('OK') };
const result = await window.showWarningMessage(gitWarn, ok, neverAgain);
if (result === neverAgain) {
config.update('ignoreLimitWarning', true, false);
@ -2297,18 +2295,18 @@ export class Repository implements Disposable {
|| !this.HEAD.upstream
|| !(this.HEAD.ahead || this.HEAD.behind)
) {
return localize('sync changes', "Synchronize Changes");
return l10n.t('Synchronize Changes');
}
const remoteName = this.HEAD && this.HEAD.remote || this.HEAD.upstream.remote;
const remote = this.remotes.find(r => r.name === remoteName);
if ((remote && remote.isReadOnly) || !this.HEAD.ahead) {
return localize('pull n', "Pull {0} commits from {1}/{2}", this.HEAD.behind, this.HEAD.upstream.remote, this.HEAD.upstream.name);
return l10n.t('Pull {0} commits from {1}/{2}', this.HEAD.behind!, this.HEAD.upstream.remote, this.HEAD.upstream.name);
} else if (!this.HEAD.behind) {
return localize('push n', "Push {0} commits to {1}/{2}", this.HEAD.ahead, this.HEAD.upstream.remote, this.HEAD.upstream.name);
return l10n.t('Push {0} commits to {1}/{2}', this.HEAD.ahead, this.HEAD.upstream.remote, this.HEAD.upstream.name);
} else {
return localize('pull push n', "Pull {0} and push {1} commits between {2}/{3}", this.HEAD.behind, this.HEAD.ahead, this.HEAD.upstream.remote, this.HEAD.upstream.name);
return l10n.t('Pull {0} and push {1} commits between {2}/{3}', this.HEAD.behind, this.HEAD.ahead, this.HEAD.upstream.remote, this.HEAD.upstream.name);
}
}
@ -2317,9 +2315,9 @@ export class Repository implements Disposable {
if (branchName) {
// '{0}' will be replaced by the corresponding key-command later in the process, which is why it needs to stay.
this._sourceControl.inputBox.placeholder = localize('commitMessageWithHeadLabel', "Message ({0} to commit on '{1}')", '{0}', branchName);
this._sourceControl.inputBox.placeholder = l10n.t('Message ({0} to commit on "{1}")', '{0}', branchName);
} else {
this._sourceControl.inputBox.placeholder = localize('commitMessage', "Message ({0} to commit)");
this._sourceControl.inputBox.placeholder = l10n.t('Message ({0} to commit)');
}
}

View File

@ -3,15 +3,12 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Disposable, Command, EventEmitter, Event, workspace, Uri } from 'vscode';
import { Disposable, Command, EventEmitter, Event, workspace, Uri, l10n } from 'vscode';
import { Repository, Operation } from './repository';
import { anyEvent, dispose, filterEvent } from './util';
import * as nls from 'vscode-nls';
import { Branch, RemoteSourcePublisher } from './api/git';
import { IRemoteSourcePublisherRegistry } from './remotePublisher';
const localize = nls.loadMessageBundle();
class CheckoutStatusBar {
private _onDidChange = new EventEmitter<void>();
@ -25,11 +22,11 @@ class CheckoutStatusBar {
get command(): Command | undefined {
const rebasing = !!this.repository.rebaseCommit;
const isBranchProtected = this.repository.isBranchProtected();
const label = `${this.repository.headLabel}${rebasing ? ` (${localize('rebasing', 'Rebasing')})` : ''}`;
const label = `${this.repository.headLabel}${rebasing ? ` (${l10n.t('Rebasing')})` : ''}`;
return {
command: 'git.checkout',
tooltip: localize('checkout', "{0}, Checkout branch/tag...", label),
tooltip: l10n.t('{0}, Checkout branch/tag...', label),
title: `${isBranchProtected ? '$(lock)' : '$(git-branch)'} ${label}`,
arguments: [this.repository.sourceControl]
};
@ -122,8 +119,8 @@ class SyncStatusBar {
}
const tooltip = this.state.remoteSourcePublishers.length === 1
? localize('publish to', "Publish to {0}", this.state.remoteSourcePublishers[0].name)
: localize('publish to...', "Publish to...");
? l10n.t('Publish to {0}', this.state.remoteSourcePublishers[0].name)
: l10n.t('Publish to...');
return {
command: 'git.publish',
@ -150,7 +147,7 @@ class SyncStatusBar {
} else {
icon = '$(cloud-upload)';
command = 'git.publish';
tooltip = localize('publish branch', "Publish Branch");
tooltip = l10n.t('Publish Branch');
}
} else {
command = '';
@ -160,7 +157,7 @@ class SyncStatusBar {
if (this.state.isSyncRunning) {
icon = '$(sync~spin)';
command = '';
tooltip = localize('syncing changes', "Synchronizing Changes...");
tooltip = l10n.t('Synchronizing Changes...');
}
return {

View File

@ -3,16 +3,13 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vscode-nls';
import { CancellationToken, ConfigurationChangeEvent, Disposable, env, Event, EventEmitter, MarkdownString, ThemeIcon, Timeline, TimelineChangeEvent, TimelineItem, TimelineOptions, TimelineProvider, Uri, workspace } from 'vscode';
import { CancellationToken, ConfigurationChangeEvent, Disposable, env, Event, EventEmitter, MarkdownString, ThemeIcon, Timeline, TimelineChangeEvent, TimelineItem, TimelineOptions, TimelineProvider, Uri, workspace, l10n } from 'vscode';
import { Model } from './model';
import { Repository, Resource } from './repository';
import { debounce } from './decorators';
import { emojify, ensureEmojis } from './emoji';
import { CommandCenter } from './commands';
const localize = nls.loadMessageBundle();
export class GitTimelineItem extends TimelineItem {
static is(item: TimelineItem): item is GitTimelineItem {
return item instanceof GitTimelineItem;
@ -54,7 +51,7 @@ export class GitTimelineItem extends TimelineItem {
this.tooltip = new MarkdownString('', true);
if (email) {
const emailTitle = localize('git.timeline.email', "Email");
const emailTitle = l10n.t('Email');
this.tooltip.appendMarkdown(`$(account) [**${author}**](mailto:${email} "${emailTitle} ${author}")\n\n`);
} else {
this.tooltip.appendMarkdown(`$(account) **${author}**\n\n`);
@ -79,7 +76,7 @@ export class GitTimelineProvider implements TimelineProvider {
}
readonly id = 'git-history';
readonly label = localize('git.timeline.source', 'Git History');
readonly label = l10n.t('Git History');
private readonly disposable: Disposable;
private providerDisposable: Disposable | undefined;
@ -171,7 +168,7 @@ export class GitTimelineProvider implements TimelineProvider {
const showAuthor = config.get<boolean>('showAuthor');
const showUncommitted = config.get<boolean>('showUncommitted');
const openComparison = localize('git.timeline.openComparison', "Open Comparison");
const openComparison = l10n.t('Open Comparison');
const items = commits.map<GitTimelineItem>((c, i) => {
const date = dateType === 'authored' ? c.authorDate : c.commitDate;
@ -199,13 +196,13 @@ export class GitTimelineProvider implements TimelineProvider {
});
if (options.cursor === undefined) {
const you = localize('git.timeline.you', 'You');
const you = l10n.t('You');
const index = repo.indexGroup.resourceStates.find(r => r.resourceUri.fsPath === uri.fsPath);
if (index) {
const date = this.repoStatusDate ?? new Date();
const item = new GitTimelineItem('~', 'HEAD', localize('git.timeline.stagedChanges', 'Staged Changes'), date.getTime(), 'index', 'git:file:index');
const item = new GitTimelineItem('~', 'HEAD', l10n.t('Staged Changes'), date.getTime(), 'index', 'git:file:index');
// TODO@eamodio: Replace with a better icon -- reflecting its status maybe?
item.iconPath = new ThemeIcon('git-commit');
item.description = '';
@ -228,7 +225,7 @@ export class GitTimelineProvider implements TimelineProvider {
if (working) {
const date = new Date();
const item = new GitTimelineItem('', index ? '~' : 'HEAD', localize('git.timeline.uncommitedChanges', 'Uncommitted Changes'), date.getTime(), 'working', 'git:file:working');
const item = new GitTimelineItem('', index ? '~' : 'HEAD', l10n.t('Uncommitted Changes'), date.getTime(), 'working', 'git:file:working');
item.iconPath = new ThemeIcon('circle-outline');
item.description = '';
item.setItemDetails(you, undefined, dateFormatter.format(date), Resource.getStatusText(working.type));

View File

@ -186,11 +186,6 @@ util-deprecate@^1.0.1:
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==
vscode-nls@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
vscode-uri@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/vscode-uri/-/vscode-uri-2.0.0.tgz#2df704222f72b8a71ff266ba0830ed6c51ac1542"

View File

@ -134,8 +134,7 @@
},
"dependencies": {
"@octokit/rest": "19.0.4",
"tunnel": "^0.0.6",
"vscode-nls": "^5.2.0"
"tunnel": "^0.0.6"
},
"devDependencies": {
"@types/node": "16.x"

View File

@ -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));
}

View File

@ -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);

View File

@ -152,11 +152,6 @@ universal-user-agent@^6.0.0:
resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee"
integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==
vscode-nls@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-5.2.0.tgz#3cb6893dd9bd695244d8a024bdf746eea665cc3f"
integrity sha512-RAaHx7B14ZU04EU31pT+rKz2/zSl7xMsfIZuo8pd+KZO6PXtQmpevpq3vxvWNcrGbdmhM/rr5Uw5Mz+NBfhVng==
webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"