From 8a476b326136f5c03790fa168686848884c8cd5a Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Thu, 14 Nov 2019 09:27:05 +0100 Subject: l18n: add localization support Revise the messages to make them localizable. Note: The log messages are not marked for localization. Probably, we want to keep log files in English for easier global troubleshooting. Having a user run `go generate` requires a valid and up-to-date Go environment. Rather than instructing users how to setup the environment correctly, the `go generate` was integrated into build.bat. This reuses the Go building environment downloaded and prepared by build.bat to provide controllable and consistent result. Use `make generate` on Linux. As the zgotext.go output varies for GOARCH=386 and amd64, one had to be chosen to provide stable output. The former is the first one to build in build.bat. Signed-off-by: Simon Rozman --- ui/filesave.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ui/filesave.go') diff --git a/ui/filesave.go b/ui/filesave.go index 4b5c2947..7ca8a2c2 100644 --- a/ui/filesave.go +++ b/ui/filesave.go @@ -6,10 +6,11 @@ package ui import ( - "fmt" "os" "github.com/lxn/walk" + + "golang.zx2c4.com/wireguard/windows/l18n" ) func writeFileWithOverwriteHandling(owner walk.Form, filePath string, write func(file *os.File) error) bool { @@ -18,7 +19,7 @@ func writeFileWithOverwriteHandling(owner walk.Form, filePath string, write func return false } - showErrorCustom(owner, "Writing file failed", err.Error()) + showErrorCustom(owner, l18n.Sprintf("Writing file failed"), err.Error()) return true } @@ -26,7 +27,7 @@ func writeFileWithOverwriteHandling(owner walk.Form, filePath string, write func file, err := os.OpenFile(filePath, os.O_CREATE|os.O_WRONLY|os.O_EXCL, 0600) if err != nil { if os.IsExist(err) { - if walk.DlgCmdNo == walk.MsgBox(owner, "Writing file failed", fmt.Sprintf(`File ā€˜%sā€™ already exists. + if walk.DlgCmdNo == walk.MsgBox(owner, l18n.Sprintf("Writing file failed"), l18n.Sprintf(`File ā€˜%sā€™ already exists. Do you want to overwrite it?`, filePath), walk.MsgBoxYesNo|walk.MsgBoxDefButton2|walk.MsgBoxIconWarning) { return false -- cgit v1.2.3-59-g8ed1b