charlotte
charlotte

Reputation: 23

What is the best way to change the language files in Django

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.

Upvotes: 2

Views: 866

Answers (1)

miku
miku

Reputation: 188054

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.

Upvotes: 5

Related Questions