我在发布这个问题之前已经找到了答案。 有一堆长字符串按以下方式拆分,需要翻译
string = "This is a very long " \
"string to be translated"
标记后
string = _("This is a very long " \
"string to be translated")
生成的.po文件只保留字符串的第一部分
msgid "This is a very long "
msgstr ""
那么,有没有办法让这项工作成功,最好不要搞砸代码......
谢谢
答案 0 :(得分:0)
根据makemessages文档,在创建消息时,请使用--no-wrap选项。
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
没有--no-wrap
,它看起来像这样:
#: test/models.py:16
msgid ""
"This is a super long description that should never really exist but it does. "
"Should not wrap."
msgstr ""
添加--no-wrap
后,它看起来像这样:
#: test/models.py:16
msgid "This is a super long description that should never really exist but it does. Should not wrap."
msgstr ""