Generate a catalog.go file with the following strings (for example):
"This is the first string in the catalog"
"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.
The text was updated successfully, but these errors were encountered:
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.