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: first string in catalog returned when the given string is not in the catalog #30924

Open
jeffreydwalter opened this issue Mar 19, 2019 · 2 comments

Comments

@jeffreydwalter
Copy link

@jeffreydwalter jeffreydwalter commented Mar 19, 2019

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

$ go version
go version go1.11.5 darwin/amd64

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="~/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="~/Code/kace/agent"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/8w/05w3j5xj4q34m1z6w9ynmcf80000gp/T/go-build628007696=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Generate a catalog.go file with the following strings (for example):

  1. "This is the first string in the catalog"
  2. "This is the second string in the catalog"

Now, translate a string that's not in the catalog.

p := message.NewPrinter(message.MatchLanguage("en"))
p.Println("This string is not in the catalog")

What did you expect to see?

I would expect to get back the original string I passed to the p.Println() function if it does not match any string in the catalog.
In this case, I expect to get back: This string is not in the catalog.

What did you see instead?

p.Println() returns the first string in the catalog. In this case, I get back: This is the first string in the catalog.

@gopherbot gopherbot added this to the Unreleased milestone Mar 19, 2019
@agnivade

This comment has been minimized.

Copy link
Contributor

@agnivade agnivade commented Apr 8, 2019

@jeffreydwalter

This comment has been minimized.

Copy link
Author

@jeffreydwalter jeffreydwalter commented Apr 8, 2019

To add some color to this issue, the expected behavior (getting back the original string) is how gettext works. I do realize that either way the string we would get back would not be the proper translation, but getting back the original string at least lets you test to see if the string was translated. Getting back the first random translation in the catalog is not a good developer experience. It makes unit testing more challenging and reduces the general usability of this package.

@julieqiu julieqiu changed the title x/text: First string in catalog returned when the given string is not in the catalog. x/text: first string in catalog returned when the given string is not in the catalog May 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.