Skip to content

Commit

Permalink
rst: Use code-block instead of code directive. Specify language.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 25, 2020
1 parent 8c05fcd commit 01291ab
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 25 deletions.
50 changes: 37 additions & 13 deletions docs/cli.rst
Expand Up @@ -9,11 +9,15 @@ To install this package with command-line tools, run:
Then, `install the ocds-babel requirements for Markdown translation <https://ocds-babel.readthedocs.io/en/latest/api/translate.html#install-requirements-for-markdown-translation>`__.

To see all commands available, run::
To see all commands available, run:

.. code-block:: bash
ocdsextensionregistry --help
If you see a message at the start of the output like::
If you see a message at the start of the output like:

.. code-block:: none
exception "No module named 'babel'" prevented loading of ocdsextensionregistry.cli.commands.generate_pot_files module
Expand All @@ -24,19 +28,27 @@ download

Downloads versions of extensions to a local directory.

To download all versions of all extensions into an ``outputdir`` directory::
To download all versions of all extensions into an ``outputdir`` directory:

.. code-block:: bash
ocdsextensionregistry download outputdir
To download all versions of specific extensions::
To download all versions of specific extensions:

.. code-block:: bash
ocdsextensionregistry download outputdir lots bids
To download specific versions::
To download specific versions:

.. code-block:: bash
ocdsextensionregistry download outputdir bids==v1.1.3
You can mix and match specifying extensions and versions::
You can mix and match specifying extensions and versions:

.. code-block:: bash
ocdsextensionregistry download outputdir lots bids==v1.1.3
Expand All @@ -51,7 +63,9 @@ Within the output directory, the extension files are organized like `{extension}
generate-pot-files
------------------

Creates POT files (message catalogs) for versions of extensions in a local directory, for example::
Creates POT files (message catalogs) for versions of extensions in a local directory, for example:

.. code-block:: bash
ocdsextensionregistry generate-pot-files build/locale
Expand All @@ -61,38 +75,48 @@ You can specify versions and extensions like with the ``download`` command.

Within the output directory, the POT files are organized like `{extension}/{version}/{files}`, for example: ``lots/v1.1.3/docs.pot``.

This command can be run offline if ``--versions-dir`` is set to a local directory organized like the output directory of the ``download`` command, and if ``--extension-versions-url`` and ``--extensions-url`` are set to local files, for example::
This command can be run offline if ``--versions-dir`` is set to a local directory organized like the output directory of the ``download`` command, and if ``--extension-versions-url`` and ``--extensions-url`` are set to local files, for example:

.. code-block:: bash
ocdsextensionregistry generate-pot-files --versions-dir outputdir --extension-versions-url file://path/to/extension_versions.csv --extensions-url file://path/to/extensions.csv build/locale
generate-data-file
------------------

Generates a data file in JSON format with all the information about versions of extensions, for example::
Generates a data file in JSON format with all the information about versions of extensions, for example:

.. code-block:: bash
ocdsextensionregistry generate-data-file > data.json
You can specify versions and extensions like with the ``download`` command.

To add translations to the data file, set the ``--locale-dir`` option to a directory containing MO files, for example::
To add translations to the data file, set the ``--locale-dir`` option to a directory containing MO files, for example:

.. code-block:: bash
ocdsextensionregistry generate-data-file --locale-dir locale > data.json
The default behavior is to add all available translations, To select translations, use the ``--languages`` option, for example::
The default behavior is to add all available translations, To select translations, use the ``--languages`` option, for example:

.. code-block:: bash
ocdsextensionregistry generate-data-file --locale-dir locale --languages es,fr > data.json
To create MO files from existing translations, see :doc:`translation`.

By default, the publisher name of an extension version is like "open-contracting-extensions". If the version is on GitHub, you can have the publisher name be like "Open Contracting Data Standard Extensions" by `generating a personal access token <https://github.com/settings/tokens/new>`__ (do not select any scopes), copying it, and setting a ``OCDS_GITHUB_ACCESS_TOKEN`` environment variable to it.

This command can be run offline if ``--versions-dir`` is set to a local directory organized like the output directory of the ``download`` command, and if ``--extension-versions-url`` and ``--extensions-url`` are set to local files, for example::
This command can be run offline if ``--versions-dir`` is set to a local directory organized like the output directory of the ``download`` command, and if ``--extension-versions-url`` and ``--extensions-url`` are set to local files, for example:

.. code-block:: bash
ocdsextensionregistry generate-data-file --versions-dir outputdir --extension-versions-url file://path/to/extension_versions.csv --extensions-url file://path/to/extensions.csv > data.json
The data file is organized as below. To keep it short, the sample shows only one version of one extension, and only one row of one codelist, and it truncates the Markdown content of documentation files and the parsed content of schema files.

.. code:: json
.. code-block:: json
{
"risk_allocation": {
Expand Down
48 changes: 36 additions & 12 deletions docs/translation.rst
Expand Up @@ -4,11 +4,15 @@ Translation
Setup
-----

:doc:`Install this package with command-line tools<cli>`, and then install ``sphinx-intl`` and ``transifex-client``::
:doc:`Install this package with command-line tools<cli>`, and then install ``sphinx-intl`` and ``transifex-client``:

.. code-block:: bash
pip install 'sphinx-intl<1' transifex-client
Create a `~/.transifexrc <https://docs.transifex.com/client/client-configuration#%7E/-transifexrc>`__ file (replace ``USERNAME`` and ``PASSWORD``)::
Create a `~/.transifexrc <https://docs.transifex.com/client/client-configuration#%7E/-transifexrc>`__ file (replace ``USERNAME`` and ``PASSWORD``):

.. code-block:: bash
sphinx-intl create-transifexrc --transifex-username USERNAME --transifex-password PASSWORD
Expand All @@ -17,31 +21,45 @@ Create new translations

Create a project on Transifex (in this example, our project's identifier is ``ocds-extensions``). You might want to `upload <https://docs.transifex.com/setup/glossary/uploading-an-existing-glossary>`__ the `OCDS glossary <https://github.com/open-contracting/glossary/tree/master/glossaries>`__ in your language to Transifex, to assist with translation.

Generate POT files for all versions of all extensions::
Generate POT files for all versions of all extensions:

.. code-block:: bash
ocdsextensionregistry generate-pot-files build/locale
Or, generate POT files for the versions of extensions you want to translate, for example::
Or, generate POT files for the versions of extensions you want to translate, for example:

.. code-block:: bash
ocdsextensionregistry generate-pot-files build/locale lots bids==v1.1.3
Remove any existing ``.tx/config`` file::
Remove any existing ``.tx/config`` file:

.. code-block:: bash
rm -f .tx/config
Create a new ``.tx/config`` file::
Create a new ``.tx/config`` file:

.. code-block:: bash
sphinx-intl create-txconfig
Update the ``.tx/config`` file based on the POT files (replace ``ocds-extensions`` with your project)::
Update the ``.tx/config`` file based on the POT files (replace ``ocds-extensions`` with your project):

.. code-block:: bash
sphinx-intl update-txconfig-resources --transifex-project-name ocds-extensions --pot-dir build/locale --locale-dir locale
Push source files to Transifex for translation::
Push source files to Transifex for translation:

.. code-block:: bash
tx push -s
Once you've translated strings on Transifex, email data@open-contracting.org so that we can pull translation files from Transifex, build MO files, and commit the changes::
Once you've translated strings on Transifex, email data@open-contracting.org so that we can pull translation files from Transifex, build MO files, and commit the changes:

.. code-block:: bash
tx pull -a -f
sphinx-intl build -d locale
Expand All @@ -51,15 +69,21 @@ Update existing translations

Existing translations are stored in `ocds-extensions-translations <https://github.com/open-contracting/ocds-extensions-translations>`__.

Follow the steps for creating new translations, then clone the repository::
Follow the steps for creating new translations, then clone the repository:

.. code-block:: bash
git clone https://github.com/open-contracting/ocds-extensions-translations.git
Change into its directory::
Change into its directory:

.. code-block:: bash
cd ocds-extensions-translations
And push its translations. See `Transifex's documentation <https://docs.transifex.com/client/push>`__ for more information on how to specify which languages or resources to push::
And push its translations. See `Transifex's documentation <https://docs.transifex.com/client/push>`__ for more information on how to specify which languages or resources to push:

.. code-block:: bash
tx push -t
Expand Down

0 comments on commit 01291ab

Please sign in to comment.