Source text won't update

117 views Asked by At

I have a dictionary in Django and one of the strings that's translated won't get updated in the .po file even though it's changed in the model.

What i've done is to change a badge condition (gamificated site) from:

'Wrote %(arg_0)d comments to %(arg_1)d different questions (comments has got at least %(arg_2)d points)'

to...

'Wrote %(arg_0)d comments to %(arg_1)d different questions'

When I open the .po file with Poedit the old condition is still there as source text, even though it's changed in the model. When I change the source text (i.e. removes the last arg) in Poedit and save the file the arg comes back and the editor complains about the arg is missing in the translated text.

What am I doing wrong?

code from the model (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
1

There are 1 answers

0
Ludwik Trammer On BEST ANSWER

To sync your .po files content with strings from your source code, do this:

python manage.py makemessages -a

You seem to think that you don't need to do this, because you use Poedit and "Poedit converts .po files to .mo files". Compiling .po files to .mo files is an entirely different process, and a different Django management command - python manage.py compilemessages.

First you get strings from your source code to .po files with makemessages, then you translate them, and only then you compile them using compilemessages.