summaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2020-10-04 11:00:48 +1100
committerJesse Duffield <jessedduffield@gmail.com>2020-10-10 00:23:01 +1100
commit37bb89dac33cb4236bf817e1e2e09cb1cbfade5c (patch)
treeea06fa4595a7f2d7eff80c2602648b18450f5988 /pkg
parent7d9aa97f9691dd0a8658c4b6626877a198c5d03c (diff)
type i18n
Diffstat (limited to 'pkg')
-rw-r--r--pkg/app/app.go12
-rw-r--r--pkg/commands/dummies.go2
-rw-r--r--pkg/commands/git.go10
-rw-r--r--pkg/commands/git_test.go14
-rw-r--r--pkg/commands/loading_commits.go6
-rw-r--r--pkg/commands/loading_commits_test.go2
-rw-r--r--pkg/commands/patch_rebases.go4
-rw-r--r--pkg/commands/pull_request.go4
-rw-r--r--pkg/commands/rebasing.go8
-rw-r--r--pkg/gui/branches_panel.go83
-rw-r--r--pkg/gui/cherry_picking.go6
-rw-r--r--pkg/gui/commit_files_panel.go14
-rw-r--r--pkg/gui/commit_message_panel.go10
-rw-r--r--pkg/gui/commits_panel.go85
-rw-r--r--pkg/gui/confirmation_panel.go9
-rw-r--r--pkg/gui/credentials_panel.go14
-rw-r--r--pkg/gui/custom_commands.go2
-rw-r--r--pkg/gui/diffing.go12
-rw-r--r--pkg/gui/discard_changes_menu_panel.go6
-rw-r--r--pkg/gui/files_panel.go60
-rw-r--r--pkg/gui/filtering.go4
-rw-r--r--pkg/gui/filtering_menu_panel.go10
-rw-r--r--pkg/gui/git_flow.go5
-rw-r--r--pkg/gui/global_handlers.go6
-rw-r--r--pkg/gui/gui.go19
-rw-r--r--pkg/gui/keybindings.go322
-rw-r--r--pkg/gui/layout.go24
-rw-r--r--pkg/gui/list_context.go10
-rw-r--r--pkg/gui/menu_panel.go8
-rw-r--r--pkg/gui/merge_panel.go18
-rw-r--r--pkg/gui/modes.go8
-rw-r--r--pkg/gui/options_menu_panel.go2
-rw-r--r--pkg/gui/patch_options_panel.go18
-rw-r--r--pkg/gui/quitting.go2
-rw-r--r--pkg/gui/rebase_options_panel.go10
-rw-r--r--pkg/gui/recent_repos_panel.go2
-rw-r--r--pkg/gui/reflog_panel.go4
-rw-r--r--pkg/gui/remote_branches_panel.go15
-rw-r--r--pkg/gui/remotes_panel.go22
-rw-r--r--pkg/gui/reset_menu_panel.go2
-rw-r--r--pkg/gui/staging_panel.go12
-rw-r--r--pkg/gui/stash_panel.go26
-rw-r--r--pkg/gui/status_panel.go2
-rw-r--r--pkg/gui/sub_commits_panel.go4
-rw-r--r--pkg/gui/submodules_panel.go44
-rw-r--r--pkg/gui/tags_panel.go17
-rw-r--r--pkg/gui/undoing.go14
-rw-r--r--pkg/gui/view_helpers.go12
-rw-r--r--pkg/gui/workspace_reset_options_panel.go12
-rw-r--r--pkg/i18n/dutch.go1543
-rw-r--r--pkg/i18n/english.go2105
-rw-r--r--pkg/i18n/i18n.go102
-rw-r--r--pkg/i18n/i18n_test.go48
-rw-r--r--pkg/i18n/polish.go1013
-rw-r--r--pkg/updates/updates.go18
-rw-r--r--pkg/utils/utils.go3
56 files changed, 2006 insertions, 3843 deletions
diff --git a/pkg/app/app.go b/pkg/app/app.go
index fd8950ae7..9d3f53cc0 100644
--- a/pkg/app/app.go
+++ b/pkg/app/app.go
@@ -34,7 +34,7 @@ type App struct {
OSCommand *oscommands.OSCommand
GitCommand *commands.GitCommand
Gui *gui.Gui
- Tr *i18n.Localizer
+ Tr *i18n.TranslationSet
Updater *updates.Updater // may only need this on the Gui
ClientContext string
}
@@ -103,7 +103,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
}
var err error
app.Log = newLogger(config)
- app.Tr = i18n.NewLocalizer(app.Log)
+ app.Tr = i18n.NewTranslationSet(app.Log)
// if we are being called in 'demon' mode, we can just return here
app.ClientContext = os.Getenv("LAZYGIT_CLIENT_COMMAND")
@@ -138,7 +138,7 @@ func NewApp(config config.AppConfigurer, filterPath string) (*App, error) {
func (app *App) validateGitVersion() error {
output, err := app.OSCommand.RunCommandWithOutput("git --version")
// if we get an error anywhere here we'll show the same status
- minVersionError := errors.New(app.Tr.SLocalize("minGitVersionError"))
+ minVersionError := errors.New(app.Tr.MinGitVersionError)
if err != nil {
return minVersionError
}
@@ -193,7 +193,7 @@ func (app *App) setupRepo() (bool, error) {
}
// Offer to initialize a new repository in current directory.
- fmt.Print(app.Tr.SLocalize("CreateRepo"))
+ fmt.Print(app.Tr.CreateRepo)
response, _ := bufio.NewReader(os.Stdin).ReadString('\n')
if strings.Trim(response, " \n") != "y" {
// check if we have a recent repo we can open
@@ -275,7 +275,7 @@ func (app *App) Close() error {
func (app *App) KnownError(err error) (string, bool) {
errorMessage := err.Error()
- knownErrorMessages := []string{app.Tr.SLocalize("minGitVersionError")}
+ knownErrorMessages := []string{app.Tr.MinGitVersionError}
for _, message := range knownErrorMessages {
if errorMessage == message {
@@ -286,7 +286,7 @@ func (app *App) KnownError(err error) (string, bool) {
mappings := []errorMapping{
{
originalError: "fatal: not a git repository",
- newError: app.Tr.SLocalize("notARepository"),
+ newError: app.Tr.NotARepository,
},
}
diff --git a/pkg/commands/dummies.go b/pkg/commands/dummies.go
index da03d2f08..b7ec98501 100644
--- a/pkg/commands/dummies.go
+++ b/pkg/commands/dummies.go
@@ -17,7 +17,7 @@ func NewDummyGitCommandWithOSCommand(osCommand *oscommands.OSCommand) *GitComman
return &GitCommand{
Log: utils.NewDummyLog(),
OSCommand: osCommand,
- Tr: i18n.NewLocalizer(utils.NewDummyLog()),
+ Tr: i18n.NewTranslationSet(utils.NewDummyLog()),
Config: config.NewDummyAppConfig(),
getGlobalGitConfig: func(string) (string, error) { return "", nil },
getLocalGitConfig: func(string) (string, error) { return "", nil },
diff --git a/pkg/commands/git.go b/pkg/commands/git.go
index af1533886..63b0e6859 100644
--- a/pkg/commands/git.go
+++ b/pkg/commands/git.go
@@ -30,7 +30,7 @@ type GitCommand struct {
Log *logrus.Entry
OSCommand *oscommands.OSCommand
Repo *gogit.Repository
- Tr *i18n.Localizer
+ Tr *i18n.TranslationSet
Config config.AppConfigurer
getGlobalGitConfig func(string) (string, error)
getLocalGitConfig func(string) (string, error)
@@ -44,7 +44,7 @@ type GitCommand struct {
}
// NewGitCommand it runs git commands
-func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n.Localizer, config config.AppConfigurer) (*GitCommand, error) {
+func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet, config config.AppConfigurer) (*GitCommand, error) {
var repo *gogit.Repository
// see what our default push behaviour is
@@ -64,7 +64,7 @@ func NewGitCommand(log *logrus.Entry, osCommand *oscommands.OSCommand, tr *i18n.
return nil, err
}
- if repo, err = setupRepository(gogit.PlainOpen, tr.SLocalize); err != nil {
+ if repo, err = setupRepository(gogit.PlainOpen, tr.GitconfigParseErr); err != nil {
return nil, err
}
@@ -140,7 +140,7 @@ func resolvePath(path string) (string, error) {
return filepath.EvalSymlinks(path)
}
-func setupRepository(openGitRepository func(string) (*gogit.Repository, error), sLocalize func(string) string) (*gogit.Repository, error) {
+func setupRepository(openGitRepository func(string) (*gogit.Repository, error), gitConfigParseErrorStr string) (*gogit.Repository, error) {
unresolvedPath := env.GetGitDirEnv()
if unresolvedPath == "" {
var err error
@@ -159,7 +159,7 @@ func setupRepository(openGitRepository func(string) (*gogit.Repository, error),
if err != nil {
if strings.Contains(err.Error(), `unquoted '\' must be followed by new line`) {
- return nil, errors.New(sLocalize("GitconfigParseErr"))
+ return nil, errors.New(gitConfigParseErrorStr)
}
return nil, err
diff --git a/pkg/commands/git_test.go b/pkg/commands/git_test.go
index e04903e39..ebac76e01 100644
--- a/pkg/commands/git_test.go
+++ b/pkg/commands/git_test.go
@@ -159,7 +159,7 @@ func TestSetupRepository(t *testing.T) {
type scenario struct {
testName string
openGitRepository func(string) (*gogit.Repository, error)
- sLocalize func(string) string
+ errorStr string
test func(*gogit.Repository, error)
}
@@ -169,9 +169,7 @@ func TestSetupRepository(t *testing.T) {
func(string) (*gogit.Repository, error) {
return nil, fmt.Errorf(`unquoted '\' must be followed by new line`)
},
- func(string) string {
- return "error translated"
- },
+ "error translated",
func(r *gogit.Repository, err error) {
assert.Error(t, err)
assert.EqualError(t, err, "error translated")
@@ -182,7 +180,7 @@ func TestSetupRepository(t *testing.T) {
func(string) (*gogit.Repository, error) {
return nil, fmt.Errorf("Error from inside gogit")
},
- func(string) string { return "" },
+ "",
func(r *gogit.Repository, err error) {
assert.Error(t, err)
assert.EqualError(t, err, "Error from inside gogit")
@@ -196,7 +194,7 @@ func TestSetupRepository(t *testing.T) {
assert.NoError(t, err)
return r, nil
},
- func(string) string { return "" },
+ "",
func(r *gogit.Repository, err error) {
assert.NoError(t, err)
assert.NotNil(t, r)
@@ -206,7 +204,7 @@ func TestSetupRepository(t *testing.T) {
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
- s.test(setupRepository(s.openGitRepository, s.sLocalize))
+ s.test(setupRepository(s.openGitRepository, s.errorStr))
})
}
}
@@ -254,7 +252,7 @@ func TestNewGitCommand(t *testing.T) {
for _, s := range scenarios {
t.Run(s.testName, func(t *testing.T) {
s.setup()
- s.test(NewGitCommand(utils.NewDummyLog(), oscommands.NewDummyOSCommand(), i18n.NewLocalizer(utils.NewDummyLog()), config.NewDummyAppConfig()))
+ s.test(NewGitCommand(utils.NewDummyLog(), oscommands.NewDummyOSCommand(), i18n.NewTranslationSet(utils.NewDummyLog()), config.NewDummyAppConfig()))
})
}
}
diff --git a/pkg/commands/loading_commits.go b/pkg/commands/loading_commits.go
index 72946aeb6..33954b23e 100644
--- a/pkg/commands/loading_commits.go
+++ b/pkg/commands/loading_commits.go
@@ -33,11 +33,11 @@ type CommitListBuilder struct {
Log *logrus.Entry
GitCommand *GitCommand
OSCommand *oscommands.OSCommand
- Tr *i18n.Localizer
+ Tr *i18n.TranslationSet
}
// NewCommitListBuilder builds a new commit list builder
-func NewCommitListBuilder(log *logrus.Entry, gitCommand *GitCommand, osCommand *oscommands.OSCommand, tr *i18n.Localizer) *CommitListBuilder {
+func NewCommitListBuilder(log *logrus.Entry, gitCommand *GitCommand, osCommand *oscommands.OSCommand, tr *i18n.TranslationSet) *CommitListBuilder {
return &CommitListBuilder{
Log: log,
GitCommand: gitCommand,
@@ -170,7 +170,7 @@ func (c *CommitListBuilder) GetCommits(opts GetCommitsOptions) ([]*models.Commit
if rebaseMode != "" {
currentCommit := commits[len(rebasingCommits)]
blue := color.New(color.FgYellow)
- youAreHere := blue.Sprintf("<-- %s ---", c.Tr.SLocalize("YouAreHere"))
+ youAreHere := blue.Sprintf("<-- %s ---", c.Tr.YouAreHere)
currentCommit.Name = fmt.Sprintf("%s %s", youAreHere, currentCommit.Name)
}
diff --git a/pkg/commands/loading_commits_test.go b/pkg/commands/loading_commits_test.go
index beda2c574..c6c77f259 100644
--- a/pkg/commands/loading_commits_test.go
+++ b/pkg/commands/loading_commits_test.go
@@ -18,7 +18,7 @@ func NewDummyCommitListBuilder() *CommitListBuilder {
Log: utils.NewDummyLog(),
GitCommand: NewDummyGitCommandWithOSCommand(osCommand),
OSCommand: osCommand,
- Tr: i18n.NewLocalizer(utils.NewDummyLog()),
+ Tr: i18n.NewTranslationSet(utils.NewDummyLog()),
}
}
diff --git a/pkg/commands/patch_rebases.go b/pkg/commands/patch_rebases.go
index c51a24ed7..42e03f1e9 100644
--- a/pkg/commands/patch_rebases.go
+++ b/pkg/commands/patch_rebases.go
@@ -72,7 +72,7 @@ func (c *GitCommand) MovePatchToSelectedCommit(commits []*models.Commit, sourceC
// one where we handle the possibility of a credential request, and the other
// where we continue the rebase
if c.usingGpg() {
- return errors.New(c.Tr.SLocalize("DisabledForGPG"))
+ return errors.New(c.Tr.DisabledForGPG)
}
baseIndex := sourceCommitIdx + 1
@@ -139,7 +139,7 @@ func (c *GitCommand) MovePatchToSelectedCommit(commits []*models.Commit, sourceC
func (c *GitCommand) PullPatchIntoIndex(commits []*models.Commit, commitIdx int, p *patch.PatchManager, stash bool) error {
if stash {
- if err := c.StashSave(c.Tr.SLocalize("StashPrefix") + commits[commitIdx].Sha); err != nil {
+ if err := c.StashSave(c.Tr.StashPrefix + commits[commitIdx].Sha); err != nil {
return err
}
}
diff --git a/pkg/commands/pull_request.go b/pkg/commands/pull_request.go
index acceced52..3a820dbfd 100644
--- a/pkg/commands/pull_request.go
+++ b/pkg/commands/pull_request.go
@@ -94,7 +94,7 @@ func (pr *PullRequest) Create(branch *models.Branch) error {
branchExistsOnRemote := pr.GitCommand.CheckRemoteBranchExists(branch)
if !branchExistsOnRemote {
- return errors.New(pr.GitCommand.Tr.SLocalize("NoBranchOnRemote"))
+ return errors.New(pr.GitCommand.Tr.NoBranchOnRemote)
}
repoURL := pr.GitCommand.GetRemoteURL()
@@ -108,7 +108,7 @@ func (pr *PullRequest) Create(branch *models.Branch) error {
}
if gitService == nil {
- return errors.New(pr.GitCommand.Tr.SLocalize("UnsupportedGitService"))
+ return errors.New(pr.GitCommand.Tr.UnsupportedGitService)
}
repoInfo := getRepoInfoFromURL(repoURL)
diff --git a/pkg/commands/rebasing.go b/pkg/commands/rebasing.go
index df1f43607..e7c28bd8d 100644
--- a/pkg/commands/rebasing.go
+++ b/pkg/commands/rebasing.go
@@ -26,7 +26,7 @@ func (c *GitCommand) MoveCommitDown(commits []*models.Commit, index int) error {
// we must ensure that we have at least two commits after the selected one
if len(commits) <= index+2 {
// assuming they aren't picking the bottom commit
- return errors.New(c.Tr.SLocalize("NoRoom"))
+ return errors.New(c.Tr.NoRoom)
}
todo := ""
@@ -101,14 +101,14 @@ func (c *GitCommand) GenerateGenericRebaseTodo(commits []*models.Commit, actionI
baseIndex := actionIndex + 1
if len(commits) <= baseIndex {
- return "", "", errors.New(c.Tr.SLocalize("CannotRebaseOntoFirstCommit"))
+ return "", "", errors.New(c.Tr.CannotRebaseOntoFirstCommit)
}
if action == "squash" || action == "fixup" {
baseIndex++
if len(commits) <= baseIndex {
- return "", "", errors.New(c.Tr.SLocalize("CannotSquashOntoSecondCommit"))
+ return "", "", errors.New(c.Tr.CannotSquashOntoSecondCommit)
}
}
@@ -212,7 +212,7 @@ func (c *GitCommand) BeginInteractiveRebaseForCommit(commits []*models.Commit, c
// one where we handle the possibility of a credential request, and the other
// where we continue the rebase
if c.usingGpg() {
- return errors.New(c.Tr.SLocalize("DisabledForGPG"))
+ return errors.New(c.Tr.DisabledForGPG)
}
todo, sha, err := c.GenerateGenericRebaseTodo(commits, commitIndex, "edit")
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 8bc6fd93c..c8b63e0d5 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -7,6 +7,7 @@ import (
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands"
"github.com/jesseduffield/lazygit/pkg/commands/models"
+ "github.com/jesseduffield/lazygit/pkg/utils"
)
// list panel functions
@@ -28,7 +29,7 @@ func (gui *Gui) handleBranchSelect() error {
var task updateTask
branch := gui.getSelectedBranch()
if branch == nil {
- task = gui.createRenderStringTask(gui.Tr.SLocalize("NoBranchesThisRepo"))
+ task = gui.createRenderStringTask(gui.Tr.NoBranchesThisRepo)
} else {
cmd := gui.OSCommand.ExecutableFromString(
gui.GitCommand.GetBranchGraphCmdStr(branch.Name),
@@ -81,7 +82,7 @@ func (gui *Gui) handleBranchPress(g *gocui.Gui, v *gocui.View) error {
return nil
}
if gui.State.Panels.Branches.SelectedLineIdx == 0 {
- return gui.createErrorPanel(gui.Tr.SLocalize("AlreadyCheckedOutBranch"))
+ return gui.createErrorPanel(gui.Tr.AlreadyCheckedOutBranch)
}
branch := gui.getSelectedBranch()
return gui.handleCheckoutRef(branch.Name, handleCheckoutRefOptions{})
@@ -99,7 +100,7 @@ func (gui *Gui) handleCreatePullRequestPress(g *gocui.Gui, v *gocui.View) error
}
func (gui *Gui) handleGitFetch(g *gocui.Gui, v *gocui.View) error {
- if err := gui.createLoaderPanel(v, gui.Tr.SLocalize("FetchWait")); err != nil {
+ if err := gui.createLoaderPanel(v, gui.Tr.FetchWait); err != nil {
return err
}
go func() {
@@ -112,8 +113,8 @@ func (gui *Gui) handleGitFetch(g *gocui.Gui, v *gocui.View) error {
func (gui *Gui) handleForceCheckout(g *gocui.Gui, v *gocui.View) error {
branch := gui.getSelectedBranch()
- message := gui.Tr.SLocalize("SureForceCheckout")
- title := gui.Tr.SLocalize("ForceCheckoutBranch")
+ message := gui.Tr.SureForceCheckout
+ title := gui.Tr.ForceCheckoutBranch
return gui.ask(askOpts{
title: title,
@@ -136,7 +137,7 @@ type handleCheckoutRefOptions struct {
func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions) error {
waitingStatus := options.WaitingStatus
if waitingStatus == "" {
- waitingStatus = gui.Tr.SLocalize("CheckingOutStatus")
+ waitingStatus = gui.Tr.CheckingOutStatus
}
cmdOptions := commands.CheckoutOptions{Force: false, EnvVars: options.EnvVars}
@@ -160,10 +161,10 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
// offer to autostash changes
return gui.ask(askOpts{
- title: gui.Tr.SLocalize("AutoStashTitle"),
- prompt: gui.Tr.SLocalize("AutoStashPrompt"),
+ title: gui.Tr.AutoStashTitle,
+ prompt: gui.Tr.AutoStashPrompt,
handleConfirm: func() error {
- if err := gui.GitCommand.StashSave(gui.Tr.SLocalize("StashPrefix") + ref); err != nil {
+ if err := gui.GitCommand.StashSave(gui.Tr.StashPrefix + ref); err != nil {
return gui.surfaceError(err)
}
if err := gui.GitCommand.Checkout(ref, cmdOptions); err != nil {
@@ -193,14 +194,14 @@ func (gui *Gui) handleCheckoutRef(ref string, options handleCheckoutRefOptions)
}
func (gui *Gui) handleCheckoutByName(g *gocui.Gui, v *gocui.View) error {
- return gui.prompt(gui.Tr.SLocalize("BranchName")+":", "", func(response string) error {
+ return gui.prompt(gui.Tr.BranchName+":", "", func(response string) error {
return gui.handleCheckoutRef(response, handleCheckoutRefOptions{
onRefNotFound: func(ref string) error {
return gui.ask(askOpts{
- title: gui.Tr.SLocalize("BranchNotFoundTitle"),
- prompt: fmt.Sprintf("%s %s%s", gui.Tr.SLocalize("BranchNotFoundPrompt"), ref, "?"),
+ title: gui.Tr.BranchNotFoundTitle,
+ prompt: fmt.Sprintf("%s %s%s", gui.Tr.BranchNotFoundPrompt, ref, "?"),
handleConfirm: func() error {
return gui.createNewBranchWithName(ref)
},
@@ -243,22 +244,22 @@ func (gui *Gui) deleteBranch(force bool) error {
}
checkedOutBranch := gui.getCheckedOutBranch()
if checkedOutBranch.Name == selectedBranch.Name {
- return gui.createErrorPanel(gui.Tr.SLocalize("CantDeleteCheckOutBranch"))
+ return gui.createErrorPanel(gui.Tr.CantDeleteCheckOutBranch)
}
return gui.deleteNamedBranch(selectedBranch, force)
}
func (gui *Gui) deleteNamedBranch(selectedBranch *models.Branch, force bool) error {
- title := gui.Tr.SLocalize("DeleteBranch")
- var messageID string
+ title := gui.Tr.DeleteBranch
+ var templateStr string
if force {
- messageID = "ForceDeleteBranchMessage"
+ templateStr = gui.Tr.ForceDeleteBranchMessage
} else {
- messageID = "DeleteBranchMessage"
+ templateStr = gui.Tr.DeleteBranchMessage
}
- message := gui.Tr.TemplateLocalize(
- messageID,
- Teml{
+ message := utils.ResolvePlaceholderString(
+ templateStr,
+ map[string]string{
"selectedBranchName": selectedBranch.Name,
},
)
@@ -290,11 +291,11 @@ func (gui *Gui) mergeBranchIntoCheckedOutBranch(branchName string) error {
}
checkedOutBranchName := gui.getCheckedOutBranch().Name
if checkedOutBranchName == branchName {
- return gui.createErrorPanel(gui.Tr.SLocalize("CantMergeBranchIntoItself"))