From 5275161a8813afc9a0cacd890984bddb2591ecac Mon Sep 17 00:00:00 2001 From: Ryooooooga <eial5q265e5@gmail.com> Date: Tue, 10 May 2022 20:10:59 +0900 Subject: [PATCH 1/2] chore(i18n): localize panel titles --- docs/keybindings/Keybindings_en.md | 44 +++++++++++++++--------------- docs/keybindings/Keybindings_ja.md | 13 ++++++--- docs/keybindings/Keybindings_pl.md | 44 +++++++++++++++--------------- pkg/gui/branches_panel.go | 2 +- pkg/gui/context/context.go | 17 ++++++------ pkg/gui/gui.go | 2 +- pkg/gui/keybindings.go | 4 +-- pkg/gui/recent_repos_panel.go | 2 +- pkg/i18n/english.go | 4 ++- pkg/i18n/japanese.go | 9 +++--- 10 files changed, 75 insertions(+), 66 deletions(-) diff --git a/docs/keybindings/Keybindings_en.md b/docs/keybindings/Keybindings_en.md index e094f4910..f9887d7e3 100644 --- a/docs/keybindings/Keybindings_en.md +++ b/docs/keybindings/Keybindings_en.md @@ -41,28 +41,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>[</kbd>: previous tab </pre> -## Branches - -<pre> - <kbd>ctrl+o</kbd>: copy branch name to clipboard - <kbd>i</kbd>: show git-flow options - <kbd>space</kbd>: checkout - <kbd>n</kbd>: new branch - <kbd>o</kbd>: create pull request - <kbd>O</kbd>: create pull request options - <kbd>ctrl+y</kbd>: copy pull request URL to clipboard - <kbd>c</kbd>: checkout by name - <kbd>F</kbd>: force checkout - <kbd>d</kbd>: delete branch - <kbd>r</kbd>: rebase checked-out branch onto this branch - <kbd>M</kbd>: merge into currently checked out branch - <kbd>f</kbd>: fast-forward this branch from its upstream - <kbd>g</kbd>: view reset options - <kbd>R</kbd>: rename branch - <kbd>u</kbd>: set/unset upstream - <kbd>enter</kbd>: view commits -</pre> - ## Commit Files <pre> @@ -137,6 +115,28 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>f</kbd>: fetch </pre> +## Local Branches + +<pre> + <kbd>ctrl+o</kbd>: copy branch name to clipboard + <kbd>i</kbd>: show git-flow options + <kbd>space</kbd>: checkout + <kbd>n</kbd>: new branch + <kbd>o</kbd>: create pull request + <kbd>O</kbd>: create pull request options + <kbd>ctrl+y</kbd>: copy pull request URL to clipboard + <kbd>c</kbd>: checkout by name + <kbd>F</kbd>: force checkout + <kbd>d</kbd>: delete branch + <kbd>r</kbd>: rebase checked-out branch onto this branch + <kbd>M</kbd>: merge into currently checked out branch + <kbd>f</kbd>: fast-forward this branch from its upstream + <kbd>g</kbd>: view reset options + <kbd>R</kbd>: rename branch + <kbd>u</kbd>: set/unset upstream + <kbd>enter</kbd>: view commits +</pre> + ## Main Panel (Merging) <pre> diff --git a/docs/keybindings/Keybindings_ja.md b/docs/keybindings/Keybindings_ja.md index 761d745d7..b3f11b93f 100644 --- a/docs/keybindings/Keybindings_ja.md +++ b/docs/keybindings/Keybindings_ja.md @@ -194,10 +194,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>R</kbd>: ブランチ名を変更 <kbd>u</kbd>: set/unset upstream <kbd>enter</kbd>: コミットを閲覧 - <kbd>f</kbd>: リモートをfetch - <kbd>n</kbd>: リモートを新規追加 - <kbd>d</kbd>: リモートを削除 - <kbd>e</kbd>: リモートを編集 </pre> ## メインパネル (Merging) @@ -259,6 +255,15 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>E</kbd>: edit hunk </pre> +## リモート + +<pre> + <kbd>f</kbd>: リモートをfetch + <kbd>n</kbd>: リモートを新規追加 + <kbd>d</kbd>: リモートを削除 + <kbd>e</kbd>: リモートを編集 +</pre> + ## リモートブランチ <pre> diff --git a/docs/keybindings/Keybindings_pl.md b/docs/keybindings/Keybindings_pl.md index b18d18730..99c97e594 100644 --- a/docs/keybindings/Keybindings_pl.md +++ b/docs/keybindings/Keybindings_pl.md @@ -41,28 +41,6 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>[</kbd>: previous tab </pre> -## Branches - -<pre> - <kbd>ctrl+o</kbd>: copy branch name to clipboard - <kbd>i</kbd>: show git-flow options - <kbd>space</kbd>: przełącz - <kbd>n</kbd>: nowa gałąź - <kbd>o</kbd>: utwórz żądanie pobrania - <kbd>O</kbd>: utwórz opcje żądania ściągnięcia - <kbd>ctrl+y</kbd>: skopiuj adres URL żądania pobrania do schowka - <kbd>c</kbd>: przełącz używając nazwy - <kbd>F</kbd>: wymuś przełączenie - <kbd>d</kbd>: usuń gałąź - <kbd>r</kbd>: zmiana bazy gałęzi - <kbd>M</kbd>: scal do obecnej gałęzi - <kbd>f</kbd>: fast-forward this branch from its upstream - <kbd>g</kbd>: wyświetl opcje resetu - <kbd>R</kbd>: rename branch - <kbd>u</kbd>: set/unset upstream - <kbd>enter</kbd>: view commits -</pre> - ## Commity <pre> @@ -96,6 +74,28 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct <kbd>enter</kbd>: przeglądaj pliki commita </pre> +## Local Branches + +<pre> + <kbd>ctrl+o</kbd>: copy branch name to clipboard + <kbd>i</kbd>: show git-flow options + <kbd>space</kbd>: przełącz + <kbd>n</kbd>: nowa gałąź + <kbd>o</kbd>: utwórz żądanie pobrania + <kbd>O</kbd>: utwórz opcje żądania ściągnięcia + <kbd>ctrl+y</kbd>: skopiuj adres URL żądania pobrania do schowka + <kbd>c</kbd>: przełącz używając nazwy + <kbd>F</kbd>: wymuś przełączenie + <kbd>d</kbd>: usuń gałąź + <kbd>r</kbd>: zmiana bazy gałęzi + <kbd>M</kbd>: scal do obecnej gałęzi + <kbd>f</kbd>: fast-forward this branch from its upstream + <kbd>g</kbd>: wyświetl opcje resetu + <kbd>R</kbd>: rename branch + <kbd>u</kbd>: set/unset upstream + <kbd>enter</kbd>: view commits +</pre> + ## Main Panel (Patch Building) <pre> diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go index 86580fb2e..a8593e9f3 100644 --- a/pkg/gui/branches_panel.go +++ b/pkg/gui/branches_panel.go @@ -13,7 +13,7 @@ func (gui *Gui) branchesRenderToMain() error { return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ - title: "Log", + title: gui.c.Tr.LogTitle, task: task, }, }) diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go index 00d472db2..6de5c97b0 100644 --- a/pkg/gui/context/context.go +++ b/pkg/gui/context/context.go @@ -4,6 +4,7 @@ import ( "sync" "github.com/jesseduffield/lazygit/pkg/gui/types" + "github.com/jesseduffield/lazygit/pkg/i18n" ) const ( @@ -144,39 +145,39 @@ type TabContext struct { Context types.Context } -func (tree ContextTree) InitialViewTabContextMap() map[string][]TabContext { +func (tree ContextTree) InitialViewTabContextMap(tr *i18n.TranslationSet) map[string][]TabContext { return map[string][]TabContext{ "branches": { { - Tab: "Local Branches", + Tab: tr.LocalBranchesTitle, Context: tree.Branches, }, { - Tab: "Remotes", + Tab: tr.RemotesTitle, Context: tree.Remotes, }, { - Tab: "Tags", + Tab: tr.TagsTitle, Context: tree.Tags, }, }, "commits": { { - Tab: "Commits", + Tab: tr.CommitsTitle, Context: tree.LocalCommits, }, { - Tab: "Reflog", + Tab: tr.ReflogCommitsTitle, Context: tree.ReflogCommits, }, }, "files": { { - Tab: "Files", + Tab: tr.FilesTitle, Context: tree.Files, }, { - Tab: "Submodules", + Tab: tr.SubmodulesTitle, Context: tree.Submodules, }, }, diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index a75ef897c..d1aaaee33 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -343,7 +343,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { Diffing: diffing.New(), }, ViewContextMap: viewContextMap, - ViewTabContextMap: contextTree.InitialViewTabContextMap(), + ViewTabContextMap: contextTree.InitialViewTabContextMap(gui.c.Tr), ScreenMode: screenMode, // TODO: put contexts in the context manager ContextManager: NewContextManager(initialContext), diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 20d2c37f2..59d2693f2 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -868,7 +868,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi } } - for viewName := range self.State.Contexts.InitialViewTabContextMap() { + for viewName := range self.State.Contexts.InitialViewTabContextMap(self.c.Tr) { bindings = append(bindings, []*types.Binding{ { ViewName: viewName, @@ -914,7 +914,7 @@ func (gui *Gui) resetKeybindings() error { } } - for viewName := range gui.State.Contexts.InitialViewTabContextMap() { + for viewName := range gui.State.Contexts.InitialViewTabContextMap(gui.c.Tr) { viewName := viewName tabClickCallback := func(tabIndex int) error { return gui.onViewTabClick(viewName, tabIndex) } diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go index 86f1bd6ab..dc2f9f17f 100644 --- a/pkg/gui/recent_repos_panel.go +++ b/pkg/gui/recent_repos_panel.go @@ -39,7 +39,7 @@ func (gui *Gui) handleShowAllBranchLogs() error { return gui.refreshMainViews(refreshMainOpts{ main: &viewUpdateOpts{ - title: "Log", + title: gui.c.Tr.LogTitle, task: task, }, }) diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index ee14b8193..d83433797 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -24,6 +24,7 @@ type TranslationSet struct { MergingTitle string MergeConfirmTitle string NormalTitle string + LogTitle string CommitMessage string CredentialsUsername string CredentialsPassword string @@ -645,6 +646,7 @@ func EnglishTranslationSet() TranslationSet { StagingTitle: "Main Panel (Staging)", MergingTitle: "Main Panel (Merging)", NormalTitle: "Main Panel (Normal)", + LogTitle: "Log", CommitMessage: "Commit message", CredentialsUsername: "Username", CredentialsPassword: "Password", @@ -806,7 +808,7 @@ func EnglishTranslationSet() TranslationSet { MergeOptionsTitle: "Merge Options", RebaseOptionsTitle: "Rebase Options", CommitMessageTitle: "Commit Message", - LocalBranchesTitle: "Branches", + LocalBranchesTitle: "Local Branches", SearchTitle: "Search", TagsTitle: "Tags", MenuTitle: "Menu", diff --git a/pkg/i18n/japanese.go b/pkg/i18n/japanese.go index a2b8eba0d..f65cca7a5 100644 --- a/pkg/i18n/japanese.go +++ b/pkg/i18n/japanese.go @@ -33,6 +33,7 @@ func japaneseTranslationSet() TranslationSet { StagingTitle: "メインパネル (Staging)", MergingTitle: "メインパネル (Merging)", NormalTitle: "メインパネル (Normal)", + LogTitle: "ログ", CommitMessage: "コミットメッセージ", CredentialsUsername: "ユーザ名", CredentialsPassword: "パスワード", @@ -192,7 +193,7 @@ func japaneseTranslationSet() TranslationSet { SearchTitle: "検索", TagsTitle: "タグ", MenuTitle: "メニュー", - RemotesTitle: "ブランチ", + RemotesTitle: "リモート", RemoteBranchesTitle: "リモートブランチ", PatchBuildingTitle: "メインパネル (Patch Building)", InformationTitle: "Information", @@ -247,9 +248,9 @@ func japaneseTranslationSet() TranslationSet { // CheckingOutStatus: "checking out", // CommittingStatus: "committing", CommitFiles: "Commit files", - SubCommitsDynamicTitle: "Commits (%s)", + SubCommitsDynamicTitle: "コミット (%s)", CommitFilesDynamicTitle: "Diff files (%s)", - RemoteBranchesDynamicTitle: "Remote branches (%s)", + RemoteBranchesDynamicTitle: "リモートブランチ (%s)", // LcViewItemFiles: "view selected item's files", CommitFilesTitle: "コミットファイル", // LcCheckoutCommitFile: "checkout file", @@ -460,7 +461,7 @@ func japaneseTranslationSet() TranslationSet { ShowingWhitespaceInDiffView: "空白文字の変更は差分画面に表示されます", // IncreaseContextInDiffView: "Increase the size of the context shown around changes in the diff view", // DecreaseContextInDiffView: "Decrease the size of the context shown around changes in the diff view", - CreatePullRequest: "pull requestを作成s", + CreatePullRequest: "pull requestを作成", // CreatePullRequestOptions: "Create pull request options", // LcCreatePullRequestOptions: "create pull request options", LcDefaultBranch: "デフォルトブランチ", From bfefef92a6d4d2d9d133b70f4bf452341e9995f0 Mon Sep 17 00:00:00 2001 From: Ryooooooga <eial5q265e5@gmail.com> Date: Wed, 18 May 2022 21:09:48 +0900 Subject: [PATCH 2/2] chore(i18n): move `InitialViewTabContextMap` to `gui` package --- pkg/gui/context/context.go | 40 ------------------------------------- pkg/gui/gui.go | 41 +++++++++++++++++++++++++++++++++++++- pkg/gui/keybindings.go | 4 ++-- 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/pkg/gui/context/context.go b/pkg/gui/context/context.go index 6de5c97b0..c2001b215 100644 --- a/pkg/gui/context/context.go +++ b/pkg/gui/context/context.go @@ -4,7 +4,6 @@ import ( "sync" "github.com/jesseduffield/lazygit/pkg/gui/types" - "github.com/jesseduffield/lazygit/pkg/i18n" ) const ( @@ -144,42 +143,3 @@ type TabContext struct { Tab string Context types.Context } - -func (tree ContextTree) InitialViewTabContextMap(tr *i18n.TranslationSet) map[string][]TabContext { - return map[string][]TabContext{ - "branches": { - { - Tab: tr.LocalBranchesTitle, - Context: tree.Branches, - }, - { - Tab: tr.RemotesTitle, - Context: tree.Remotes, - }, - { - Tab: tr.TagsTitle, - Context: tree.Tags, - }, - }, - "commits": { - { - Tab: tr.CommitsTitle, - Context: tree.LocalCommits, - }, - { - Tab: tr.ReflogCommitsTitle, - Context: tree.ReflogCommits, - }, - }, - "files": { - { - Tab: tr.FilesTitle, - Context: tree.Files, - }, - { - Tab: tr.SubmodulesTitle, - Context: tree.Submodules, - }, - }, - } -} diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index d1aaaee33..3f07fb986 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -343,7 +343,7 @@ func (gui *Gui) resetState(filterPath string, reuseState bool) { Diffing: diffing.New(), }, ViewContextMap: viewContextMap, - ViewTabContextMap: contextTree.InitialViewTabContextMap(gui.c.Tr), + ViewTabContextMap: gui.initialViewTabContextMap(contextTree), ScreenMode: screenMode, // TODO: put contexts in the context manager ContextManager: NewContextManager(initialContext), @@ -466,6 +466,45 @@ func (gui *Gui) initGocui() (*gocui.Gui, error) { return g, nil } +func (gui *Gui) initialViewTabContextMap(contextTree *context.ContextTree) map[string][]context.TabContext { + return map[string][]context.TabContext{ + "branches": { + { + Tab: gui.c.Tr.LocalBranchesTitle, + Context: contextTree.Branches, + }, + { + Tab: gui.c.Tr.RemotesTitle, + Context: contextTree.Remotes, + }, + { + Tab: gui.c.Tr.TagsTitle, + Context: contextTree.Tags, + }, + }, + "commits": { + { + Tab: gui.c.Tr.CommitsTitle, + Context: contextTree.LocalCommits, + }, + { + Tab: gui.c.Tr.ReflogCommitsTitle, + Context: contextTree.ReflogCommits, + }, + }, + "files": { + { + Tab: gui.c.Tr.FilesTitle, + Context: contextTree.Files, + }, + { + Tab: gui.c.Tr.SubmodulesTitle, + Context: contextTree.Submodules, + }, + }, + } +} + // Run: setup the gui with keybindings and start the mainloop func (gui *Gui) Run(filterPath string) error { g, err := gui.initGocui() diff --git a/pkg/gui/keybindings.go b/pkg/gui/keybindings.go index 59d2693f2..d7910d18b 100644 --- a/pkg/gui/keybindings.go +++ b/pkg/gui/keybindings.go @@ -868,7 +868,7 @@ func (self *Gui) GetInitialKeybindings() ([]*types.Binding, []*gocui.ViewMouseBi } } - for viewName := range self.State.Contexts.InitialViewTabContextMap(self.c.Tr) { + for viewName := range self.initialViewTabContextMap(self.State.Contexts) { bindings = append(bindings, []*types.Binding{ { ViewName: viewName, @@ -914,7 +914,7 @@ func (gui *Gui) resetKeybindings() error { } } - for viewName := range gui.State.Contexts.InitialViewTabContextMap(gui.c.Tr) { + for viewName := range gui.initialViewTabContextMap(gui.State.Contexts) { viewName := viewName tabClickCallback := func(tabIndex int) error { return gui.onViewTabClick(viewName, tabIndex) }