У меня есть словарь в Django, и одна из строк, которые были переведены, не будет обновляться в файле .po, даже если она изменена в модели.Исходный текст не обновляется
Что я сделал, чтобы изменить состояние значок (gamificated сайт) от:
'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'
При открытии файла .po с PoEdit старой условие все еще присутствует в качестве исходного текста, хотя оно изменено в модели. Когда я меняю исходный текст (т. Е. Удаляет последний arg) в Poedit и сохраняет файл 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
Вы проверили, что poedit (я предполагаю, что вы используете poedit) генерирует файл перевода при сохранении? Подробнее см. здесь http://supertuxkart.sourceforge.net/translating_with_poedit –
@ LiamSorsby Дело в том, что он не будет сохранять (и, следовательно, генерировать файл .mo) из-за отсутствия _arg_ в переводе. Даже если я удалю _arg_ из исходного текста и сохраню его, вернется. – holyredbeard
Вы запустили makemessages? Вы не говорите об этом. – jpic