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

Request for feature #7

Open
barseghyanartur opened this issue Dec 18, 2013 · 1 comment
Open

Request for feature #7

barseghyanartur opened this issue Dec 18, 2013 · 1 comment

Comments

@barseghyanartur
Copy link

Please, add support for multi-line strings.

This does not work:

_("""
Line 1
Line 2
Line 3
""")

This works:

_("""Line 1 """
"""Line 2"""
"""Line 3""")

And it would be nice if it works in both cases.

mauritsvanrees added a commit that referenced this issue Dec 31, 2013
@mauritsvanrees
Copy link
Member

This looks tricky to solve. The extraction does work a bit, so it ends up in the generated .pot file when you use rebuild-pot, but the resulting file has errors, for example like this when I try it out in the Poi domain:

$ msgfmt -c locales/Poi.pot 
locales/Poi.pot:22: end-of-line within string
locales/Poi.pot:21: missing 'msgstr' section
locales/Poi.pot:22:5: syntax error
locales/Poi.pot:23: keyword "Line" unknown
locales/Poi.pot:24: keyword "Line" unknown
locales/Poi.pot:26: end-of-line within string
msgfmt: found 6 fatal errors

That is because this bad syntax is generated:

msgid "
Line 1
Line 2
Line 3
"
msgstr ""

This also means that the extracted msgid does not end up in the .po files.

Apparently the correct output would be:

msgid ""
"\n"
"Line 1\n"
"Line 2\n"
"Line 3\n"
msgstr ""

This may be fixable in extract.py or pygettext.py. Pull requests are welcome.

Workaround: use a one-line msgid and specify the multi-line text as the default, like in ad85bed.

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