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/managewindow.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'ui/managewindow.go') diff --git a/ui/managewindow.go b/ui/managewindow.go index 542c91b9..e6855d5d 100644 --- a/ui/managewindow.go +++ b/ui/managewindow.go @@ -13,6 +13,7 @@ import ( "github.com/lxn/win" "golang.org/x/sys/windows" + "golang.zx2c4.com/wireguard/windows/l18n" "golang.zx2c4.com/wireguard/windows/manager" ) @@ -118,7 +119,7 @@ func NewManageTunnelsWindow() (*ManageTunnelsWindow, error) { CbSize: uint32(unsafe.Sizeof(win.MENUITEMINFO{})), FMask: win.MIIM_ID | win.MIIM_STRING | win.MIIM_FTYPE, FType: win.MIIM_STRING, - DwTypeData: windows.StringToUTF16Ptr("&About WireGuard…"), + DwTypeData: windows.StringToUTF16Ptr(l18n.Sprintf("&About WireGuard…")), WID: uint32(aboutWireGuardCmd), }) win.InsertMenuItem(systemMenu, 1, true, &win.MENUITEMINFO{ @@ -169,7 +170,7 @@ func (mtw *ManageTunnelsWindow) onTunnelChange(tunnel *manager.Tunnel, state man if len(errMsg) > 0 && errMsg[len(errMsg)-1] != '.' { errMsg += "." } - showWarningCustom(mtw, "Tunnel Error", errMsg+"\n\nPlease consult the log for more information.") + showWarningCustom(mtw, l18n.Sprintf("Tunnel Error"), l18n.Sprintf("%s\n\nPlease consult the log for more information.", errMsg)) } }) } @@ -178,7 +179,7 @@ func (mtw *ManageTunnelsWindow) UpdateFound() { if mtw.updatePage != nil { return } - mtw.SetTitle(mtw.Title() + " (out of date)") + mtw.SetTitle(l18n.Sprintf("%s (out of date)", mtw.Title())) updatePage, err := NewUpdatePage() if err == nil { mtw.updatePage = updatePage -- cgit v1.2.3-59-g8ed1b