我想更改语言文件中的一些字符串以适应我在 Django 中的语言。我当然可以只更改 .po 文件,但这似乎不明智,因为如果我更新 Django,该文件将再次更改。做这个的最好方式是什么?
我不在乎该解决方案是针对我正在开发的特定应用程序还是针对我的整个 Django 安装。
最佳答案
来自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.
因此,只需为您的项目创建一个locale
目录并覆盖其中的消息即可。
关于django - 更改 Django 语言文件的最佳方法是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2041064/