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/updatepage.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'ui/updatepage.go') diff --git a/ui/updatepage.go b/ui/updatepage.go index 9e73781f..1ed0b74c 100644 --- a/ui/updatepage.go +++ b/ui/updatepage.go @@ -6,10 +6,9 @@ package ui import ( - "fmt" - "github.com/lxn/walk" + "golang.zx2c4.com/wireguard/windows/l18n" "golang.zx2c4.com/wireguard/windows/manager" "golang.zx2c4.com/wireguard/windows/updater" ) @@ -30,7 +29,7 @@ func NewUpdatePage() (*UpdatePage, error) { } disposables.Add(up) - up.SetTitle("An Update is Available!") + up.SetTitle(l18n.Sprintf("An Update is Available!")) tabIcon, _ := loadSystemIcon("imageres", 1, 16) up.SetImage(tabIcon) @@ -41,14 +40,14 @@ func NewUpdatePage() (*UpdatePage, error) { if err != nil { return nil, err } - instructions.SetText("An update to WireGuard is available. It is highly advisable to update without delay.") + instructions.SetText(l18n.Sprintf("An update to WireGuard is available. It is highly advisable to update without delay.")) instructions.SetMinMaxSize(walk.Size{1, 0}, walk.Size{0, 0}) status, err := walk.NewTextLabel(up) if err != nil { return nil, err } - status.SetText("Status: Waiting for user") + status.SetText(l18n.Sprintf("Status: Waiting for user")) status.SetMinMaxSize(walk.Size{1, 0}, walk.Size{0, 0}) bar, err := walk.NewProgressBar(up) @@ -63,7 +62,7 @@ func NewUpdatePage() (*UpdatePage, error) { } updateIcon, _ := loadSystemIcon("shell32", 46, 32) button.SetImage(updateIcon) - button.SetText("Update Now") + button.SetText(l18n.Sprintf("Update Now")) walk.NewVSpacer(up) @@ -75,7 +74,7 @@ func NewUpdatePage() (*UpdatePage, error) { bar.SetVisible(true) bar.SetMarqueeMode(true) up.SetSuspended(false) - status.SetText("Status: Waiting for updater service") + status.SetText(l18n.Sprintf("Status: Waiting for updater service")) } } @@ -97,7 +96,7 @@ func NewUpdatePage() (*UpdatePage, error) { err := manager.IPCClientUpdate() if err != nil { switchToReadyState() - status.SetText(fmt.Sprintf("Error: %v. Please try again.", err)) + status.SetText(l18n.Sprintf("Error: %v. Please try again.", err)) } }) @@ -106,11 +105,13 @@ func NewUpdatePage() (*UpdatePage, error) { switchToUpdatingState() if dp.Error != nil { switchToReadyState() - status.SetText(fmt.Sprintf("Error: %v. Please try again.", dp.Error)) + err := dp.Error + status.SetText(l18n.Sprintf("Error: %v. Please try again.", err)) return } if len(dp.Activity) > 0 { - status.SetText(fmt.Sprintf("Status: %s", dp.Activity)) + stateText := dp.Activity + status.SetText(l18n.Sprintf("Status: %s", stateText)) } if dp.BytesTotal > 0 { bar.SetMarqueeMode(false) @@ -123,7 +124,7 @@ func NewUpdatePage() (*UpdatePage, error) { } if dp.Complete { switchToReadyState() - status.SetText("Status: Complete!") + status.SetText(l18n.Sprintf("Status: Complete!")) return } }) -- cgit v1.2.3-59-g8ed1b