Skip to content

Commit

Permalink
config: make strings translatable
Browse files Browse the repository at this point in the history
Turn several multiline strings into single-line strings for better
translatability.
  • Loading branch information
bk2204 committed Jan 18, 2022
1 parent 9daf439 commit 835c438
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/git-lfs/git-lfs/v3/fs"
"github.com/git-lfs/git-lfs/v3/git"
"github.com/git-lfs/git-lfs/v3/tools"
"github.com/git-lfs/git-lfs/v3/tr"
"github.com/rubyist/tracerx"
)

Expand Down Expand Up @@ -79,7 +80,7 @@ func NewIn(workdir, gitdir string) *Configuration {
callback: func() Environment {
sources, err := gitConf.Sources(c.LocalWorkingDir(), ".lfsconfig")
if err != nil {
fmt.Fprintf(os.Stderr, "Error reading git config: %s\n", err)
fmt.Fprintf(os.Stderr, tr.Tr.Get("Error reading git config: %s\n", err))
}
return c.readGitConfig(sources...)
},
Expand Down
6 changes: 4 additions & 2 deletions config/extension.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package config

import (
"fmt"
"errors"
"sort"

"github.com/git-lfs/git-lfs/v3/tr"
)

// An Extension describes how to manipulate files during smudge and clean.
Expand All @@ -21,7 +23,7 @@ func SortExtensions(m map[string]Extension) ([]Extension, error) {
for n, ext := range m {
p := ext.Priority
if _, exist := pMap[p]; exist {
err := fmt.Errorf("duplicate priority %d on %s", p, n)
err := errors.New(tr.Tr.Get("duplicate priority %d on %s", p, n))
return nil, err
}
pMap[p] = ext
Expand Down
5 changes: 3 additions & 2 deletions config/git_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"sync"

"github.com/git-lfs/git-lfs/v3/git"
"github.com/git-lfs/git-lfs/v3/tr"
)

type GitFetcher struct {
Expand Down Expand Up @@ -39,7 +40,7 @@ func readGitConfig(configs ...*git.ConfigurationSource) (gf *GitFetcher, extensi

if origKey, ok := uniqKeys[key]; ok {
if ShowConfigWarnings && len(vals[key]) > 0 && vals[key][len(vals[key])-1] != val && strings.HasPrefix(key, gitConfigWarningPrefix) {
fmt.Fprintf(os.Stderr, "WARNING: These git config values clash:\n")
fmt.Fprint(os.Stderr, tr.Tr.Get("warning: These git config values clash:\n"))
fmt.Fprintf(os.Stderr, " git config %q = %q\n", origKey, vals[key])
fmt.Fprintf(os.Stderr, " git config %q = %q\n", pieces[0], val)
}
Expand Down Expand Up @@ -101,7 +102,7 @@ func readGitConfig(configs ...*git.ConfigurationSource) (gf *GitFetcher, extensi
}

if len(ignored) > 0 {
fmt.Fprintf(os.Stderr, "WARNING: These unsafe lfsconfig keys were ignored:\n\n")
fmt.Fprintf(os.Stderr, tr.Tr.Get("warning: These unsafe lfsconfig keys were ignored:\n\n"))
for _, key := range ignored {
fmt.Fprintf(os.Stderr, " %s\n", key)
}
Expand Down
2 changes: 1 addition & 1 deletion t/t-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ begin_test "config: ignoring unsafe lfsconfig keys"

git lfs env 2>&1 | tee status.log

grep "WARNING: These unsafe lfsconfig keys were ignored:" status.log
grep "warning: These unsafe lfsconfig keys were ignored:" status.log
grep " core.askpass" status.log
)
end_test
Expand Down

0 comments on commit 835c438

Please sign in to comment.