Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/text/cmd/gotext: gotext created catalog_gen.go returns wrong value for non-existing keys #35587

Closed
rozmansi opened this issue Nov 14, 2019 · 2 comments
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@rozmansi
Copy link

What version of Go are you using (go version)?

go version go1.13.4 windows/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Simon\AppData\Local\go-build
set GOENV=C:\Users\Simon\AppData\Roaming\go\env
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Simon\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\Simon\go\src\golang.org\x\text\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\XXX\AppData\Local\Temp\go-build215568786=/tmp/go-build -gno-record-gcc-switches

What did you do?

  1. Create a Go sample:
package main

import (
	"strings"

	"golang.org/x/text/language"
	"golang.org/x/text/message"
)

//go:generate go run golang.org/x/text/cmd/gotext -srclang=en update -out=catalog_out.go -lang=en,sl

func main() {
	prn := message.NewPrinter(language.Slovenian)

	prn.Printf("This is a test.\n")

	fruits := []string{"apple", "orange"}
	list := strings.Join(fruits, prn.Sprintf(", "))
	prn.Printf("Fruits: %s\n", list)
}
  1. go generate
  2. Copy locales/sl/out.gotext.json to locales/sl/messages.gotext.json and fill in "translation" members. Copy from "message" members.
  3. go generate
  4. go build
  5. Run the executable.

What did you expect to see?

This is a test.
Fruits: apple, orange

What did you see instead?

This is a test.
Fruits: appleThis is a test.
orange
@gopherbot gopherbot added this to the Unreleased milestone Nov 14, 2019
@gopherbot
Copy link

Change https://golang.org/cl/207217 mentions this issue: message/pipeline: detect unknown keys

zx2c4-bot pushed a commit to WireGuard/wireguard-windows that referenced this issue Nov 14, 2019
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>
zx2c4-bot pushed a commit to WireGuard/wireguard-windows that referenced this issue Nov 15, 2019
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>
zx2c4-bot pushed a commit to WireGuard/wireguard-windows that referenced this issue Nov 15, 2019
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>
@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 15, 2019
@andybons
Copy link
Member

@mpvl

@golang golang locked and limited conversation to collaborators Dec 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

3 participants