From 21a826c11cbb6e82f11677c6898b52ffdbf88ff7 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 09:48:07 +0900 Subject: [PATCH 01/11] Add japanese locale --- i18n/ja_JP.json | 109 ++++++++++++++++++++++++++++++++++++++++++++++++ i18n/locales.go | 1 + 2 files changed, 110 insertions(+) create mode 100644 i18n/ja_JP.json diff --git a/i18n/ja_JP.json b/i18n/ja_JP.json new file mode 100644 index 0000000..1c4f4ba --- /dev/null +++ b/i18n/ja_JP.json @@ -0,0 +1,109 @@ +{ + "wide": "Wide", + "isDelete": "削除", + "cancel": "取消", + "file": "ファイル", + "login": "ログイン", + "username": "ユーザ名", + "current_user": "現在のユーザ", + "password": "パスワード", + "login_error": "ログインエラー", + "run": "実行", + "debug": "デバッグ", + "help": "ヘルプ", + "check_update": "更新をチェック", + "report_issues": "問題を報告", + "wide_doc": "Wide ドキュメント", + "about": "Wide について", + "start_page": "スタートページ", + "create_file": "新規ファイル", + "create": "作成", + "create_dir": "新規ディレクトリ", + "delete": "削除", + "save": "保存", + "exit": "終了", + "close_all_files": "全てのファイルを閉じる", + "save_all_files": "全てを保存", + "format": "フォーマット", + "goget": "go get", + "goinstall": "go install", + "build": "ビルド", + "build_n_run": "ビルド実行", + "editor": "エディタ", + "max_editor": "最大化", + "restore_editor": "元のサイズに戻す", + "unread_notification": "未読の通知", + "notification_2": "[gocode] が見つかりません。[Autocomplete] は動作しません。", + "notification_3": "[ide_stub] が見つかりません。[Jump to Decl]、[Find Usages] は動作しません。", + "goto_line": "指定行にジャンプ", + "go": "Go", + "tip": "ヒント", + "confirm": "確認", + "stop": "停止", + "output": "出力", + "search": "検索", + "notification": "通知", + "min": "最小化", + "restore_side": "ファイルツリーを戻す", + "search_text": "テキストを検索", + "find": "検索", + "find_next": "次を検索", + "find_previous": "前を検索", + "replace": "置換", + "replace_all": "全て置換", + "restore_bottom": "ウィンドウを下に戻す", + "file_format": "ファイルの拡張子", + "keyword": "キーワード", + "user_guide": "ユーザガイド", + "dev_guide": "開発ガイド", + "keyboard_shortcuts": "キーボードショートカット", + "ver": "バージョン", + "current_ver": "現在のバージョン", + "dev_team": "開発チーム", + "donate_us": "寄付", + "confirm_save": "保存の確認", + "workspace": "ワークスペース", + "project_address": "プロジェクト", + "community": "コミュニティ", + "autocomplete": "自動補完", + "jump_to_decl": "定義へジャンプ", + "show_expr_info": "式の情報を表示", + "find_usages": "使用方法を検索する", + "delete_line": "行を削除", + "save_editor_file": "保存", + "save_all_editors_files": "全てを保存", + "close_editor": "エディタを閉じる", + "full_screen": "全画面", + "auto_indent": "自動インデント", + "indent": "インデントを増やす", + "unindent": "インデントを減らす", + "focus": "フォーカス", + "switch_tab": "タブを切り替える", + "focus_editor": "エディタにフォーカスを与える", + "focus_file_tree": "ファイルツリーにフォーカスを与える", + "focus_output": "出力にフォーカスを与える", + "focus_search": "検索にフォーカスを与える", + "focus_notification": "通知にフォーカスを与える", + "start-build": "[go build] 開始", + "build-succ": "[go build] 成功", + "build-error": "[go build] 失敗", + "start-test": "[go test] 開始", + "test-succ": "[go test] 成功", + "test-error": "[go test] 失敗", + "start-install": "[go install] 開始", + "install-succ": "[go install] 成功", + "install-error": "[go install] 失敗", + "start-get": "[go get] 開始", + "get-succ": "[go get] 成功", + "get-error": "[go get] 失敗", + "check_version": "更新をチェック中", + "new_version_available": "新しいバージョンがあります", + "go_env": "Go", + "os": "OS", + "project": "プロジェクト", + "license": "ライセンス", + "credits": "クレジット", + "uptodate": "最新です", + "test": "テスト", + "colon": ":" +} diff --git a/i18n/locales.go b/i18n/locales.go index e86e017..02d6946 100644 --- a/i18n/locales.go +++ b/i18n/locales.go @@ -23,6 +23,7 @@ func Load() { // TODO: 自动加载所有语言配置 load("zh_CN") + load("ja_JP") load("en_US") } From b99e954f4f071f677847fe32749fcc33e0e47bf1 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 09:48:11 +0900 Subject: [PATCH 02/11] Separate font-family --- static/css/base.css | 4 ++-- views/index.html | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/static/css/base.css b/static/css/base.css index a7c2bfd..b30956f 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -4,7 +4,7 @@ body { margin: 0; color: #000; overflow: hidden; - font-family: Helvetica, 'Microsoft Yahei'; + font-family: Helvetica; } ul { @@ -19,7 +19,7 @@ ul { input, button { - font-family: Helvetica, 'Microsoft Yahei'; + font-family: Helvetica, 'Microsoft Yahei', 'MS Gothic'; } .fn-left { diff --git a/views/index.html b/views/index.html index 597c2e4..4da204a 100644 --- a/views/index.html +++ b/views/index.html @@ -14,6 +14,7 @@ + From 850be98c9ad903d686923b248f8ba9c5f220439e Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 09:48:30 +0900 Subject: [PATCH 03/11] Separate font-family --- static/css/base-en_US.css | 0 static/css/base-ja_JP.css | 3 +++ static/css/base-zh_CN.css | 3 +++ 3 files changed, 6 insertions(+) create mode 100644 static/css/base-en_US.css create mode 100644 static/css/base-ja_JP.css create mode 100644 static/css/base-zh_CN.css diff --git a/static/css/base-en_US.css b/static/css/base-en_US.css new file mode 100644 index 0000000..e69de29 diff --git a/static/css/base-ja_JP.css b/static/css/base-ja_JP.css new file mode 100644 index 0000000..2e7a32b --- /dev/null +++ b/static/css/base-ja_JP.css @@ -0,0 +1,3 @@ +body { + font-family: Helvetica, 'MS Gothic'; +} diff --git a/static/css/base-zh_CN.css b/static/css/base-zh_CN.css new file mode 100644 index 0000000..8ed20fa --- /dev/null +++ b/static/css/base-zh_CN.css @@ -0,0 +1,3 @@ +body { + font-family: Helvetica, 'Microsoft Yahei'; +} From eaddb049c7abfb6edaf4171488118b4d7a774102 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 09:55:00 +0900 Subject: [PATCH 04/11] Separate CSSs to handle font-family for buttons --- static/css/base-ja_JP.css | 5 +++++ static/css/base-zh_CN.css | 5 +++++ static/css/base.css | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/static/css/base-ja_JP.css b/static/css/base-ja_JP.css index 2e7a32b..1ec0f2b 100644 --- a/static/css/base-ja_JP.css +++ b/static/css/base-ja_JP.css @@ -1,3 +1,8 @@ body { font-family: Helvetica, 'MS Gothic'; } + +input, +button { + font-family: Helvetica, 'MS Gothic'; +} diff --git a/static/css/base-zh_CN.css b/static/css/base-zh_CN.css index 8ed20fa..9bfc42a 100644 --- a/static/css/base-zh_CN.css +++ b/static/css/base-zh_CN.css @@ -1,3 +1,8 @@ body { font-family: Helvetica, 'Microsoft Yahei'; } + +input, +button { + font-family: Helvetica, 'Microsoft Yahei'; +} diff --git a/static/css/base.css b/static/css/base.css index b30956f..7f546e8 100644 --- a/static/css/base.css +++ b/static/css/base.css @@ -19,7 +19,7 @@ ul { input, button { - font-family: Helvetica, 'Microsoft Yahei', 'MS Gothic'; + font-family: Helvetica; } .fn-left { From 9bfaef796eecc9d636ce869af41efd454beb1894 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 10:12:32 +0900 Subject: [PATCH 05/11] Handle two columns error format. ex: /path/to/file.go: Permission denied --- output/outputs.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/output/outputs.go b/output/outputs.go index e238d92..8420add 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -33,7 +33,7 @@ type Lint struct { File string `json:"file"` LineNo int `json:"lineNo"` Severity string `json:"severity"` - Msg string + Msg string `json:"msg"` } // 建立输出通道. @@ -354,8 +354,13 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] - lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")]) - msg := left[strings.Index(left, ":")+2:] + index := strings.Index(left, ":") + lineNo := 1 + msg := left + if index >= 0 { + lineNo, _ = strconv.Atoi(left[:index]) + msg = left[index+2:] + } lint := &Lint{ File: file, @@ -621,8 +626,13 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] - lineNo, _ := strconv.Atoi(left[:strings.Index(left, ":")]) - msg := left[strings.Index(left, ":")+2:] + index := strings.Index(left, ":") + lineNo := 1 + msg := left + if index >= 0 { + lineNo, _ = strconv.Atoi(left[:index]) + msg = left[index+2:] + } lint := &Lint{ File: file, From 1362ad1ea3298be24131afa014547c56bca808f5 Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 10:16:42 +0900 Subject: [PATCH 06/11] Should be zero to avoid highlight editor --- output/outputs.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/output/outputs.go b/output/outputs.go index 8420add..610a097 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -355,7 +355,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] index := strings.Index(left, ":") - lineNo := 1 + lineNo := 0 msg := left if index >= 0 { lineNo, _ = strconv.Atoi(left[:index]) @@ -627,7 +627,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { file := line[:strings.Index(line, ":")] left := line[strings.Index(line, ":")+1:] index := strings.Index(left, ":") - lineNo := 1 + lineNo := 0 msg := left if index >= 0 { lineNo, _ = strconv.Atoi(left[:index]) From 45d409540190e3d8dfdba3862d895777fabe3daf Mon Sep 17 00:00:00 2001 From: mattn Date: Tue, 28 Oct 2014 11:13:00 +0900 Subject: [PATCH 07/11] Fix filepath things. This make wide possible to work "Build/Build&Run" on windows --- output/outputs.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/output/outputs.go b/output/outputs.go index e238d92..04f860d 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -10,6 +10,7 @@ import ( "net/http" "os" "os/exec" + "path/filepath" "runtime" "strconv" "strings" @@ -74,7 +75,7 @@ func RunHandler(w http.ResponseWriter, r *http.Request) { } filePath := args["executable"].(string) - curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)] + curDir := filepath.Dir(filePath) cmd := exec.Command(filePath) cmd.Dir = curDir @@ -198,7 +199,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { sid := args["sid"].(string) filePath := args["file"].(string) - curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)] + curDir := filepath.Dir(filePath) fout, err := os.Create(filePath) @@ -234,7 +235,7 @@ func BuildHandler(w http.ResponseWriter, r *http.Request) { glog.V(5).Infof("go build -o %s", executable) - executable = curDir + conf.PathSeparator + executable + executable = filepath.Join(curDir, executable) // 先把可执行文件删了 err = os.RemoveAll(executable) @@ -407,7 +408,7 @@ func GoTestHandler(w http.ResponseWriter, r *http.Request) { sid := args["sid"].(string) filePath := args["file"].(string) - curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)] + curDir := filepath.Dir(filePath) cmd := exec.Command("go", "test", "-v") cmd.Dir = curDir @@ -522,7 +523,7 @@ func GoInstallHandler(w http.ResponseWriter, r *http.Request) { sid := args["sid"].(string) filePath := args["file"].(string) - curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)] + curDir := filepath.Dir(filePath) cmd := exec.Command("go", "install") cmd.Dir = curDir @@ -678,7 +679,7 @@ func GoGetHandler(w http.ResponseWriter, r *http.Request) { sid := args["sid"].(string) filePath := args["file"].(string) - curDir := filePath[:strings.LastIndex(filePath, conf.PathSeparator)] + curDir := filepath.Dir(filePath) cmd := exec.Command("go", "get") cmd.Dir = curDir @@ -802,7 +803,7 @@ func setCmdEnv(cmd *exec.Cmd, username string) { masterWorkspace := conf.Wide.GetWorkspace() cmd.Env = append(cmd.Env, - "GOPATH="+userWorkspace+conf.PathListSeparator+masterWorkspace, + "GOPATH="+filepath.Join(userWorkspace, masterWorkspace), "GOOS="+runtime.GOOS, "GOARCH="+runtime.GOARCH, "GOROOT="+runtime.GOROOT(), From 363728316832a596f8e39dd13b7bc4a1f7a5c93b Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Oct 2014 12:06:50 +0800 Subject: [PATCH 08/11] #111 @mattn --- output/outputs.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/output/outputs.go b/output/outputs.go index 04f860d..9e4353a 100644 --- a/output/outputs.go +++ b/output/outputs.go @@ -803,7 +803,7 @@ func setCmdEnv(cmd *exec.Cmd, username string) { masterWorkspace := conf.Wide.GetWorkspace() cmd.Env = append(cmd.Env, - "GOPATH="+filepath.Join(userWorkspace, masterWorkspace), + "GOPATH="+userWorkspace+conf.PathListSeparator+masterWorkspace, "GOOS="+runtime.GOOS, "GOARCH="+runtime.GOARCH, "GOROOT="+runtime.GOROOT(), From 1c65b7403792a3c09473c46d4f5d3e4fff24bdd6 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Oct 2014 13:22:39 +0800 Subject: [PATCH 09/11] refactor path things --- conf/wide.go | 6 +++--- editor/editors.go | 3 ++- file/files.go | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index 5e6384c..3ec8fee 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -183,7 +183,7 @@ func (*conf) GetExecutableInGOBIN(executable string) string { executable += ".exe" } - gopaths := strings.Split(os.Getenv("GOPATH"), PathListSeparator) + gopaths := filepath.SplitList(os.Getenv("GOPATH")) for _, gopath := range gopaths { // $GOPATH/bin/$GOOS_$GOARCH/executable @@ -280,10 +280,10 @@ func Load() { // // 如果不存在 Workspace 配置所指定的目录路径则创建该目录. func initWorkspaceDirs() { - paths := strings.Split(Wide.GetWorkspace(), PathListSeparator) + paths := filepath.SplitList(Wide.GetWorkspace()) for _, user := range Wide.Users { - paths = append(paths, strings.Split(user.GetWorkspace(), PathListSeparator)...) + paths = append(paths, filepath.SplitList(user.GetWorkspace())...) } diff --git a/editor/editors.go b/editor/editors.go index 85514b0..f5a21b9 100644 --- a/editor/editors.go +++ b/editor/editors.go @@ -7,6 +7,7 @@ import ( "net/http" "os" "os/exec" + "path/filepath" "runtime" "strconv" "strings" @@ -124,7 +125,7 @@ func AutocompleteHandler(w http.ResponseWriter, r *http.Request) { // glog.Infof("offset: %d", offset) userWorkspace := conf.Wide.GetUserWorkspace(username) - workspaces := strings.Split(userWorkspace, conf.PathListSeparator) + workspaces := filepath.SplitList(userWorkspace) libPath := "" for _, workspace := range workspaces { userLib := workspace + conf.PathSeparator + "pkg" + conf.PathSeparator + diff --git a/file/files.go b/file/files.go index 1e1bd28..14b679a 100644 --- a/file/files.go +++ b/file/files.go @@ -46,7 +46,7 @@ func GetFiles(w http.ResponseWriter, r *http.Request) { username := session.Values["username"].(string) userWorkspace := conf.Wide.GetUserWorkspace(username) - workspaces := strings.Split(userWorkspace, conf.PathListSeparator) + workspaces := filepath.SplitList(userWorkspace) root := FileNode{Name: "root", Path: "", IconSkin: "ico-ztree-dir ", Type: "d", FileNodes: []*FileNode{}} From 23efab8c60399560a03b82308677c714f141abeb Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Oct 2014 13:47:43 +0800 Subject: [PATCH 10/11] format --- views/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/index.html b/views/index.html index 4da204a..05dcc14 100644 --- a/views/index.html +++ b/views/index.html @@ -14,7 +14,7 @@ - + From a3624a0e10994805801a2f767995280cbaeefb1e Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 28 Oct 2014 14:38:27 +0800 Subject: [PATCH 11/11] Fix #113 --- conf/wide.go | 8 ++------ i18n/locales.go | 16 ++++++++++++---- util/os.go | 11 +++++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/conf/wide.go b/conf/wide.go index 3ec8fee..2b6c48b 100644 --- a/conf/wide.go +++ b/conf/wide.go @@ -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)) diff --git a/i18n/locales.go b/i18n/locales.go index 02d6946..632caa5 100644 --- a/i18n/locales.go +++ b/i18n/locales.go @@ -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) { diff --git a/util/os.go b/util/os.go index 7350aeb..8517abe 100644 --- a/util/os.go +++ b/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) +}