scelis / twine

Twine is a command line tool for managing your strings and their translations.
Other
840 stars 151 forks source link

Character " is not escaped in PO files #267

Closed DJansse closed 5 years ago

DJansse commented 5 years ago

Hi all, I think I've found an issue with the generation of Android localization files, using Twine 1.0.4, and having an entry in the twine file like this:

[[ContextSensitiveHelp]]
[contextSensitiveHelp_home_bottomMenuBar_message]
        en = The most used sections can be accessed here. Tapping "More" reveals a list with all other sections.
        comment = Help item message about the usage of the bottom menu bar.
        de = The most used sections can be accessed here. Tapping "More" reveals a list with all other sections.

causes some issues when exporting to PO files, using the following command twine generate-localization-file twine.txt translations_20_02_19_en.po --lang en --format gettext :

#. "Help item message about the usage of the bottom menu bar."
msgctxt "contextSensitiveHelp_home_bottomMenuBar_message"
msgid "The most used sections can be accessed here. Tapping "More" reveals a list with all other sections."
msgstr "The most used sections can be accessed here. Tapping "More" reveals a list with all other sections."

You can see that the "More" isn't correctly escaped. Generating localization files with this however works fine.

The quick idea to fix this was escaping the " within the twine file:

[[ContextSensitiveHelp]]
[contextSensitiveHelp_home_bottomMenuBar_message]
        en = The most used sections can be accessed here. Tapping \"More\" reveals a list with all other sections.
        comment = Help item message about the usage of the bottom menu bar.
        de = The most used sections can be accessed here. Tapping \"More\" reveals a list with all other sections.

Which leads to a correct PO file entry:

#. "Help item message about the usage of the bottom menu bar."
msgctxt "contextSensitiveHelp_home_bottomMenuBar_message"
msgid "The most used sections can be accessed here. Tapping \"More\" reveals a list with all other sections."
msgstr "The most used sections can be accessed here. Tapping \"More\" reveals a list with all other sections."

but then the Android localization files are affected using twine generate-localization-file twine.txt ../app/src/skinFlavour/res/values/strings_generated.xml --lang en --format android:

<!-- Help item message about the usage of the bottom menu bar. -->
    <string name="contextSensitiveHelp_home_bottomMenuBar_message">The most used sections can be accessed here. Tapping \\"More\\" reveals a list with all other sections.</string>

The expected output would be that the PO file would have been generated properly with the " part of the string being escaped like above:

#. "Help item message about the usage of the bottom menu bar."
msgctxt "contextSensitiveHelp_home_bottomMenuBar_message"
msgid "The most used sections can be accessed here. Tapping \"More\" reveals a list with all other sections."
msgstr "The most used sections can be accessed here. Tapping \"More\" reveals a list with all other sections."

Kind regards, Davy

scelis commented 5 years ago

Thanks for this excellent report! I have opened #268 which should fix this issue. If you are able to confirm using this build that would be wonderful!