1

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

1 Answers1

1

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.

Thomas Kremmel
  • 14,575
  • 26
  • 108
  • 177
  • JUst to make sure: Should they be at MY_PROJECT/blog/locale/es/LC_MESSAGES or at MY_PROJECT/locale/es/LC_MESSAGES?? – Mario Ricardo Osorio Oct 04 '13 at 15:51
  • None of the indicated paths worked for me. I even tried copying the translation files to BOTH folders. What am I missing here? naming conventions? The files are named like the originals django.po and django.mo – Mario Ricardo Osorio Oct 04 '13 at 16:28
  • I tried the LOCALE_PATHS and did not wor work either. Please take a look at the [this paste](http://pastebin.com/c8pvKLXQ) that shows my directory tree and value of LOCALE_PATHS at the edn of settings.py – Mario Ricardo Osorio Oct 04 '13 at 22:42
  • are you using django 1.4+? then I would first recommend that you adapt your directory structure to match the structure proposed there: http://stackoverflow.com/questions/11216829/django-directory-structure – Thomas Kremmel Oct 05 '13 at 09:53
  • also make sure that LOCALE_PATHS is the absolute (= the entire) path. you only used the relative path. https://docs.djangoproject.com/en/dev/ref/settings/#locale-paths – Thomas Kremmel Oct 05 '13 at 10:03