Traduir documentació amb Sphinx¶
Sphinx és una eina per crear una bella documentació. Utilitza una sintaxi reStructuredText senzilla i pot generar resultats en molts formats. Si busqueu un exemple, aquesta documentació també es construeix utilitzant-lo. El complement molt útil per utilitzar Sphinx és el servei Read the Docs, que crearà i publicarà la vostra documentació gratuïtament.
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 Internationalization. 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 Descobriment de components add-on to automatically
discover all others.
|
|
|
|
|
|
gettext PO file |
|
|
Expressió regular per a trobar fitxers de traducció |
|
Personalitza el nom del component |
|
Defineix el fitxer base per a noves traduccions |
|
Suggeriment
Preferiríeu que Sphinx generi només un fitxer PO? Des de Sphinx 3.3.0, podeu aconseguir-ho mitjançant:
gettext_compact = "docs"
Podeu trobar diversos projectes de documentació que s’estan traduint mitjançant aquest enfocament:
Documentació de Weblate (estàs llegint-ho ara)