0

I have searched for an answer before posting this question. There is a bunch of long strings that are split in the following way and need to be translated

string = "This is a very long " \
          "string to be translated"

after marking

string = _("This is a very long " \
          "string to be translated")

the resulting .po file keeps only the first part of the string

msgid "This is a very long "
msgstr ""

So, is there any way to make this work, preferably without messing up the code very much...

Thank you

unicorn
  • 139
  • 1
  • 9
  • I tried the triple quote, which worked, but the thing is the string must not contain \r\n characters (which are added using triple quotes)... – unicorn Apr 15 '15 at 12:23

1 Answers1

0

Per the makemessages documentation, when creating messages, use the --no-wrap option.

My Model

class Test(models.Model):
    test = models.CharField(
        max_length=20,
        null=True,
        blank=True,
        verbose_name=_(
            'This is a super long description that should never really exist '
            'but it does. Should not wrap.'
        )
    )

./manage.py makemessages --locale=de --no-wrap

Without --no-wrap it looked like this:

#: test/models.py:16
msgid ""
"This is a super long description that should never really exist but it does. "
"Should not wrap."
msgstr ""

After adding the --no-wrap it looks like this:

#: test/models.py:16
msgid "This is a super long description that should never really exist but it does. Should not wrap."
msgstr ""
Michael B
  • 5,148
  • 1
  • 28
  • 32
  • Well actually my problem is that i don't make even the first case to work. Only the first line is extracted. – unicorn Apr 19 '15 at 09:06