PEP 545 - Python文档翻译







得体 传神 有内涵

  • PEP 545 -- Python Documentation Translations

    PEP 545 - Python文档翻译

  • Abstract


  • The intent of this PEP is to make existing translations of the Python Documentation more accessible and discoverable. By doing so, we hope to attract and motivate new translators and new translations.


  • Translated documentation will be hosted on Examples of two active translation teams:


  • French


  • Japanese


  • will redirect to会重定向到。

  • Sources of translated documentation will be hosted in the Python organization on GitHub: Contributors will have to accept a Documentation Contribution Agreement.


  • Motivation


  • On the French #python-fr IRC channel on freenode, it's not rare to meet people who don't speak English and so are unable to read the Python official documentation. Python wants to be widely available to all users in any language: this is also why Python 3 supports any non-ASCII identifiers:

    在freenode上的法语#python-fr IRC频道上,并不难遇到因不会说英语而读不懂Python官方文档的人。 Python希望被广泛使用无论用户使用哪种语言:这也是Python 3支持任何non-ASCII的原因:

  • There are at least 4 groups of people who are translating the Python documentation to their native language (French [16] [17] [18], Japanese [19] [20], Spanish [21], Hungarian [27] [28]) even though their translations are not visible on d.p.o. Other, less visible and less organized groups, are also translating the documentation, we've heard of Russian [26], Chinese and Korean. Others we haven't found yet might also exist. This PEP defines rules describing how to move translations on so they can easily be found by developers, newcomers and potential translators.

    至少有4个团队正在将Python文档翻译成他们的母语(法语[16] [17] [18],日语[19] [20],西班牙语[21],匈牙利语[27] [28] )即使他们的翻译在d.p.o上不可见 ,也有其他潜在的和不太有组织的团队也在进行翻译,我们听说过俄语[26],中文和韩文。其他我们不知道的团队也可能存在。本PEP定义了描述如何在docs.python.org上发布翻译成果的规则,以便开发人员,新人和潜在翻译人员可以轻松参与。

  • The Japanese team has (as of March 2017) translated ~80% of the documentation, the French team ~20%. French translation went from 6% to 23% in 2016 [13] with 7 contributors [14], proving a translation team can be faster than the rate the documentation mutates.

    日本团队已经翻译了约80%的文件(截至2017年3月),法国队~20%。 2016年法语翻译从6%上升到23%[13],有7位贡献者[14],证明翻译团队的速度可能比文档变异的速度快。

  • Quoting Xiang Zhang about Chinese translations:

    引用Xiang Zhang在中文翻译中遇到的情况:

  • I have seen several groups trying to translate part of our official doc. But their efforts are disperse and quickly become lost because they are not organized to work towards a single common result and their results are hold anywhere on the Web and hard to find. An official one could help ease the pain.


  • Rationale


  • Translation


  • Issue tracker


  • Considering that issues opened about translations may be written in the translation language, which can be considered noise but at least is inconsistent, issues should be placed outside (b.p.o).


  • As all translation must have their own GitHub project (see Repository for Po Files), they must use the associated GitHub issue tracker.


  • Considering the noise induced by translation issues redacted in any languages which may beyond every warnings land in b.p.o, triage will have to be done. Considering that translations already exist and are not actually a source of noise in b.p.o, an unmanageable amount of work is not to be expected. Considering that Xiang Zhang and Victor Stinner are already triaging, and Julien Palard is willing to help on this task, noise on b.p.o is not to be expected.

    考虑由于语言问题b.p.o对这种噪音的警告不是每个译者都能知晓,所以问题分类的工作也必须进行.考虑到翻译已经开始并且实际上不是b.p.o中的噪音源,所以不会出现不可预期的工作量,而且考虑到Xiang Zhang 和Victor Stinner已经在进行分类,而且Julien Palard愿意帮助他们,噪音将会是小概率事件

  • Also, language team coordinators (see Language Team) should help with triaging b.p.o by properly indicating, in the language of the issue author if required, the right issue tracker.


  • Branches


  • Translation teams should focus on last stable versions, and use tools (scripts, translation memory, …) to automatically translate what is done in one branch to other branches.

    翻译团队应该关注最后的稳定版本,并使用工具(脚本,translation memory......)自动将一个分支中完成的内容转换为其他分支。

  • Note


  • Translation memories are a kind of database of previously translated paragraphs, even removed ones. See also Sphinx Internationalization.

    Translation memory是一种先前翻译过的段落的数据库,甚至是已删除的段落。另见Sphinx国际化。

  • The three currently stable branches that will be translated are [12]: 2.7, 3.5, and 3.6. The scripts to build the documentation of older branches needs to be modified to support translation [12], whereas these branches now only accept security-only fixes.


  • The development branch (master) should have a lower translation priority than stable branches. But docsbuild-scripts should build it anyway so it is possible for a team to work on it to be ready for the next release.


  • Hosting


  • Domain Name, Content negotiation and URL

    域名,Content negotiation和URL

  • Different translations can be identified by changing one of the following: Country Code Top Level Domain (CCTLD), path segment, subdomain or content negotiation.

    可以通过更改以下内容之一来访问不同的语言:国家/地区代码顶级域(CCTLD),路径,子域或Content negotiation。

  • Buying a CCTLD for each translations is expensive, time-consuming, and sometimes almost impossible when already registered, this solution should be avoided.


  • Using subdomains like "" or "" is possible but confusing ("is it or"). Hyphens in subdomains like is uncommon and SEOMoz [23] correlated the presence of hyphens as a negative factor. Usage of underscores in subdomain is prohibited by the RFC1123 [24], section 2.1. Finally, using subdomains means creating TLS certificates for each language. This not only requires more maintenance but will also cause issues in language switcher if, as for version switcher, we want a preflight to check if the translation exists in the given version: preflight will probably be blocked by same-origin-policy. Wildcard TLS certificates are very expensive.

    像“”或“”这样的子域名是可行的,但使用时会令人困惑(“是还是”)。像pt-br.doc.python.org这样的子域中的连字符并不常见,SEOMoz [23]将连字符看作负面因素。 而RFC1123 [24]第2.1节禁止在子域中使用下划线。最后,使用子域需要为每种语言创建TLS证书。这不仅需要更多的维护,而且还会导致官方文档语种选择功能出现问题,如果对于版本切换器,我们需要预检给定版本的翻译是否存在:预检可能会被同源策略阻止。而通配符TLS证书非常昂贵。

  • Using content negotiation (HTTP headers Accept-Language in the request and Vary: Accept-Language) leads to a bad user experience where they can't easily change the language. According to Mozilla: "This header is a hint to be used when the server has no way of determining the language via another way, like a specific URL, that is controlled by an explicit user decision." [25]. As we want to be able to easily change the language, we should not use the content negotiation as a main language determination, so we need something else.

    使用content negotiation (请求中的HTTP标头Accept-Language和Vary:Accept-Language)会导致用户体验不佳,无法轻松更改语言。根据Mozilla的说法:“当服务器无法通过其他方式确定语言时,此标头可以作为一种判断依据,而像特定的URL,用户可以明确地进行控制。” [25]。由于我们希望能够轻松更改语言,因此我们不应将content negotiation 作主要语言决策,所以还需要其他方式。

  • Last solution is to use the URL path, which looks readable, allows for an easy switch from a language to another, and nicely accepts hyphens. Typically something like: "" or, by using a hyphen: "".


  • As for the version, sphinx-doc does not support compiling for multiple languages, so we'll have full builds rooted under a path, exactly like we're already doing with versions.


  • So we can have "" or "". A question that arises is: "Does the language contain multiple versions or does the version contain multiple languages?". As versions exist in any case and translations for a given version may or may not exist, we may prefer "", but doing so scatters languages everywhere. Having "/de/3.6/" is clearer, meaning: "everything under /de/ is written in German". Having the version at the end is also a habit taken by readers of the documentation: they like to easily change the version by changing the end of the path.

    我们可以选择的是“”或“”。问题来了:“语言是包含多个版本还是版本包含多种语言?”。由于版本在任何情况下都存在,并且给定版本的翻译可能存在也可能不存在,我们可能更喜欢“”,但这样做语言会被分散。 “/de/3.6/”更清晰,意思是:“/ de /下的所有东西都用德语写成”。最终版本依据文档读者的习惯:他们喜欢通过改变路径的末尾来轻松更改版本。

  • So we should use the following pattern: "".


  • The current documentation is not moved to "/en/", instead "" will redirect to "".

    当前文档不存在路径“/ en /”,“”将会重定向到“”。

  • Language Tag


  • A common notation for language tags is the IETF Language Tag [3] [4] based on ISO 639, although gettext uses ISO 639 tags with underscores (ex: pt_BR) instead of dashes to join tags [5] (ex: pt-BR). Examples of IETF Language Tags: fr (French), ja (Japanese), pt-BR (Orthographic formulation of 1943 - Official in Brazil).

    语言标签是基于ISO 639的IETF语言标签[3] [4],尽管gettext使用带下划线的ISO 639标签(例如:pt_BR)而不是破折号[5](例如:pt-BR) )。 IETF语言标签的示例:fr(法语),ja(日语),pt-BR(1943年的正交公式 - 巴西官方)。

  • It is more common to see dashes instead of underscores in URLs [6], so we should use IETF language tags, even if sphinx uses gettext internally: URLs are not meant to leak the underlying implementation.

    在URL [6]中更常见的是破折号而不是下划线,因此我们应该使用IETF语言标记,即使sphinx在内部使用了gettext :URL规则并不意味着公开底层实现。

  • It's uncommon to see capitalized letters in URLs, and doesn't use any, so it may hurt readability by attracting the eye on it, like in: "". RFC 5646 (Tags for Identifying Languages (IETF)) section-2.1 [7] states that tags are not case sensitive. As the RFC allows lower case, and it enhances readability, we should use lowercased tags like pt-br.

    在URL中看到大写字母并不常见,而docs.python.org不使用任何大写字母,所以它可能会吸引人的注意力,从而影响可读性,例如:“ /3.6/library/stdtypes.html”。 RFC 5646(标识语言标记(IETF))第2.1节[7]指出标记不区分大小写。所以RFC允许小写,并且它增强了可读性,我们应该使用像pt-br这样的小写标签。

  • We may drop the region subtag when it does does not add distinguishing information, for example: "de-DE" or "fr-FR". (Although it might make sense, respectively meaning "German as spoken in Germany" and "French as spoken in France"). But when the region subtag actually adds information, for example "pt-BR" for "Portuguese as spoken in Brazil", it should be kept.

    当区域子标签没有区别作用时,我们可以删除它,例如:“de-DE”或“fr-FR”。 (虽然它可能有意义,分别意为“德语在德国使用”和“法语在法国使用”)。但是当区域子标签实际上添加了信息时,例如“pt-BR”代表“巴西语中的葡萄牙语”,它应该被保留。

  • So we should use IETF language tags, lowercased, like /fr/, /pt-br/, /de/ and so on.

    所以我们应该使用IETF语言标签,小写,如/ fr /,/ pt-br /,/ de /等等。

  • Fetching And Building Translations


  • Currently docsbuild-scripts are building the documentation [8]. These scripts should be modified to fetch and build translations.


  • Building new translations is like building new versions so, while we're adding complexity it is not that much.


  • Two steps should be configurable distinctively: Building a new language, and adding it to the language switcher. This allows a transition step between "we accepted the language" and "it is translated enough to be made public". During this step, translators can review their modifications on d.p.o without having to build the documentation locally.


  • From the translation repositories, only the .po files should be opened by the docsbuild-script to keep the attack surface and probable bug sources at a minimum. This means no translation can patch sphinx to advertise their translation tool. (This specific feature should be handled by sphinx anyway [9]).

    在翻译的repositories中,docsbuild-script脚本只应该打开.po文件,以便将攻击面和可能的错误源保持在最低限度。这意味着没有任何翻译可以修补sphinx来宣传他们的翻译工具。 (无论如何,这个特定的功能应该由sphinx处理[9])。

  • Community


  • Mailing List


  • The doc-sig [30] mailing list will be used to discuss cross-language changes on translated documentation.

    doc-sig [30]邮件列表用于讨论翻译文档的跨语言更改。

  • There is also the i18n-sig list but it's more oriented towards i18n APIs [1] than translating the Python documentation.

    还有i18n-sig列表,但它更倾向于i18n API [1],而不是翻译Python文档。

  • Chat


  • Due to the Python community being highly active on IRC, we should create a new IRC channel on freenode, typically #python-doc for consistency with the mailing list name.


  • Each language coordinator can organize their own team, even by choosing another chat system if the local usage asks for it. As local teams will write in their native languages, we don't want each team in a single channel. It's also natural for the local teams to reuse their local channels like "#python-fr" for French translators.


  • Repository for PO Files


  • Considering that each translation team may want to use different translation tools, and that those tools should easily be synchronized with git, all translations should expose their .po files via a git repository.

    考虑到每个翻译团队可能想要使用不同的翻译工具,这些工具应该很容易同步到git,所有翻译都应该通过git repository公开他们的.po文件。

  • Considering that each translation will be exposed via git repositories, and that Python has migrated to GitHub, translations will be hosted on GitHub.


  • For consistency and discoverability, all translations should be in the same GitHub organization and named according to a common pattern.


  • Given that we want translations to be official, and that Python already has a GitHub organization, translations should be hosted as projects of the Python GitHub organization [31].

    鉴于我们希望翻译成为官方翻译,并且Python已经有一个GitHub组织,翻译应该作为Python GitHub组织的项目托管[31]。

  • For consistency, translation repositories should be called python-docs-LANGUAGE_TAG [22], using the language tag used in paths: without region subtag if redundant, and lowercased.

    为了保持一致性,翻译repositories 应该被称为python-docs-LANGUAGE_TAG [22],使用路径中使用的语言标记:如果是region子标记冗余则删除,并且使用小写。

  • The docsbuild-scripts may enforce this rule by refusing to fetch outside of the Python organization or a wrongly named repository.


  • The CLA bot may be used on the translation repositories, but with a limited effect as local coordinators may synchronize themselves with translations from an external tool, like transifex, and lose track of who translated what in the process.

    CLA机器人可以在翻译 repositories中使用,但效果有限,因为本地协调员可以将自己与来自外部工具(如transifex)的翻译同步,并且无法跟踪谁在翻译过程中的内容。

  • Versions can be hosted on different repositories, different directories or different branches. Storing them on different repositories will probably pollute the Python GitHub organization. As it is typical and natural to use branches to separate versions, branches should be used to do so.

    版本托管的形式可以选择在不同的 repositories,不同的目录或不同的分支上。将它们存储在不同的 repositories中可能会污染Python GitHub组织。而使用分支来分离版本是典型和自然的,因此应该使用分支来实现。

  • Translation tools


  • Most of the translation work is actually done on Transifex [15].


  • Other tools may be used later like and


  • Documentation Contribution Agreement


  • Documentation does require a license from the translator, as it involves creativity in the expression of the ideas.


  • There's multiple solutions, quoting Van Lindberg from the PSF asked about the subject:

    有多种解决方案,引用PSF的Van Lindberg询问了这个主题:

  • Docs should either have the copyright​ assigned or be under CCO. A permissive software license (like Apache or MIT) would also get the job done, although it is not quite fit for task.


  • The translators should either sign an agreement or submit a declaration of the license with the translation.


  • We should have in the project page an invitation for people to contribute under a defined license, with acceptance defined by their act of contribution. Such as:


  • "By posting this project on Transifex and inviting you to participate, we are proposing an agreement that you will provide your translation for the PSF's use under the CC0 license. In return, you may noted that you were the translator for the portion you translate. You signify acceptance of this agreement by submitting your work to the PSF for inclusion in the documentation."


  • It looks like having a "Documentation Contribution Agreement" is the most simple thing we can do as we can use multiple ways (GitHub bots, invitation page, …) in different context to ensure contributors are agreeing with it.


  • Language Team


  • Each language team should have one coordinator responsible for:


  • Managing the team.


  • Choosing and managing the tools the team will use (chat, mailing list, …).


  • Ensure contributors understand and agree with the documentation contribution agreement.


  • Ensure quality (grammar, vocabulary, consistency, filtering spam, ads, …).


  • Redirect issues posted on b.p.o to the correct GitHub issue tracker for the language.


  • Alternatives


  • Simplified English


  • It would be possible to introduce a "simplified English" version like wikipedia did [10], as discussed on python-dev [11], targeting English learners and children.

    有可能引入像维基百科那样的“简化英语”版本[10],如python-dev [11]所述,以方便英语学习者和儿童。

  • Pros: It yields a single translation, theoretically readable by everyone and reviewable by current maintainers.

  • Cons: Subtle details may be lost, and translators from English to English may be hard to find as stated by Wikipedia:


  • > The main English Wikipedia has 5 million articles, written by nearly 140K active users; the Swedish Wikipedia is almost as big, 3M articles from only 3K active users; but the Simple English Wikipedia has just 123K articles and 871 active users. That's fewer articles than Esperanto!


  • Changes


  • Get a Documentation Contribution Agreement

  • The Documentation Contribution Agreement have to be written by the PSF, then listed at and have its own page like

  • Migrate GitHub Repositories


  • We (authors of this PEP) already own French and Japanese Git repositories, so moving them to the Python documentation organization will not be a problem. We'll however be following the New Translation Procedure.

  • Setup a GitHub bot for Documentation Contribution Agreement

  • To help ensuring contributors from GitHub have signed the Documentation Contribution Agreement, We can setup the "The Knights Who Say Ni" GitHub bot customized for this agreement on the migrated repositories [29].

  • Patch docsbuild-scripts to Compile Translations

  • Docsbuild-script must be patched to:

  • List the language tags to build along with the branches to build.

  • List the language tags to display in the language switcher.

  • Find translation repositories by formatting{language_tag}.git (See Repository for Po Files)

  • Build translations for each branch and each language.

  • Patched docsbuild-scripts must only open .po files from translation repositories.

  • List coordinators in the devguide

  • Add a page or a section with an empty list of coordinators to the devguide, each new coordinator will be added to this list.

  • Create sphinx-doc Language Switcher


  • Highly similar to the version switcher, a language switcher must be implemented. This language switcher must be configurable to hide or show a given language.

  • The language switcher will only have to update or add the language segment to the path like the current version switcher does. Unlike the version switcher, no preflight are required as destination page always exists (translations does not add or remove pages). Untranslated (but existing) pages still exists, they should however be rendered as so, see Enhance Rendering of Untranslated and Fuzzy Translations.

  • Update sphinx-doc Version Switcher

  • The patch_url function of the version switcher in version_switch.js have to be updated to understand and allow the presence of the language segment in the path.

  • Enhance Rendering of Untranslated and Fuzzy Translations

  • It's an opened sphinx issue [9], but we'll need it so we'll have to work on it. Translated, fuzzy, and untranslated paragraphs should be differentiated. (Fuzzy paragraphs have to warn the reader what he's reading may be out of date.)

  • New Translation Procedure

  • Designate a Coordinator

  • The first step is to designate a coordinator, see Language Team, The coordinator must sign the CLA.

  • The coordinator should be added to the list of translation coordinators on the devguide.

  • Create Github Repository

  • Create a repository named "python-docs-{LANGUAGE_TAG}" (IETF language tag, without redundent region subtag, with a dash, and lowercased.) on the Python GitHub organization (See Repository For Po Files.), and grant the language coordinator push rights to this repository.

  • Setup the Documentation Contribution Agreement

  • The README file should clearly show the following Documentation Contribution Agreement:


  • maintained using a global network of volunteers. By posting this

  • project on Transifex, GitHub, and other public places, and inviting

  • you to participate, we are proposing an agreement that you will

  • provide your improvements to Python's documentation or the translation

  • of Python's documentation for the PSF's use under the CC0 license

  • (available at

  • ``_). In

  • return, you may publicly claim credit for the portion of the

  • translation you contributed and if your translation is accepted by the

  • PSF, you may (but are not required to) submit a patch including an

  • appropriate annotation in the Misc/ACKS or TRANSLATORS file. Although

  • nothing in this Documentation Contribution Agreement obligates the PSF

  • to incorporate your textual contribution, your participation in the

  • Python community is welcomed and appreciated.

  • You signify acceptance of this agreement by submitting your work to

  • the PSF for inclusion in the documentation.

  • Add support for translations in docsbuild-scripts

  • As soon as the translation hits its first commits, update the docsbuild-scripts configuration to build the translation (but not displaying it in the language switcher).

  • Add Translation to the Language Switcher


  • As soon as the translation hits:


  • 100% of bugs.html with proper links to the language repository issue tracker.


  • 100% of tutorial.


  • 100% of library/functions (builtins).


  • the translation can be added to the language switcher.


  • 最后,请帮忙写一下简介