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

Impossible to generate well formated POT files when a String with \" is used #80004

Closed
acgc99 opened this issue Jul 29, 2023 · 0 comments · Fixed by #80058
Closed

Impossible to generate well formated POT files when a String with \" is used #80004

acgc99 opened this issue Jul 29, 2023 · 0 comments · Fixed by #80058

Comments

@acgc99
Copy link

acgc99 commented Jul 29, 2023

Godot version

v4.1.stable.official [9704596]

System information

Godot v4.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 (NVIDIA; 31.0.15.3667) - Intel(R) Core(TM) i5-8300H CPU @ 2.30GHz (8 Threads)

Issue description

When generating a POT file using Godot Editor, if the String contains double quotes, its entry in the POT file will be wrong (see below).

Steps to reproduce

Create this script:

extends Control


func _ready():
	
	var a: String = tr("\"Problematic\" string")
	print(a)

And then generate a POT file from it. You will get something like:

# LANGUAGE translation for Bugs for the following files:
# res://main.gd
#
# FIRST AUTHOR < EMAIL @ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Bugs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"

#: main.gd
msgid ""Problematic" string"
msgstr ""

The problem cames from the extra double quotes inside the string, they will raise an error when generating a PO file.

A possible solution would be to make:

extends Control


func _ready():
	
	TranslationServer.set_locale("fr")
	var a: String = tr("\\\"Problematic\\\" string")
	print(a)

Therefore, the POT file:

# LANGUAGE translation for Bugs for the following files:
# res://main.gd
#
# FIRST AUTHOR < EMAIL @ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Bugs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8-bit\n"

#: main.gd
msgid "\"Problematic\" string"
msgstr ""

But then, the string is not recognized. This is the PO file with an extra entry added manually:

# LANGUAGE translation for Bugs for the following files:
# res://main.gd
#
# FIRST AUTHOR < EMAIL @ADDRESS>, 2023.
#
msgid ""
msgstr ""
"Project-Id-Version: Bugs\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: fr\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n"

#: main.gd
msgid "\"Problematic\" string"
msgstr "TEST0"

msgid "\\\"Problematic\\\" string"
msgstr "TEST1"

Then print(a) prints TEST1 instead of TEST0.

Minimal reproduction project

project.zip

@acgc99 acgc99 changed the title Generation of POT files when Strings with \" are used Impossible to generate well formated POT files when Strings with \" are used Jul 29, 2023
@acgc99 acgc99 changed the title Impossible to generate well formated POT files when Strings with \" are used Impossible to generate well formated POT files when a String with \" is used Jul 29, 2023
@YuriSizov YuriSizov added this to the 4.2 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants