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.SessionChannel = strings.Replace(Wide.SessionChannel, "{IP}", ip, 1) | ||||
| 
 | ||||
| 	// 获取当前执行路径
 | ||||
| 	file, _ := exec.LookPath(os.Args[0]) | ||||
| 	pwd, _ := filepath.Abs(file) | ||||
| 	pwd = pwd[:strings.LastIndex(pwd, PathSeparator)] | ||||
| 	Wide.Pwd = pwd | ||||
| 	glog.V(3).Infof("pwd [%s]", pwd) | ||||
| 	Wide.Pwd = util.OS.Pwd() | ||||
| 	glog.V(3).Infof("pwd [%s]", Wide.Pwd) | ||||
| 
 | ||||
| 	glog.V(3).Info("Conf: \n" + string(bytes)) | ||||
| 
 | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ import ( | |||
| 	"encoding/json" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"strings" | ||||
| 
 | ||||
| 	"github.com/golang/glog" | ||||
| ) | ||||
|  | @ -20,11 +21,18 @@ var Locales = map[string]locale{} | |||
| 
 | ||||
| // 加载国际化配置.
 | ||||
| func Load() { | ||||
| 	// TODO: 自动加载所有语言配置
 | ||||
| 	f, _ := os.Open("i18n") | ||||
| 	names, _ := f.Readdirnames(-1) | ||||
| 	f.Close() | ||||
| 
 | ||||
| 	load("zh_CN") | ||||
| 	load("ja_JP") | ||||
| 	load("en_US") | ||||
| 	for _, name := range names { | ||||
| 		if !strings.HasSuffix(name, ".json") { | ||||
| 			continue | ||||
| 		} | ||||
| 
 | ||||
| 		loc := name[:strings.LastIndex(name, ".")] | ||||
| 		load(loc) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func load(localeStr string) { | ||||
|  |  | |||
							
								
								
									
										11
									
								
								util/os.go
								
								
								
								
							
							
						
						
									
										11
									
								
								util/os.go
								
								
								
								
							|  | @ -1,6 +1,9 @@ | |||
| package util | ||||
| 
 | ||||
| import ( | ||||
| 	"os" | ||||
| 	"os/exec" | ||||
| 	"path/filepath" | ||||
| 	"runtime" | ||||
| ) | ||||
| 
 | ||||
|  | @ -13,3 +16,11 @@ var OS = myos{} | |||
| func (*myos) IsWindows() bool { | ||||
| 	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