Ticket #1668: make-messages.diff

File make-messages.diff, 994 bytes (added by Evren Esat Özkan <sleytr@…>, 17 years ago)

make-messages.py patch to add app names to django.po file

  • make-messages.py

     
    148148            open(pofile, 'wb').write(msgs)
    149149            os.unlink(potfile)
    150150
     151def make_app_names():
     152    try:
     153        tmp_file=open('./templates/app_names.html','w')
     154    except IOError:
     155        return False
     156    app_names=set()
     157    path=os.path.split(os.getcwd())
     158    sys.path.insert(0,path[0])
     159    os.environ["DJANGO_SETTINGS_MODULE"]=path[1]+'.settings'
     160    settings._import_settings()
     161    from django.db.models import get_models
     162    for m in get_models(): app_names.add(m._meta.app_label.title())
     163    p1,p2='\"%}','{% trans \"'
     164    tmp_file.write(p2+(p1+p2).join(app_names)+p1)
     165    tmp_file.close()
     166    os.environ["DJANGO_SETTINGS_MODULE"]=''
     167    return tmp_file
     168
    151169if __name__ == "__main__":
     170    tmp_file=make_app_names()
    152171    make_messages()
     172    if tmp_file: os.remove(tmp_file.name)
Back to Top