Skip to content

Consuming PO file skips multiline msgctxt entries #288

@DJansse

Description

@DJansse

Hi Twine team,
we've encountered an issue when using long string resource keys in our Android and iOS apps and although we have fixed it with a very easy Perl command, perhaps it's of use for other developers using this awesome tool!

Twine version:
v1.0.6

Description:
Twine can't import / consume items from a PO file when the msgctxt uses more than one line.
Generating PO files with Twine doesn't use multiline strings, but exporting translations from other sources (e.g. Transifex) do use the multiline strings approach (which are according to the "gettext" spec, see https://www.gnu.org/software/gettext/manual/html_node/PO-Files.html).

The following example is taken from a PO file exported from Transifex:

#. "Help item message about the usage of the Channel list item."
msgctxt ""
"contextSensitiveHelp_channelList_channelListScreen_channelListItem_message"
msgid ""
"These are all the available channel lists. Select a channel list by tapping "
"it."
msgstr ""
"Това са всички налични Списъци с канали. Избери конкретен Списък с канали, "
"като натиснеш бутона."

As you can see in this example, the multiline approach is taken for all 3 properties.
Twine simply skips this when calling the twine command:

twine consume-localization-file /BG/twine.txt Example.po --lang bg --format gettext

Transforming the entry (manually or with a Perl command) to remove the multiline msgctxt string, results in:

#. "Help item message about the usage of the Channel list item."
msgctxt "contextSensitiveHelp_channelList_channelListScreen_channelListItem_message"
msgid ""
"These are all the available channel lists. Select a channel list by tapping "
"it."
msgstr ""
"Това са всички налични Списъци с канали. Избери конкретен Списък с канали, "
"като натиснеш бутона."

This quick and easy change allows Twine to successfully consume the PO file to the twine.txt:

[contextSensitiveHelp_channelList_channelListScreen_channelListItem_message]
		en = These are all the available channel lists. Select a channel list by tapping it.
		comment = Help item message about the usage of the Channel list item.
		bg = Това са всички налични Списъци с канали. Избери конкретен Списък с канали, като натиснеш бутона.

Note that twine doesn't print warnings about the skipped entries either, so we've only discovered this error after delivering the app to the customer who wanted to verify the new translations.

Kind regards,
Davy

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions