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: extract only matches printer.Sprintf calls, not printer.Sprint calls #69742

Closed
SamWhited opened this issue Oct 2, 2024 · 2 comments
Milestone

Comments

@SamWhited
Copy link
Member

Go version

go version go1.23.1 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/sam/.cache/go-build'
GOENV='/home/sam/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/sam/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/sam/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.1'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/sam/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/sam/gotest/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4124639609=/tmp/go-build -gno-record-gcc-switches'

What did you do?

Put the following MWE in a module and run go generate

(Playground: https://go.dev/play/p/uBxxYhGtldB)

package main

//go:generate gotext extract .
import (
	"fmt"

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

func main() {
	p := message.NewPrinter(message.MatchLanguage("en"))

	fmt.Println(p.Sprint("One"))
	fmt.Println(p.Sprintf("Two: %v", "three"))
}

What did you see happen?

The first string ("One") is not extracted to "locales/en-US/out.gotext.json" and won't be in your translations file. The second string is extracted correctly.

What did you expect to see?

Both strings are extracted to "locales/en-US/out.gotext.json"

@gopherbot gopherbot added this to the Unreleased milestone Oct 2, 2024
@SamWhited
Copy link
Member Author

Oops, looks like a duplicate of #41781. Apologies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants