summaryrefslogtreecommitdiffstats
path: root/layout
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-06-20 16:47:48 -0500
committerSean E. Russell <ser@ser1.net>2020-06-20 16:47:48 -0500
commit23364aa754c836b8a5fbc69adbdbd49abd183a57 (patch)
tree51f9137e2bd2090ffdd938fd7c1a7b4b71c56402 /layout
parent9a56571373eb5a9ea9261afb39bebaf7ddeb700f (diff)
More strings moved to translations
Diffstat (limited to 'layout')
-rw-r--r--layout/layout.go6
-rw-r--r--layout/parser.go9
2 files changed, 11 insertions, 4 deletions
diff --git a/layout/layout.go b/layout/layout.go
index b4343b4..645e490 100644
--- a/layout/layout.go
+++ b/layout/layout.go
@@ -3,7 +3,9 @@ package layout
import (
"log"
"sort"
+ "strings"
+ "github.com/jdkeke142/lingo-toml"
"github.com/xxxserxxx/gotop/v4"
"github.com/xxxserxxx/gotop/v4/widgets"
@@ -28,8 +30,10 @@ type MyGrid struct {
}
var widgetNames []string = []string{"cpu", "disk", "mem", "temp", "net", "procs", "batt"}
+var tr lingo.Translations
func Layout(wl layout, c gotop.Config) (*MyGrid, error) {
+ tr = c.Tr
rowDefs := wl.Rows
uiRows := make([][]interface{}, 0)
numRows := countNumRows(wl.Rows)
@@ -197,7 +201,7 @@ func makeWidget(c gotop.Config, widRule widgetRule) interface{} {
b.BarColor = ui.Color(c.Colorscheme.ProcCursor)
w = b
default:
- log.Printf("Invalid widget name %s. Must be one of %v", widRule.Widget, widgetNames)
+ log.Printf(tr.Value("layout.error.widget", widRule.Widget, strings.Join(widgetNames, ",")))
return ui.NewBlock()
}
if c.ExportPort != "" {
diff --git a/layout/parser.go b/layout/parser.go
index b747eae..b922067 100644
--- a/layout/parser.go
+++ b/layout/parser.go
@@ -83,7 +83,8 @@ func ParseLayout(i io.Reader) layout {
if len(rs) > 1 {
v, e := strconv.Atoi(rs[0])
if e != nil {
- log.Printf("Layout error on line %d: format must be INT:STRING/INT. Error parsing %s as a int. Word was %s. Using a row height of 1.", lineNo, rs[0], w)
+ ln := strconv.Itoa(lineNo)
+ log.Printf(tr.Value("layout.error.format", "INT:STRING/INT", ln, rs[0], w))
v = 1
}
if v < 1 {
@@ -99,7 +100,8 @@ func ParseLayout(i io.Reader) layout {
if len(ks) > 1 {
weight, e := strconv.Atoi(ks[1])
if e != nil {
- log.Printf("Layout error on line %d: format must be STRING/INT. Error parsing %s as a int. Word was %s. Using a weight of 1 for widget.", lineNo, ks[1], w)
+ ln := strconv.Itoa(lineNo)
+ log.Printf(tr.Value("layout.error.format", "STRING/INT", ln, ks[1], w))
weight = 1
}
if weight < 1 {
@@ -107,7 +109,8 @@ func ParseLayout(i io.Reader) layout {
}
wr.Weight = float64(weight)
if len(ks) > 2 {
- log.Printf("Layout warning on line %d: too many '/' in word %s; ignoring extra junk.", lineNo, w)
+ ln := strconv.Itoa(lineNo)
+ log.Printf(tr.Value("layout.error.slashes", ln, w))
}
weightTotal += weight
} else {