I'm giving my first steps with python/django/mezzanine so please bear with me.

I modified a translation file and compiled it ok.

The translated file belongs to mezzanine's blog application and the only place I found out I could place it to test was at the blog app's locale folder (~/MY_VIRTUAL_ENV/lib/python2.7/site-packages/mezzanine/blog/locale/es/LC_MESSAGES).

It worked fine, but my guts tell me there has to be a way I can have this file(s) in some other location WITHIN my own mezzanine application so:

I can easily maintain it and
I don't have to keep my whole virtual environment in my SCM's repository.

Am I in the right track? If so, where should I place my new own translation files?

Thanks a lot in advanced

有帮助吗?

解决方案

Never ever place your virtual environment into your repository. It makes no sense. You will somewhen deploy your application, and besides it is a good approach to use virtual environments on your server, you might also deploy your app on Heroku or another PaaS, and then you will only need the app source in your repository.

Django 1.5 picks up the translation files in the following order:

  • First, it looks for a locale directory in the application directory of the view that’s being called. If it finds a translation for the selected language, the translation will be installed.

  • Next, it looks for a locale directory in the project directory. If it finds a translation, the translation will be installed.

  • Finally, it checks the Django-provided base translation in django/conf/locale.

So in your case I assume that the blog application is a package installed via pip (therefore it is in the site-packages folder) you can choose the second option and create a locale directory in your project directory, and put your translation in there.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top