使 Django 本地化

Django 的很多部分,比如后台站点和认证错误提示都是国际化的。这意味着它们根据使用者的语言展示不同的信息。为此,Django 使用了和 Django 应用相同的国际化和本地化基础设施,在 i18n documentation 中介绍。

翻译

翻译内容由全球的 Django 用户提供。协调工作由 Transifex 负责。

If you find an incorrect translation or want to discuss specific translations, go to the Django project page. If you would like to help out with translating or adding a language that isn’t yet translated, here’s what to do:

  • Introduce yourself on the Django internationalization forum.

  • 确保你已经阅读了 Django 翻译的特性 的注意点。

  • Transifex 注册并访问 Django project page

  • Django project page,选择你期望翻译的语言, ——如果该语言不存在——点击“Request language”链接,选择合适的语言,请求创建一个新的语言团队。

  • 接着,点击“加入团队”按钮成为团队的一员。每个团队至少拥有一位协调员,负责管理团队的请求。你可以联系团队协调员,了解程序性问题或翻译进度。

  • Once you are a member of a team choose the translation resource you want to update on the team page. For example, the “core” resource refers to the translation catalog that contains all non-contrib translations. Each of the contrib apps also has a resource (prefixed with “contrib”).

    备注

    更多关于如何使用 Transifex 的信息,阅读 Transifex User Guide

来自 Transifex 的翻译只会在发布新 term:`feature release ` 时集成进 Django 仓库。我们尝试在以下某个 :term:`patch release ` 中再次更新它们,但这取决于翻译管理器的可用性。 因此,请不要错过字符串冻结期(发布候选版和功能发布版之间),借此机会完成并修复您的语言翻译!

格式

你页可以阅读 conf/locale/<locale>/formats.py。该文件介绍了基于你所在地的日期,时间和数字的格式。参考 本地格式化 获得更多信息。

格式文件并不由 Transifex 管理。要修改它们的话,你必须对比当前 Django 代码 创建一个补丁 ,就像修改其它代码一样:

  • Create a diff against the current Git main branch.
  • 在 Django 的工单系统创建一个工单,设置其 Component 字段为 Translations,并附上补丁。

文档

还有翻译文档的机会,虽然这是一项浩大的工程(事先提醒!)。同样,我们使用 Transifex tool。只要 docs/intro/* 部分的全部文档被翻译,你就能在 https://docs.djangoproject.com/<language_code>/ 见到该语言的版本。中文翻译团队官网:https://www.djangodocs.com/

一旦翻译发布,Transifex 的更新版本将不定期地移植到 django/django-docs-translations 存储库和文档网页。只更新最新稳定的 Django 版本的翻译。