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

Multi-line and backquotes strings support incorrect compared to gettext spec #81

Closed
didrocks opened this issue Jul 26, 2023 · 0 comments

Comments

@didrocks
Copy link
Contributor

didrocks commented Jul 26, 2023

Please describe your issue

Is this a bug, an improvement, a proposal or something else? Describe it.

When exporting from a po and extracting text from files, there are multiple issues for multi-line and backquotes usage. This is fine until we use standard gettext tooling for compiling them to mo files.

  • multilines are printed as is, instead of follow the gettext spec ( )
  • strings with backquotes as printed as “msgid this is my string”, which then can’t be compiled to mo files.
  • multilines strings with backquotes are formatted as multi-lines to, without closing quotes on each lines.

The loading is correct though, this only impact the generation file. Those generated files are thus then invalid and can’t be compile to mo file.

The gettext specification can be found at https://www.gnu.org/software/gettext/manual/html_node/Normalizing.html.

What's the expected behaviour, the current behaviour and the steps to reproduce it?

From:

	fmt.Println(gotext.Get("Hello World, end line\n"))
	fmt.Println(gotext.Get(`A single line text`))
	fmt.Println(gotext.Get("A single line text"))
	fmt.Println(gotext.Get("\nService already exists and will be reconfigured\n"))
	fmt.Println(gotext.Get(`
Service already exists and will be reconfigured 2
`))
	fmt.Println(gotext.Get("\nService already exists and will be reconfigured 2\n"))
	fmt.Println(gotext.Get("\nService already exists and will be reconfigured without EOL))

Example of currently exported string:

#: main.go:22
msgid "\nService already exists and will be reconfigured\n"
msgstr ""

#: main.go:23
msgid `
Service already exists and will be reconfigured 2
`
msgstr ""

#: main.go:21
msgid `A single line text`
msgstr ""

#: main.go:22
msgid "Hello World, end line\n"
msgstr ""

#: main.go:30
msgid "\nService already exists and will be reconfigured without EOL"
msgstr ""

Expectation from the spec:

#: main.go:22
msgid ""
"\n"
"Service already exists and will be reconfigured\n"
msgstr ""

#: main.go:26
#: main.go:29
msgid ""
"\n"
"Service already exists and will be reconfigured 2\n"
msgstr ""

#: main.go:23
#: main.go:24
msgid "A single line text"
msgstr ""

#: main.go:22
msgid "Hello World, end line\n"
msgstr ""

#: main.go:30
msgid ""
"\n"
"Service already exists and will be reconfigured without EOL"
msgstr ""
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

2 participants