views:

157

answers:

1

I want to change some of the strings in the language file for my language in Django. I can of course just change the .po file, but that seems unwise because if I update Django the file will be changed again. What is the best way to do this?

I don't care if the solution is for the specific app I'm working on or for my entire Django installation.

+4  A: 

From the docs:

Django looks for translations by following this algorithm:

  • 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 just create a localedirectory for your project and overwrite your messages in there.

The MYYN
Thank you! I actually did read the docs but somehow did not understand that this applied to my situation, though I must admit now that the docs are clear. For people who may find this with a google search: I copied the locale\mylocale\LC_MESSAGES folder from the django dir to the root of my project dir (keep the directory structure), edited the django.po file, and then ran django-admin.py compilemessages from the root of my project dir. That worked after I installed gettext on Windows, as described in the docs.
charlotte