-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gotext: fix non-existing translation lookup
The ", " somehow doesn't make it to the locale catalogues. And gotext has a bug to return first translation instead of error on non-existing lookups. When the gotext is fixed upstream (fix proposed), remove this commit. But, do research, why ", " strings are not picked up by gotext for translation. See-also: golang/go#35587). See-also: https://go-review.googlesource.com/c/text/+/207217 Signed-off-by: Simon Rozman <simon@rozman.si>
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
From 8359973c072d7822b711ad548902a8130b35d85a Mon Sep 17 00:00:00 2001 | ||
From: Simon Rozman <simon@rozman.si> | ||
Date: Thu, 14 Nov 2019 15:11:40 +0100 | ||
Subject: [PATCH] gotext: fix non-existing key lookup | ||
|
||
See-also: https://go-review.googlesource.com/c/text/+/207217 | ||
Signed-off-by: Simon Rozman <simon@rozman.si> | ||
--- | ||
zgotext.go | 5 ++++- | ||
1 file changed, 4 insertions(+), 1 deletion(-) | ||
|
||
diff --git a/zgotext.go b/zgotext.go | ||
index 4a840c02..b66b2272 100644 | ||
--- a/zgotext.go | ||
+++ b/zgotext.go | ||
@@ -14,7 +14,10 @@ type dictionary struct { | ||
} | ||
|
||
func (d *dictionary) Lookup(key string) (data string, ok bool) { | ||
- p := messageKeyToIndex[key] | ||
+ p, ok := messageKeyToIndex[key] | ||
+ if !ok { | ||
+ return "", false | ||
+ } | ||
start, end := d.index[p], d.index[p+1] | ||
if start == end { | ||
return "", false | ||
-- | ||
2.19.1.windows.1 | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.