Skip to content

Commit da076d1

Browse files
DOCS: Improve Internationalization guide (#12377)
Documentation needs to mention the new Transifex CLI tool instead of the deprecated transifex-client Co-authored-by: Chris Sewell <[email protected]>
1 parent 20ec3bd commit da076d1

File tree

1 file changed

+83
-40
lines changed

1 file changed

+83
-40
lines changed

doc/usage/advanced/intl.rst

Lines changed: 83 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Sphinx uses these facilities to translate whole documents.
2727

2828
Initially project maintainers have to collect all translatable strings (also
2929
referred to as *messages*) to make them known to translators. Sphinx extracts
30-
these through invocation of ``sphinx-build -M gettext``.
30+
these through invocation of :command:`sphinx-build -M gettext`.
3131

3232
Every single element in the doctree will end up in a single message which
3333
results in lists being equally split into different chunks while large
@@ -51,13 +51,13 @@ through :program:`msgfmt` for efficiency reasons. If you make these files
5151
discoverable with :confval:`locale_dirs` for your :confval:`language`, Sphinx
5252
will pick them up automatically.
5353

54-
An example: you have a document ``usage.rst`` in your Sphinx project. The
55-
*gettext* builder will put its messages into ``usage.pot``. Imagine you have
56-
Spanish translations [2]_ stored in ``usage.po`` --- for your builds to
54+
An example: you have a document :file:`usage.rst` in your Sphinx project. The
55+
*gettext* builder will put its messages into :file:`usage.pot`. Imagine you have
56+
Spanish translations [2]_ stored in :file:`usage.po` --- for your builds to
5757
be translated you need to follow these instructions:
5858

5959
* Compile your message catalog to a locale directory, say ``locale``, so it
60-
ends up in ``./locale/es/LC_MESSAGES/usage.mo`` in your source directory
60+
ends up in :file:`./locale/es/LC_MESSAGES/usage.mo` in your source directory
6161
(where ``es`` is the language code for Spanish.) ::
6262

6363
msgfmt "usage.po" -o "locale/es/LC_MESSAGES/usage.mo"
@@ -101,7 +101,7 @@ section describe an easy way to translate with *sphinx-intl*.
101101
102102
$ pip install sphinx-intl
103103
104-
#. Add configurations to ``conf.py``.
104+
#. Add configurations to :file:`conf.py`.
105105

106106
::
107107

@@ -137,7 +137,7 @@ section describe an easy way to translate with *sphinx-intl*.
137137
#. Translate po files.
138138

139139
As noted above, these are located in the ``./locale/<lang>/LC_MESSAGES``
140-
directory. An example of one such file, from Sphinx, ``builders.po``, is
140+
directory. An example of one such file, from Sphinx, :file:`builders.po`, is
141141
given below.
142142

143143
.. code-block:: po
@@ -165,7 +165,7 @@ section describe an easy way to translate with *sphinx-intl*.
165165

166166
#. Build translated document.
167167

168-
You need a :confval:`language` parameter in ``conf.py`` or you may also
168+
You need a :confval:`language` parameter in :file:`conf.py` or you may also
169169
specify the parameter on the command line.
170170

171171
For BSD/GNU make, run:
@@ -218,69 +218,103 @@ Using Transifex service for team translation
218218
--------------------------------------------
219219

220220
Transifex_ is one of several services that allow collaborative translation via a
221-
web interface. It has a nifty Python-based command line client that makes it
221+
web interface. It has a nifty Go-based command line client that makes it
222222
easy to fetch and push translations.
223223

224224
.. TODO: why use transifex?
225225
226226
227-
#. Install `transifex-client`_.
227+
#. Install the `Transifex CLI tool`_.
228228

229-
You need :command:`tx` command to upload resources (pot files).
229+
You need the :command:`tx` command line tool for uploading resources (pot files).
230+
The official installation process place the :file:`tx` binary file in
231+
the current directory along with a README and a LICENSE file, and adds
232+
the current directory to ``$PATH``.
230233

231234
.. code-block:: console
232235
233-
$ pip install transifex-client
236+
$ curl -o- https://raw.githubusercontent.com/transifex/cli/master/install.sh | bash
234237
235238
.. seealso:: `Transifex Client documentation`_
236239

237-
#. Create your Transifex_ account and create new project for your document.
240+
#. Create your Transifex_ account and create a new project and an organization
241+
for your document.
238242

239243
Currently, Transifex does not allow for a translation project to have more
240244
than one version of the document, so you'd better include a version number in
241245
your project name.
242246

243247
For example:
244248

249+
:Organization ID: ``sphinx-document``
245250
:Project ID: ``sphinx-document-test_1_0``
246251
:Project URL: ``https://www.transifex.com/projects/p/sphinx-document-test_1_0/``
247252

248-
#. Create config files for :command:`tx` command.
253+
#. Create an API token to be used in the command-line.
249254

250-
This process will create ``.tx/config`` in the current directory, as well as
251-
a ``~/.transifexrc`` file that includes auth information.
255+
Go to your `Transifex API token`_ page and generate a token.
256+
Copy the generated token now, as you will not be able to see it again later.
257+
258+
#. Set your Transifex API token in the user configuration file
259+
:file:`$HOME/.transifexrc`.
260+
261+
.. code-block:: ini
262+
263+
[https://app.transifex.com]
264+
rest_hostname = https://rest.api.transifex.com
265+
token = paste_your_api_token_here
266+
267+
#. Alternatively, you can store your Transifex API token as the environment variable
268+
``TX_TOKEN``, which is recognized and used by :command:`tx`.
269+
270+
.. code-block:: console
271+
272+
$ export TX_TOKEN=paste_your_api_token_here
273+
274+
#. Create the project's config file for :command:`tx` command.
275+
276+
This process will create ``.tx/config`` in the current directory.
252277

253278
.. code-block:: console
254279
280+
$ cd /your/document/root
255281
$ tx init
256-
Creating .tx folder...
257-
Transifex instance [https://www.transifex.com]:
258-
...
259-
Please enter your transifex username: <transifex-username>
260-
Password: <transifex-password>
261-
...
262-
Done.
282+
283+
Successful creation of '.tx/config' file
263284
264285
#. Upload pot files to Transifex service.
265286

266-
Register pot files to ``.tx/config`` file:
287+
Register pot files to ``.tx/config`` file using
288+
:command:`sphinx-intl update-txconfig-resources`, adjusting
289+
``--pot-dir`` value to your project's pot files' directory:
267290

268291
.. code-block:: console
269292
270293
$ cd /your/document/root
271294
$ sphinx-intl update-txconfig-resources --pot-dir _build/locale \
272-
--transifex-project-name sphinx-document-test_1_0
295+
--transifex-organization-name=sphinx-document \
296+
--transifex-project-name=sphinx-document-test_1_0
297+
298+
You can use the ``SPHINXINTL_TRANSIFEX_ORGANIZATION_NAME`` and
299+
``SPHINXINTL_TRANSIFEX_PROJECT_NAME`` environment variables
300+
instead of the respective command line arguments.
301+
302+
.. seealso:: `sphinx-intl update-txconfig-resources documentation`_
273303

274304
and upload pot files:
275305

276306
.. code-block:: console
277307
278308
$ tx push -s
279-
Pushing translations for resource sphinx-document-test_1_0.builders:
280-
Pushing source file (locale/pot/builders.pot)
281-
Resource does not exist. Creating...
282-
...
283-
Done.
309+
# Getting info about resources
310+
311+
sphinx-document-test_1_0.builders - Getting info
312+
sphinx-document-test_1_0.builders - Done
313+
314+
# Pushing source files
315+
316+
sphinx-document-test_1_0.builders - Uploading file
317+
sphinx-document-test_1_0.builders - Done
284318
285319
#. Forward the translation on Transifex.
286320

@@ -295,12 +329,18 @@ easy to fetch and push translations.
295329
296330
$ cd /your/document/root
297331
$ tx pull -l de
298-
Pulling translations for resource sphinx-document-test_1_0.builders (...)
299-
-> de: locale/de/LC_MESSAGES/builders.po
300-
...
301-
Done.
332+
# Getting info about resources
333+
334+
sphinx-document-test_1_0.builders - Getting info
335+
sphinx-document-test_1_0.builders - Done
336+
337+
# Pulling files
338+
339+
sphinx-document-test_1_0.builders [de] - Pulling file
340+
sphinx-document-test_1_0.builders [de] - Creating download job
341+
sphinx-document-test_1_0.builders [de] - Done
302342
303-
Invoke :command:`make html` (for BSD/GNU make):
343+
Invoke :command:`make html` (for BSD/GNU make) passing the language code:
304344

305345
.. code-block:: console
306346
@@ -338,7 +378,8 @@ There is a `sphinx translation page`_ for Sphinx (master) documentation.
338378
4. Wait acceptance by Transifex sphinx translation maintainers.
339379
5. (After acceptance) Translate on Transifex.
340380

341-
Detail is here: https://docs.transifex.com/getting-started-1/translators
381+
Detail is here:
382+
https://help.transifex.com/en/articles/6248698-getting-started-as-a-translator
342383

343384

344385
Translation progress and statistics
@@ -364,9 +405,11 @@ percentage of nodes that have been translated on a per-document basis.
364405
for details on that software suite.
365406
.. [2] Because nobody expects the Spanish Inquisition!
366407
367-
.. _`transifex-client`: https://pypi.org/project/transifex-client/
408+
.. _`Transifex CLI tool`: https://https://github.com/transifex/cli/
368409
.. _`sphinx-intl`: https://pypi.org/project/sphinx-intl/
369-
.. _Transifex: https://www.transifex.com/
410+
.. _Transifex: https://app.transifex.com/
370411
.. _Weblate's documentation: https://docs.weblate.org/en/latest/devel/sphinx.html
371-
.. _`sphinx translation page`: https://www.transifex.com/sphinx-doc/sphinx-doc/
372-
.. _`Transifex Client documentation`: https://docs.transifex.com/client/introduction/
412+
.. _`sphinx translation page`: https://app.transifex.com/sphinx-doc/sphinx-doc/
413+
.. _`Transifex Client documentation`: https://developers.transifex.com/docs/using-the-client
414+
.. _`Transifex API token`: https://app.transifex.com/user/settings/api/
415+
.. _`sphinx-intl update-txconfig-resources documentation`: https://sphinx-intl.readthedocs.io/en/master/refs.html#sphinx-intl-update-txconfig-resources

0 commit comments

Comments
 (0)