Traduzindo documentação usando Sphinx

Sphinx é uma ferramenta para criar documentação bonita. Ela usa a sintaxe reStructuredText simples e pode gerar saída em muitos formatos. Se você está procurando um exemplo, esta documentação também é construída usando-a. O companheiro muito útil para usar o Sphinx é o serviço Read the Docs, que irá construir e publicar sua documentação gratuitamente.

I will not focus on writing documentation itself, if you need guidance with that, just follow instructions on the Sphinx website. Once you have documentation ready, translating it is quite easy as Sphinx comes with support for this and it is quite nicely covered in their Internacionalização. It’s matter of a few configuration directives and invoking the sphinx-intl tool.

If you are using Read the Docs service, you can start building translated documentation on Read the Docs. Their Localization and Internationalization covers pretty much everything you need - creating another project, setting its language, and linking it from the main project as a translation.

Now all you need is translating the documentation content. Sphinx generates PO file for each directory or top-level file, which can lead to quite a lot of files to translate (depending on gettext_compact settings). You can import the index.po into Weblate as an initial component and then configure Descoberta de componente add-on to automatically discover all others.

Configuração de componente

Nome do componente

Documentation

Máscara do arquivo

docs/locales/*/LC_MESSAGES/index.po

Modelo para novas traduções

docs/locales/index.pot

Formato de arquivo

arquivo PO gettext

Marcadores de tradução

rst-text

Configuração de descoberta de componente

Expressão regular para corresponder aos arquivos de tradução

docs/locales/(?P<language>[^/.]*)/LC_MESSAGES/(?P<component>[^/]*)\.po

Personalizar nome do componente

Documentation: {{ component|title }}

Definir o arquivo base para novas traduções

docs/locales/{{ component }}.pot

Dica

Você prefere que o Sphinx gere apenas um único arquivo PO? Desde o Sphinx 3.3.0, você pode fazer isso usando:

gettext_compact = "docs"

Você pode encontrar vários projetos de documentação sendo traduzidos usando esta abordagem: