django - 更改 Django 语言文件的最佳方法是什么

标签 django localization internationalization locale

我想更改语言文件中的一些字符串以适应我在 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/

相关文章:

django - 在 Django 项目中,python 类的最佳位置是什么?

使用 varchar_pattern_ops 索引而不是 pkey 索引的 Django-Postgres WHERE 查询

swift - 让 Str = 字符串(格式 : "لديك d٪ ثانية متبقية للاتصال", 秒)

google-chrome - 如何在所有Google(国际)页面上加载内容脚本?

Django:在不使用语言 session /cookie的情况下翻译字符串

android - 用于应用内订阅收据检查的 Google Developer API(权限不足问题)

javascript - 具有多个输入的 jQuery 自动完成 - django-dynamic-formset

GWT 动态语言环境

android:以编程方式本地化动态字符串

facebook open graph crawler 没有向我发送 db_locale