문제

I want to translate a string with PyGettext. The problems is, the string is very long. So I had to split it into multiple lines:

print _("Some text... foo bar foo bar foo bar ..... blah blah" + \
        "More text")

But I get the following error message:

*** ../myApp:1: Seen unexpected token "+"

How can I write a string like that? I don't want to write it in one line because the code will look terrible. I also don't want to use three quotation marks (""") because the translation will be messed up with a way too many spaces....

도움이 되었습니까?

해결책

The Python compiler concatenates adjacent string literals.

print _("Some text... foo bar foo bar foo bar ..... blah blah"
        "More text")

...

>>> print 'a' 'b'
ab
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top