Fix #113
This commit is contained in:
parent
23efab8c60
commit
a3624a0e10
|
@ -264,12 +264,8 @@ func Load() {
|
||||||
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", ip, 1)
|
Wide.ShellChannel = strings.Replace(Wide.ShellChannel, "{IP}", ip, 1)
|
||||||
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", ip, 1)
|
Wide.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", ip, 1)
|
||||||
|
|
||||||
// 获取当前执行路径
|
Wide.Pwd = util.OS.Pwd()
|
||||||
file, _ := exec.LookPath(os.Args[0])
|
glog.V(3).Infof("pwd [%s]", Wide.Pwd)
|
||||||
pwd, _ := filepath.Abs(file)
|
|
||||||
pwd = pwd[:strings.LastIndex(pwd, PathSeparator)]
|
|
||||||
Wide.Pwd = pwd
|
|
||||||
glog.V(3).Infof("pwd [%s]", pwd)
|
|
||||||
|
|
||||||
glog.V(3).Info("Conf: \n" + string(bytes))
|
glog.V(3).Info("Conf: \n" + string(bytes))
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
@ -20,11 +21,18 @@ var Locales = map[string]locale{}
|
||||||
|
|
||||||
// 加载国际化配置.
|
// 加载国际化配置.
|
||||||
func Load() {
|
func Load() {
|
||||||
// TODO: 自动加载所有语言配置
|
f, _ := os.Open("i18n")
|
||||||
|
names, _ := f.Readdirnames(-1)
|
||||||
|
f.Close()
|
||||||
|
|
||||||
load("zh_CN")
|
for _, name := range names {
|
||||||
load("ja_JP")
|
if !strings.HasSuffix(name, ".json") {
|
||||||
load("en_US")
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
loc := name[:strings.LastIndex(name, ".")]
|
||||||
|
load(loc)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func load(localeStr string) {
|
func load(localeStr string) {
|
||||||
|
|
11
util/os.go
11
util/os.go
|
@ -1,6 +1,9 @@
|
||||||
package util
|
package util
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -13,3 +16,11 @@ var OS = myos{}
|
||||||
func (*myos) IsWindows() bool {
|
func (*myos) IsWindows() bool {
|
||||||
return "windows" == runtime.GOOS
|
return "windows" == runtime.GOOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取当前执行程序的工作目录的绝对路径.
|
||||||
|
func (*myos) Pwd() string {
|
||||||
|
file, _ := exec.LookPath(os.Args[0])
|
||||||
|
pwd, _ := filepath.Abs(file)
|
||||||
|
|
||||||
|
return filepath.Dir(pwd)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue