Translation files are now bundled.
This commit is contained in:
parent
de187a89ae
commit
aa828c5790
|
@ -69,6 +69,10 @@ Move `gotop` to somewhere in your `$PATH`.
|
|||
|
||||
If Go is not installed or is the wrong version, and you don't have root access or don't want to upgrade Go, a script is provided to download Go and the gotop sources, compile gotop, and then clean up. See `scripts/install_without_root.sh`.
|
||||
|
||||
#### go generate
|
||||
|
||||
Apple SMC tags are embedded in a text file that is compiled into the executable; the same happens with the language translations. When the file `devices/data/sm.tsv` or any translations in `translations/dicts/` change, `go generate` should be re-run.
|
||||
|
||||
## Usage
|
||||
|
||||
Run with `-h` to get an extensive list of command line arguments. Many of these can be configured by creating a configuration file; see the next section for more information. Key bindings can be viewed while gotop is running by pressing the `?` key, or they can be printed out by using the `--list keys` command.
|
||||
|
|
|
@ -30,6 +30,7 @@ import (
|
|||
"github.com/xxxserxxx/gotop/v4/devices"
|
||||
"github.com/xxxserxxx/gotop/v4/layout"
|
||||
"github.com/xxxserxxx/gotop/v4/logging"
|
||||
"github.com/xxxserxxx/gotop/v4/translations"
|
||||
w "github.com/xxxserxxx/gotop/v4/widgets"
|
||||
)
|
||||
|
||||
|
@ -354,7 +355,7 @@ func main() {
|
|||
}
|
||||
|
||||
func run() int {
|
||||
ling, err := lingo.New("en_US", "translations", nil)
|
||||
ling, err := lingo.New("en_US", "translations", translations.AssetFile())
|
||||
if err != nil {
|
||||
fmt.Printf("failed to load language files: %s\n", err)
|
||||
return 2
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package gotop
|
||||
|
||||
//go:generate go-bindata -fs -pkg translations -prefix translations -o translations/dicts.go translations/dicts
|
||||
//go:generate go-bindata -pkg devices -prefix devices/data -o devices/smc.go devices/data
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
// Code generated by go-bindata.
|
||||
// sources:
|
||||
// data/smc.tsv
|
||||
// DO NOT EDIT!
|
||||
// Code generated by go-bindata. (@generated) DO NOT EDIT.
|
||||
|
||||
//Package devices generated by go-bindata.// sources:
|
||||
// devices/data/smc.tsv
|
||||
package devices
|
||||
|
||||
import (
|
||||
|
@ -20,7 +19,7 @@ import (
|
|||
func bindataRead(data []byte, name string) ([]byte, error) {
|
||||
gz, err := gzip.NewReader(bytes.NewBuffer(data))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Read %q: %v", name, err)
|
||||
return nil, fmt.Errorf("read %q: %v", name, err)
|
||||
}
|
||||
|
||||
var buf bytes.Buffer
|
||||
|
@ -28,7 +27,7 @@ func bindataRead(data []byte, name string) ([]byte, error) {
|
|||
clErr := gz.Close()
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Read %q: %v", name, err)
|
||||
return nil, fmt.Errorf("read %q: %v", name, err)
|
||||
}
|
||||
if clErr != nil {
|
||||
return nil, err
|
||||
|
@ -49,21 +48,32 @@ type bindataFileInfo struct {
|
|||
modTime time.Time
|
||||
}
|
||||
|
||||
// Name return file name
|
||||
func (fi bindataFileInfo) Name() string {
|
||||
return fi.name
|
||||
}
|
||||
|
||||
// Size return file size
|
||||
func (fi bindataFileInfo) Size() int64 {
|
||||
return fi.size
|
||||
}
|
||||
|
||||
// Mode return file mode
|
||||
func (fi bindataFileInfo) Mode() os.FileMode {
|
||||
return fi.mode
|
||||
}
|
||||
|
||||
// ModTime return file modify time
|
||||
func (fi bindataFileInfo) ModTime() time.Time {
|
||||
return fi.modTime
|
||||
}
|
||||
|
||||
// IsDir return file whether a directory
|
||||
func (fi bindataFileInfo) IsDir() bool {
|
||||
return false
|
||||
return fi.mode&os.ModeDir != 0
|
||||
}
|
||||
|
||||
// Sys return file is sys mode
|
||||
func (fi bindataFileInfo) Sys() interface{} {
|
||||
return nil
|
||||
}
|
||||
|
@ -83,7 +93,7 @@ func smcTsv() (*asset, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "smc.tsv", size: 3398, mode: os.FileMode(420), modTime: time.Unix(1591711965, 0)}
|
||||
info := bindataFileInfo{name: "smc.tsv", size: 3398, mode: os.FileMode(420), modTime: time.Unix(1592515411, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
@ -182,6 +192,7 @@ type bintree struct {
|
|||
Func func() (*asset, error)
|
||||
Children map[string]*bintree
|
||||
}
|
||||
|
||||
var _bintree = &bintree{nil, map[string]*bintree{
|
||||
"smc.tsv": &bintree{smcTsv, map[string]*bintree{}},
|
||||
}}
|
||||
|
@ -232,4 +243,3 @@ func _filePath(dir, name string) string {
|
|||
cannonicalName := strings.Replace(name, "\\", "/", -1)
|
||||
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package devices
|
||||
|
||||
//go:generate go-bindata -pkg devices -prefix data -o smc.go data
|
||||
|
||||
import (
|
||||
"log"
|
||||
)
|
||||
|
|
2
go.mod
2
go.mod
|
@ -12,7 +12,7 @@ require (
|
|||
github.com/shibukawa/configdir v0.0.0-20170330084843-e180dbdc8da0
|
||||
github.com/shirou/gopsutil v2.20.3+incompatible
|
||||
github.com/stretchr/testify v1.4.0
|
||||
github.com/xxxserxxx/lingo v1.0.1
|
||||
github.com/xxxserxxx/lingo v1.1.0
|
||||
github.com/xxxserxxx/opflag v1.0.5
|
||||
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0
|
||||
howett.net/plist v0.0.0-20200419221736-3b63eb3a43b5 // indirect
|
||||
|
|
2
go.sum
2
go.sum
|
@ -39,6 +39,8 @@ github.com/valyala/histogram v1.0.1 h1:FzA7n2Tz/wKRMejgu3PV1vw3htAklTjjuoI6z3d4K
|
|||
github.com/valyala/histogram v1.0.1/go.mod h1:lQy0xA4wUz2+IUnf97SivorsJIp8FxsnRd6x25q7Mto=
|
||||
github.com/xxxserxxx/lingo v1.0.1 h1:lPexOb0HEqYB50EaJdjaYFNATT8JhTcXljbQmCuXygE=
|
||||
github.com/xxxserxxx/lingo v1.0.1/go.mod h1:C2teIFiBLAmEhpLzRkwk7wP5R0eOoveXVYqD+5KOkAs=
|
||||
github.com/xxxserxxx/lingo v1.1.0 h1:UaA0oNyen0vGWNHD6eow+uCfBu7hhypwb28RxQSnprY=
|
||||
github.com/xxxserxxx/lingo v1.1.0/go.mod h1:C2teIFiBLAmEhpLzRkwk7wP5R0eOoveXVYqD+5KOkAs=
|
||||
github.com/xxxserxxx/opflag v1.0.5 h1:2H4Qtl1qe+dSkEcGt+fBe2mQ8z14MgkWPqcLaoa6k90=
|
||||
github.com/xxxserxxx/opflag v1.0.5/go.mod h1:GWZtb3/tGGj5W1GE/JTyJAuqgxDxl1+jqDGAGM+P/p4=
|
||||
golang.org/x/sys v0.0.0-20200316230553-a7d97aace0b0 h1:4Khi5GeNOkZS5DqSBRn4Sy7BE6GuxwOqARPqfurkdNk=
|
||||
|
|
404
translations/dicts.go
Normal file
404
translations/dicts.go
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user