我在 Django 中有一本字典,其中一个已翻译的字符串不会在 .po 文件中更新,即使它在模型中已更改。
我所做的是从以下位置更改徽章条件(游戏化网站):
'Wrote %(arg_0)d comments to %(arg_1)d different questions (comments has got at least %(arg_2)d points)'
至...
'Wrote %(arg_0)d comments to %(arg_1)d different questions'
当我使用 Poedit 打开 .po 文件时,旧条件仍然作为源文本存在,即使它在模型中已更改。当我在 Poedit 中更改源文本(即删除最后一个arg)并保存文件时,arg回来了,编辑器抱怨翻译文本中缺少arg 。
我究竟做错了什么?
模型中的代码(badges.py):
class Commentor_Badge(AbstractBadge):
badge_name='Commentor'
description=_('Wrote %(arg_0)d comments to %(arg_1)d different questions')
#description=_('Wrote %(arg_0)d comments to %(arg_1)d different questions (comments has got at least %(arg_2)d points)')
trigger_model=get_model("comments","Comment")
@classmethod
def listener(cls,instance,**kwargs):
user=instance.user
super(Commentor_Badge,cls).listener(user=user,**kwargs)
@classmethod
def check_condition_met(cls,params,user):
num_comments=params[0]
num_questions=params[1]
#num_wtfs=params[2]
question_type=get_model("contenttypes","ContentType").objects.get_for_model(get_model("QAManager","Question"))
all_comms=get_model("comments","Comment").objects.filter(user=user,content_type=question_type)
diff_comms=all_comms.values('object_pk').distinct().order_by()
return all_comms.count()>=num_comments and diff_comms.count()>=num_questions
@classmethod
def create_badge_in_db(cls):
super(Commentor_Badge,cls).create_badge_in_db('Kommenterare',"{'bronze':(5,5,0),'silver':(20,10,0),'gold':(100,50,0),}")
# super(Commentor_Badge,cls).create_badge_in_db('Kommenterare',"{'bronze':(5,5,2),'silver':(20,10,5),'gold':(100,50,5),}")
@classmethod
def get_description(cls,level):
dic=cls.get_description_args(level)
return _('Wrote %(arg_0)d comments to %(arg_1)d different questions')%dic
#return _('Wrote %(arg_0)d comments to %(arg_1)d different questions (comments has got at least %(arg_2)d points)')%dic