开发者

Django translation and py2exe

I have just compiled my django application to an exe using py2exe. But I don't have any idea how to make django translation work (I mean built in translation, not my own translation files). There is LANGUAGE_CODE set in my settings file, I also tried importing django.utils.translation and django.conf.locale.pl in py2exe options includes. I also tried but I didn't manage to import LC_MESSAGE files from django/conf/locale/pl using data_files in py2exe setup. I think LC_MESSAGE files are the main problem but I don't know how to put them into my c开发者_如何学运维ompilation. Is it possible to change py2exe compiled project language? How and how import language files? My py2exe setup files are similar to http://misunderstandings.wordpress.com/2008/06/26/django-desktop-app/ .

Edit: I post here code lines, where I'm trying import translation util:

'django.utils.translation.*',
'django.conf.locale.pl.*',

I have also tried:

'django.utils.translation.trans_null',
'django.utils.translation.trans_real',
'django.utils.translation.__init__',
'django.conf.locale.pl.__init__',
'django.conf.locale.pl.formats',

But as I had though it doesn't matter. In build\bdist.win-amd64\winexe\collect-2.7\django there are both folders conf/locale and utils/translation with proper files. But of course not LC_MESSAGE folder. I try to import it using:

py2exe_data_files += add_path_tree( python_path, 'lib\site-packages\django\conf\locale\pl' )

As I checked it finds files in this folder but do nothing with them.

My setup file (it's long so I put it on the sourcepod): http://www.sourcepod.com/fcmpkn17-5519

Maybe I forgot to include something but I don't have any idea what could it be..


Finally solved! And in so easy way..

As https://docs.djangoproject.com/en/dev/topics/i18n/deployment/ says we can put locale files into different localizations. So I copy all locale files from django/conf to my template folder.

This line of my py2exe setup.py copy it to my compilation with templates:

py2exe_data_files += add_path_tree( '', 'templates' )

The last thing to do is to set locale path in settings file:

LOCALE_PATHS = (
'templates/locale',
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜