运行manage.py compilemessages
时遇到语法错误。我打开.po文件,发现某些行的开头没有#:
。在源文件中正确实现了翻译代码。它被替换为空格。我已经检查了源文件的翻译代码,并已正确实施。是什么原因造成的?预先感谢!
预期的行代码:
#: .\source\of\the\file.py
实际行代码:
.\source\of\the\file.py
源文件:
class Region(AbstractOrganization):
name = models.CharField(
max_length=200,
help_text=_("The name of the region")
)
slug = AutoSlugField(
populate_from=['name'],
)
region_group = models.ForeignKey(
RegionGroup,
verbose_name=_("Region Group"),
on_delete=models.CASCADE,
related_name='regions',
blank=True,
null=True,
)
country = models.ManyToManyField(
Country,
verbose_name=_("Country"),
related_name='regions',
through='M2MRegionCountry',
blank=False,
)
def __str__(self):
return f'{self.name}'
class Meta:
verbose_name = _('Region')
ordering = ('region_group', 'name',)