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

Consuming PO file skips multiline msgctxt entries #288

Open
DJansse opened this issue Aug 28, 2019 · 1 comment
Open

Consuming PO file skips multiline msgctxt entries #288

DJansse opened this issue Aug 28, 2019 · 1 comment

Comments

@DJansse
Copy link

DJansse commented Aug 28, 2019

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

@ovoitenk
Copy link

ovoitenk commented Nov 9, 2020

Also encountered this issue, found the solution by using msgcat command with an attribute --no-wrap applied to the PO file. https://www.gnu.org/software/gettext/manual/html_node/msgcat-Invocation.html

You need to install GNU gettext utilities to use this command https://www.gnu.org/software/gettext/manual/gettext.html

Example usage :
msgcat file.po --output=file.po --no-wrap

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