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

Editor: Fix escaping issues with POT generator #80058

Merged
merged 1 commit into from
Aug 1, 2023

Conversation

dalexeev
Copy link
Member

@dalexeev dalexeev commented Jul 30, 2023

Note: I'm not familiar with gettext, please test this if you are.

print(tr(""))
print(tr("\n"))
print(tr("Test 1."))
print(tr("Test 2.\n"))
print(tr("Test 3.\nNewline."))
print(tr("Test 4.\nNewline.\n"))
print(tr("Test 5. \\n - Not newline."))
print(tr("Test 6. \" \\"))

Before:

#: node.gd
msgid ""
msgstr ""

#: node.gd
msgid ""
"\n"
""
msgstr ""

#: node.gd
msgid "Test 1."
msgstr ""

#: node.gd
msgid ""
"Test 2.\n"
""
msgstr ""

#: node.gd
msgid ""
"Test 3.\n"
"Newline."
msgstr ""

#: node.gd
msgid ""
"Test 4.\n"
"Newline.\n"
""
msgstr ""

#: node.gd
msgid ""
"Test 5. \n"
" - Not newline."
msgstr ""

#: node.gd
msgid "Test 6. " \"
msgstr ""

After:

#: node.gd
msgid ""
msgstr ""

#: node.gd
msgid "\n"
msgstr ""

#: node.gd
msgid "Test 1."
msgstr ""

#: node.gd
msgid "Test 2.\n"
msgstr ""

#: node.gd
msgid ""
"Test 3.\n"
"Newline."
msgstr ""

#: node.gd
msgid ""
"Test 4.\n"
"Newline.\n"
msgstr ""

#: node.gd
msgid "Test 5. \\n - Not newline."
msgstr ""

#: node.gd
msgid "Test 6. \" \\"
msgstr ""

@dalexeev dalexeev added this to the 4.2 milestone Jul 30, 2023
@dalexeev dalexeev force-pushed the editor-fix-pot-gen-escaping branch from 058c468 to 8f0066f Compare July 30, 2023 16:39
editor/pot_generator.cpp Outdated Show resolved Hide resolved
@dalexeev dalexeev force-pushed the editor-fix-pot-gen-escaping branch from 8f0066f to aac4a36 Compare July 31, 2023 18:06
Copy link
Member

@timothyqiu timothyqiu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Escaping file paths looks unnecessary. But yeah, newlines in a path seem not forbidden :P

@dalexeev
Copy link
Member Author

dalexeev commented Aug 1, 2023

Escaping file paths looks unnecessary. But yeah, newlines in a path seem not forbidden :P

I just added protection in case the string had newlines for some reason. Because the comment ends on a newline.

Copy link
Contributor

@YuriSizov YuriSizov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks sensible, good job!

@YuriSizov YuriSizov merged commit dfebfd1 into godotengine:master Aug 1, 2023
@YuriSizov
Copy link
Contributor

Thanks!

@dalexeev dalexeev deleted the editor-fix-pot-gen-escaping branch August 1, 2023 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Impossible to generate well formated POT files when a String with \" is used
3 participants