Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

localize for zh-cn #580

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
14 changes: 14 additions & 0 deletions localization/localize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

import * as path from 'path';
import * as vscode from 'vscode';
/** language data */
const localeData = require(path.join(__dirname, `${vscode.env.language}.json`));

/** made tilte in language,easy to new gay used git.
* @param word title or option word
* @returns word after localize
*/
export const localize:( word:string) =>string =
! localeData
? word=> localeData[word] ?? word
: word=> word
31 changes: 31 additions & 0 deletions localization/zh-cn.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"Checkout Branch": "切换此处分支",
"Rename Branch": "重命名此分支",
"Enter the new name for branch": "输入新名字",
"Delete Branch": "删除此分支",
"Force Delete": "完全删除",
"Are you sure you want to delete the branch": "你是否确定要删除分支",
"yes, delete": "是的,删除",
"Merge into current branch": "混合到当前分支",
"Rebase current branch on Branch": "基于该分支重建当前分支",
"Push Branch": "上传本地分支",
"Create Pull Request": "创建Pull Request",
"Add Tag": "添加标签",
"Create Branch": "创建新分支",
"Checkout": "切换到",
"Drop": "从上下文中移除该区块",
"Rebase current branch on this Commit": "基于该区块重建当前分支",
"Copy Commit Hash to Clipboard": "复制区块的哈希到剪贴板",
"Copy Commit Subject to Clipboard": "复制区块的备注到剪贴板",
"Delete Remote Branch": "删除库分支",
"Fetch into local branch": "刷新这个库分支到本地",
"Pull into current branch": "下载到当前分支",
"Apply Stash": "新建暂存",
"Create Branch from Stash": "从暂存创建分支",
"Pop Stash": "取出并删除暂存",
"Drop Stash": "删除暂存",
"Copy Stash Name to Clipboard": "复制暂存的到剪贴板",
"Copy Stash Hash to Clipboard": "复制暂存的哈希到剪贴板",
"Create branch at commit": "创建新分支于此区块上"

}
76 changes: 38 additions & 38 deletions web/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -971,23 +971,23 @@ class GitGraphView {
const isSelectedInBranchesDropdown = this.branchDropdown.isSelected(refName);
return [[
{
title: 'Checkout Branch',
title: localize('Checkout Branch'),
visible: visibility.checkout && this.gitBranchHead !== refName,
onClick: () => this.checkoutBranchAction(refName, null, null, target)
}, {
title: 'Rename Branch' + ELLIPSIS,
title: localize('Rename Branch') + ELLIPSIS,
visible: visibility.rename,
onClick: () => {
dialog.showRefInput('Enter the new name for branch <b><i>' + escapeHtml(refName) + '</i></b>:', refName, 'Rename Branch', (newName) => {
dialog.showRefInput(localize('Enter the new name for branch') + ' <b><i>' + escapeHtml(refName) + '</i></b>:', refName, localize('Rename Branch'), (newName) => {
runAction({ command: 'renameBranch', repo: this.currentRepo, oldName: refName, newName: newName }, 'Renaming Branch');
}, target);
}
}, {
title: 'Delete Branch' + ELLIPSIS,
title: localize('Delete Branch') + ELLIPSIS,
visible: visibility.delete && this.gitBranchHead !== refName,
onClick: () => {
let remotesWithBranch = this.gitRemotes.filter(remote => this.gitBranches.includes('remotes/' + remote + '/' + refName));
let inputs: DialogInput[] = [{ type: DialogInputType.Checkbox, name: 'Force Delete', value: this.config.dialogDefaults.deleteBranch.forceDelete }];
let inputs: DialogInput[] = [{ type: DialogInputType.Checkbox, name: localize('Force Delete'), value: this.config.dialogDefaults.deleteBranch.forceDelete }];
if (remotesWithBranch.length > 0) {
inputs.push({
type: DialogInputType.Checkbox,
Expand All @@ -996,20 +996,20 @@ class GitGraphView {
info: 'This branch is on the remote' + (remotesWithBranch.length > 1 ? 's: ' : ' ') + formatCommaSeparatedList(remotesWithBranch.map((remote) => '"' + remote + '"'))
});
}
dialog.showForm('Are you sure you want to delete the branch <b><i>' + escapeHtml(refName) + '</i></b>?', inputs, 'Yes, delete', (values) => {
dialog.showForm(localize('Are you sure you want to delete the branch') + ' <b><i>' + escapeHtml(refName) + '</i></b>?', inputs, localize('yes, delete'), (values) => {
runAction({ command: 'deleteBranch', repo: this.currentRepo, branchName: refName, forceDelete: <boolean>values[0], deleteOnRemotes: remotesWithBranch.length > 0 && <boolean>values[1] ? remotesWithBranch : [] }, 'Deleting Branch');
}, target);
}
}, {
title: 'Merge into current branch' + ELLIPSIS,
title: localize('Merge into current branch') + ELLIPSIS,
visible: visibility.merge && this.gitBranchHead !== refName,
onClick: () => this.mergeAction(refName, refName, GG.MergeActionOn.Branch, target)
}, {
title: 'Rebase current branch on Branch' + ELLIPSIS,
title: localize('Rebase current branch on Branch') + ELLIPSIS,
visible: visibility.rebase && this.gitBranchHead !== refName,
onClick: () => this.rebaseAction(refName, refName, GG.RebaseActionOn.Branch, target)
}, {
title: 'Push Branch' + ELLIPSIS,
title: localize('Push Branch') + ELLIPSIS,
visible: visibility.push && this.gitRemotes.length > 0,
onClick: () => {
const multipleRemotes = this.gitRemotes.length > 1;
Expand Down Expand Up @@ -1054,7 +1054,7 @@ class GitGraphView {
}
], [
{
title: 'Create Pull Request' + ELLIPSIS,
title: localize('Create Pull Request') + ELLIPSIS,
visible: visibility.createPullRequest && this.gitRepos[this.currentRepo].pullRequestConfig !== null,
onClick: () => {
const config = this.gitRepos[this.currentRepo].pullRequestConfig;
Expand Down Expand Up @@ -1098,11 +1098,11 @@ class GitGraphView {
const commit = this.commits[this.commitLookup[hash]];
return [[
{
title: 'Add Tag' + ELLIPSIS,
title: localize('Add Tag') + ELLIPSIS,
visible: visibility.addTag,
onClick: () => this.addTagAction(hash, '', this.config.dialogDefaults.addTag.type, '', null, target)
}, {
title: 'Create Branch' + ELLIPSIS,
title: localize('Create Branch') + ELLIPSIS,
visible: visibility.createBranch,
onClick: () => this.createBranchAction(hash, '', this.config.dialogDefaults.createBranch.checkout, target)
}
Expand Down Expand Up @@ -1185,7 +1185,7 @@ class GitGraphView {
}
}
}, {
title: 'Drop' + ELLIPSIS,
title: localize('Drop') + ELLIPSIS,
visible: visibility.drop && this.graph.dropCommitPossible(this.commitLookup[hash]),
onClick: () => {
dialog.showConfirmation('Are you sure you want to permanently drop commit <b><i>' + abbrevCommit(hash) + '</i></b>?' + (this.onlyFollowFirstParent ? '<br/><i>Note: By enabling "Only follow the first parent of commits", some commits may have been hidden from the Git Graph View that could affect the outcome of performing this action.</i>' : ''), 'Yes, drop', () => {
Expand All @@ -1195,11 +1195,11 @@ class GitGraphView {
}
], [
{
title: 'Merge into current branch' + ELLIPSIS,
title: localize('Merge into current branch') + ELLIPSIS,
visible: visibility.merge,
onClick: () => this.mergeAction(hash, abbrevCommit(hash), GG.MergeActionOn.Commit, target)
}, {
title: 'Rebase current branch on this Commit' + ELLIPSIS,
title: localize('Rebase current branch on this Commit') + ELLIPSIS,
visible: visibility.rebase,
onClick: () => this.rebaseAction(hash, abbrevCommit(hash), GG.RebaseActionOn.Commit, target)
}, {
Expand All @@ -1217,14 +1217,14 @@ class GitGraphView {
}
], [
{
title: 'Copy Commit Hash to Clipboard',
title: localize('Copy Commit Hash to Clipboard'),
visible: visibility.copyHash,
onClick: () => {
sendMessage({ command: 'copyToClipboard', type: 'Commit Hash', data: hash });
}
},
{
title: 'Copy Commit Subject to Clipboard',
title: localize('Copy Commit Subject to Clipboard'),
visible: visibility.copySubject,
onClick: () => {
sendMessage({ command: 'copyToClipboard', type: 'Commit Subject', data: commit.message });
Expand All @@ -1240,19 +1240,19 @@ class GitGraphView {
const isSelectedInBranchesDropdown = this.branchDropdown.isSelected(prefixedRefName);
return [[
{
title: 'Checkout Branch' + ELLIPSIS,
title: localize('Checkout Branch') + ELLIPSIS,
visible: visibility.checkout,
onClick: () => this.checkoutBranchAction(refName, remote, null, target)
}, {
title: 'Delete Remote Branch' + ELLIPSIS,
title: localize('Delete Remote Branch') + ELLIPSIS,
visible: visibility.delete && remote !== '',
onClick: () => {
dialog.showConfirmation('Are you sure you want to delete the remote branch <b><i>' + escapeHtml(refName) + '</i></b>?', 'Yes, delete', () => {
dialog.showConfirmation('Are you sure you want to delete the remote branch <b><i>' + escapeHtml(refName) + '</i></b>?', localize('yes, delete'), () => {
runAction({ command: 'deleteRemoteBranch', repo: this.currentRepo, branchName: branchName, remote: remote }, 'Deleting Remote Branch');
}, target);
}
}, {
title: 'Fetch into local branch' + ELLIPSIS,
title: localize('Fetch into local branch') + ELLIPSIS,
visible: visibility.fetch && remote !== '' && this.gitBranches.includes(branchName) && this.gitBranchHead !== branchName,
onClick: () => {
dialog.showForm('Are you sure you want to fetch the remote branch <b><i>' + escapeHtml(refName) + '</i></b> into the local branch <b><i>' + escapeHtml(branchName) + '</i></b>?', [{
Expand All @@ -1265,11 +1265,11 @@ class GitGraphView {
}, target);
}
}, {
title: 'Merge into current branch' + ELLIPSIS,
title: localize('Merge into current branch') + ELLIPSIS,
visible: visibility.merge,
onClick: () => this.mergeAction(refName, refName, GG.MergeActionOn.RemoteTrackingBranch, target)
}, {
title: 'Pull into current branch' + ELLIPSIS,
title: localize('Pull into current branch') + ELLIPSIS,
visible: visibility.pull && remote !== '',
onClick: () => {
dialog.showForm('Are you sure you want to pull the remote branch <b><i>' + escapeHtml(refName) + '</i></b> into ' + (this.gitBranchHead !== null ? '<b><i>' + escapeHtml(this.gitBranchHead) + '</i></b> (the current branch)' : 'the current branch') + '? If a merge is required:', [
Expand All @@ -1282,7 +1282,7 @@ class GitGraphView {
}
], [
{
title: 'Create Pull Request',
title: localize('Create Pull Request'),
visible: visibility.createPullRequest && this.gitRepos[this.currentRepo].pullRequestConfig !== null && branchName !== 'HEAD' &&
(this.gitRepos[this.currentRepo].pullRequestConfig!.sourceRemote === remote || this.gitRepos[this.currentRepo].pullRequestConfig!.destRemote === remote),
onClick: () => {
Expand Down Expand Up @@ -1334,7 +1334,7 @@ class GitGraphView {
const hash = target.hash, selector = target.ref, visibility = this.config.contextMenuActionsVisibility.stash;
return [[
{
title: 'Apply Stash' + ELLIPSIS,
title: localize('Apply Stash') + ELLIPSIS,
visible: visibility.apply,
onClick: () => {
dialog.showForm('Are you sure you want to apply the stash <b><i>' + escapeHtml(selector.substring(5)) + '</i></b>?', [{
Expand All @@ -1347,15 +1347,15 @@ class GitGraphView {
}, target);
}
}, {
title: 'Create Branch from Stash' + ELLIPSIS,
title: localize('Create Branch from Stash') + ELLIPSIS,
visible: visibility.createBranch,
onClick: () => {
dialog.showRefInput('Create a branch from stash <b><i>' + escapeHtml(selector.substring(5)) + '</i></b> with the name:', '', 'Create Branch', (branchName) => {
dialog.showRefInput('Create a branch from stash <b><i>' + escapeHtml(selector.substring(5)) + '</i></b> with the name:', '', localize('Create Branch'), (branchName) => {
runAction({ command: 'branchFromStash', repo: this.currentRepo, selector: selector, branchName: branchName }, 'Creating Branch');
}, target);
}
}, {
title: 'Pop Stash' + ELLIPSIS,
title: localize('Pop Stash') + ELLIPSIS,
visible: visibility.pop,
onClick: () => {
dialog.showForm('Are you sure you want to pop the stash <b><i>' + escapeHtml(selector.substring(5)) + '</i></b>?', [{
Expand All @@ -1368,7 +1368,7 @@ class GitGraphView {
}, target);
}
}, {
title: 'Drop Stash' + ELLIPSIS,
title: localize('Drop Stash') + ELLIPSIS,
visible: visibility.drop,
onClick: () => {
dialog.showConfirmation('Are you sure you want to drop the stash <b><i>' + escapeHtml(selector.substring(5)) + '</i></b>?', 'Yes, drop', () => {
Expand All @@ -1378,13 +1378,13 @@ class GitGraphView {
}
], [
{
title: 'Copy Stash Name to Clipboard',
title: localize('Copy Stash Name to Clipboard'),
visible: visibility.copyName,
onClick: () => {
sendMessage({ command: 'copyToClipboard', type: 'Stash Name', data: selector });
}
}, {
title: 'Copy Stash Hash to Clipboard',
title: localize('Copy Stash Hash to Clipboard'),
visible: visibility.copyHash,
onClick: () => {
sendMessage({ command: 'copyToClipboard', type: 'Stash Hash', data: hash });
Expand All @@ -1410,15 +1410,15 @@ class GitGraphView {
if (this.gitRemotes.length > 1) {
let options = [{ name: 'Don\'t delete on any remote', value: '-1' }];
this.gitRemotes.forEach((remote, i) => options.push({ name: remote, value: i.toString() }));
dialog.showSelect(message + '<br>Do you also want to delete the tag on a remote:', '-1', options, 'Yes, delete', remoteIndex => {
dialog.showSelect(message + '<br>Do you also want to delete the tag on a remote:', '-1', options, localize('yes, delete'), remoteIndex => {
this.deleteTagAction(tagName, remoteIndex !== '-1' ? this.gitRemotes[parseInt(remoteIndex)] : null);
}, target);
} else if (this.gitRemotes.length === 1) {
dialog.showCheckbox(message, 'Also delete on remote', false, 'Yes, delete', deleteOnRemote => {
dialog.showCheckbox(message, 'Also delete on remote', false, localize('yes, delete'), deleteOnRemote => {
this.deleteTagAction(tagName, deleteOnRemote ? this.gitRemotes[0] : null);
}, target);
} else {
dialog.showConfirmation(message, 'Yes, delete', () => {
dialog.showConfirmation(message, localize('yes, delete'), () => {
this.deleteTagAction(tagName, null);
}, target);
}
Expand Down Expand Up @@ -1536,7 +1536,7 @@ class GitGraphView {
inputs.push({ type: DialogInputType.Checkbox, name: 'Push to remote', value: defaultValue, info: 'Once this tag has been added, push it to the repositories remote.' });
}

dialog.showForm('Add tag to commit <b><i>' + abbrevCommit(hash) + '</i></b>:', inputs, 'Add Tag', (values) => {
dialog.showForm('Add tag to commit <b><i>' + abbrevCommit(hash) + '</i></b>:', inputs, localize('Add Tag'), (values) => {
const tagName = <string>values[0];
const type = <string>values[1] === 'annotated' ? GG.TagType.Annotated : GG.TagType.Lightweight;
const message = <string>values[2];
Expand All @@ -1560,7 +1560,7 @@ class GitGraphView {

private checkoutBranchAction(refName: string, remote: string | null, prefillName: string | null, target: DialogTarget & (CommitTarget | RefTarget)) {
if (remote !== null) {
dialog.showRefInput('Enter the name of the new branch you would like to create when checking out <b><i>' + escapeHtml(refName) + '</i></b>:', (prefillName !== null ? prefillName : (remote !== '' ? refName.substring(remote.length + 1) : refName)), 'Checkout Branch', newBranch => {
dialog.showRefInput('Enter the name of the new branch you would like to create when checking out <b><i>' + escapeHtml(refName) + '</i></b>:', (prefillName !== null ? prefillName : (remote !== '' ? refName.substring(remote.length + 1) : refName)), localize('Checkout Branch'), newBranch => {
if (this.gitBranches.includes(newBranch)) {
const canPullFromRemote = remote !== '';
dialog.showTwoButtons('The name <b><i>' + escapeHtml(newBranch) + '</i></b> is already used by another branch:', 'Choose another branch name', () => {
Expand Down Expand Up @@ -1591,10 +1591,10 @@ class GitGraphView {
}

private createBranchAction(hash: string, initialName: string, initialCheckOut: boolean, target: DialogTarget & CommitTarget) {
dialog.showForm('Create branch at commit <b><i>' + abbrevCommit(hash) + '</i></b>:', [
dialog.showForm(localize('Create branch at commit') + ' <b><i>' + abbrevCommit(hash) + '</i></b>:', [
{ type: DialogInputType.TextRef, name: 'Name', default: initialName },
{ type: DialogInputType.Checkbox, name: 'Check out', value: initialCheckOut }
], 'Create Branch', (values) => {
], localize('Create Branch'), (values) => {
const branchName = <string>values[0], checkOut = <boolean>values[1];
if (this.gitBranches.includes(branchName)) {
dialog.showTwoButtons('A branch named <b><i>' + escapeHtml(branchName) + '</i></b> already exists, do you want to replace it with this new branch?', 'Yes, replace the existing branch', () => {
Expand Down
4 changes: 2 additions & 2 deletions web/settingsWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class SettingsWidget {
if (this.repo.name !== null) {
document.getElementById('deleteRepoName')!.addEventListener('click', () => {
if (this.currentRepo === null || this.repo === null || this.repo.name === null) return;
dialog.showConfirmation('Are you sure you want to delete the manually configured name <b><i>' + escapeHtml(this.repo.name) + '</i></b> for this repository, and use the default name from the File System <b><i>' + escapeHtml(getRepoName(this.currentRepo)) + '</i></b>?', 'Yes, delete', () => {
dialog.showConfirmation('Are you sure you want to delete the manually configured name <b><i>' + escapeHtml(this.repo.name) + '</i></b> for this repository, and use the default name from the File System <b><i>' + escapeHtml(getRepoName(this.currentRepo)) + '</i></b>?', localize('yes, delete'), () => {
if (this.currentRepo === null) return;
this.view.saveRepoStateValue(this.currentRepo, 'name', null);
this.view.renderRepoDropdownOptions();
Expand Down Expand Up @@ -408,7 +408,7 @@ class SettingsWidget {
addListenerToClass('deleteRemote', 'click', (e) => {
const remote = this.getRemoteForBtnEvent(e);
if (remote === null) return;
dialog.showConfirmation('Are you sure you want to delete the remote <b><i>' + escapeHtml(remote.name) + '</i></b>?', 'Yes, delete', () => {
dialog.showConfirmation('Are you sure you want to delete the remote <b><i>' + escapeHtml(remote.name) + '</i></b>?', localize('yes, delete'), () => {
if (this.currentRepo === null) return;
runAction({ command: 'deleteRemote', repo: this.currentRepo, name: remote.name }, 'Deleting Remote');
}, { type: TargetType.Repo });
Expand Down