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/message: expected behaviour of message.Print is unclear #63173

Open
mtibben opened this issue Sep 23, 2023 · 1 comment
Open

x/text/message: expected behaviour of message.Print is unclear #63173

mtibben opened this issue Sep 23, 2023 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mtibben
Copy link

mtibben commented Sep 23, 2023

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

$ go version
go version go1.21.1 darwin/arm64

$ go get golang.org/x/text@v0.13.0

What did you do?

Executed the following https://go.dev/play/p/htbw6anb94b

message.SetString(language.German, "foo", "bar")
message.NewPrinter(language.German).Print("foo")
message.NewPrinter(language.German).Printf("foo")

What did you expect to see?

barbar

What did you see instead?

foobar

When using the Printer.Print function, I expect language substitutions to occur. If no language substitutions were wanted, I would use fmt.Print instead. I would not normally use Printf unless I am using a format specifier.

The Printer.Print documentation says

Print is like fmt.Print, but using language-specific formatting.

However it doesn't specify what types of language-specific formatting is actually applied. I'd expect string substitution to be one of these language-specific formatting.

Erroneous use of Printer.Print can also be seen on this blog post which uses Printer.Println instead of the working Printer.Printf

Is this a bug, or expected behaviour?

/cc @mpvl via https://dev.golang.org/owners

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/530716 mentions this issue: message: fix language translation issue

@thanm thanm added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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