开发者

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开发者_JAVA技巧 installation.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜