Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH - Update translations workflows #1959

Merged
merged 41 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
f0f71d2
Add I18n commands to tox.ini
trallard Aug 16, 2024
d95545f
Add translation commands to tox.ini
trallard Aug 19, 2024
9e412fb
Remove gettext install
trallard Aug 19, 2024
7dd05ed
Update contribution guide - translation
trallard Aug 19, 2024
0677b17
Update user guide - translation
trallard Aug 19, 2024
256bcd0
:fire: Remove noxfile
trallard Aug 19, 2024
16543a2
:fire: Remove nox docs
trallard Aug 19, 2024
5444932
Update theme's POT file
trallard Aug 19, 2024
e9b8d72
Update locale files
trallard Aug 19, 2024
8e61d5c
[pre-commit.ci] Automatic linting and formatting fixes
pre-commit-ci[bot] Aug 19, 2024
da59b0c
Update locale files
trallard Aug 19, 2024
151811c
[pre-commit.ci] Automatic linting and formatting fixes
pre-commit-ci[bot] Aug 19, 2024
b2eacde
Update tox file - separate assets and translations compilation
trallard Aug 20, 2024
c7854b6
Remove fuzzy comments from catalogues
trallard Aug 20, 2024
d0a9dba
Update translations docs - fuzzy comments
trallard Aug 20, 2024
b50baf6
Remove PO compilation from webpack.config
trallard Aug 20, 2024
7b8282f
Add note about internationalisation
trallard Aug 20, 2024
caa761e
Remove fuzzy strings
trallard Aug 20, 2024
a1608e7
[pre-commit.ci] Automatic linting and formatting fixes
pre-commit-ci[bot] Aug 20, 2024
cebb954
Apply suggestions from code review
trallard Aug 20, 2024
c7e03ec
[pre-commit.ci] Automatic linting and formatting fixes
pre-commit-ci[bot] Aug 20, 2024
9128e79
[pre-commit.ci] Automatic linting and formatting fixes
pre-commit-ci[bot] Aug 20, 2024
f283fb8
Apply suggestions from code review
trallard Aug 29, 2024
4a38eee
Apply suggestions from code review
trallard Aug 29, 2024
f7cc2e0
Merge branch 'trallard/update-translations' of https://github.com/tra…
trallard Aug 29, 2024
4209a74
Update tox.ini - comments and cleanup
trallard Aug 29, 2024
9e54b3f
Update translation docs
trallard Aug 29, 2024
c143597
:wrench: Update tox.ini file - simplify translations
trallard Aug 30, 2024
c51f208
:recycle: Update all references to compile to compile-assets
trallard Aug 30, 2024
f39c8d4
Update localization docs
trallard Aug 30, 2024
369e3a0
:pencil2: Fix references in docs
trallard Aug 30, 2024
c008344
Update a11y tests call in CI
trallard Aug 30, 2024
acf54a6
Update translation docs
trallard Aug 30, 2024
aecd98f
Update docs and command regardin docs-live
trallard Aug 30, 2024
15f8f05
Replace guide to use docs-live-server
trallard Aug 30, 2024
66e0f71
:pencil2: Add missing `
trallard Aug 30, 2024
10a1d77
Update docs/community/topics/i18n.rst
Carreau Sep 2, 2024
e63edde
Revert inline reference
trallard Sep 2, 2024
7666727
Merge branch 'main' into trallard/update-translations
trallard Sep 2, 2024
b74c71f
Update comments
trallard Sep 2, 2024
bb7282c
:rotating_light: Lint and format files
trallard Sep 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ jobs:
- name: "Run tests ✅"
shell: bash
run: |
# this will compile the assets then run the tests
# this will compile the assets and translations then run the tests
# check if there is a specific Sphinx version to test with
# example substitution: tox run -e compile,py39-sphinx61-tests
if [ -n "${{matrix.sphinx-version}}" ]; then
python -Im tox run -e compile,py$(echo ${{ matrix.python-version }} | tr -d .)-sphinx$(echo ${{ matrix.sphinx-version }} | tr -d .)-tests
python -Im tox run -e compile,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-sphinx$(echo ${{ matrix.sphinx-version }} | tr -d .)-tests
trallard marked this conversation as resolved.
Show resolved Hide resolved
# if not we use the default version
# example substitution: tox run -e compile,py39-tests
else
python -Im tox run -e compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests
python -Im tox run -e compile,i18n-compile,py$(echo ${{ matrix.python-version }} | tr -d .)-tests
fi
- name: "Upload coverage data to GH artifacts 📤"
if: matrix.python-version == '3.12' && matrix.os == 'ubuntu-latest' && matrix.sphinx-version == 'dev'
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ jobs:
python-version: "3.9"
pandoc: "False"

- name: "Install gettext for translations 🌐"
run: |
sudo apt-get install gettext

gabalafou marked this conversation as resolved.
Show resolved Hide resolved
- name: "Build and inspect package 📦"
uses: hynek/build-and-inspect-python-package@v2
id: baipp
Expand Down
189 changes: 106 additions & 83 deletions docs/community/topics/i18n.rst

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions docs/community/topics/nox.md

This file was deleted.

26 changes: 14 additions & 12 deletions docs/user_guide/i18n.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ Internationalization
This theme contains translatable strings.
There are two kinds of strings in this theme, with different steps to translate each.

**Built-in strings** are hard-coded in the theme's templates.
They will automatically be translated if the language is `supported <https://github.com/pydata/pydata-sphinx-theme/tree/master/pydata_sphinx_theme/locale>`__.
To add another language, see :ref:`translating-the-theme`.
* **Built-in strings** are hard-coded in the theme's templates. They will be automatically translated if the language is `supported <https://github.com/pydata/pydata-sphinx-theme/tree/main/src/pydata_sphinx_theme/locale>`__. To add another language, refer to the :ref:`translating-the-theme` and :ref:`adding-new-language` sections in the documentation.
trallard marked this conversation as resolved.
Show resolved Hide resolved

**Configurable strings** are user-defined with the ``html_theme_options`` variable in your ``conf.py`` file (see other sections in :doc:`the user guide<index>` for examples).
To translate these strings, see the section below.
* **Configurable strings** are user-defined with the ``html_theme_options`` variable in your ``conf.py`` file (see other sections in :doc:`the user guide<index>` for examples of these configurable strings).
trallard marked this conversation as resolved.
Show resolved Hide resolved

Translating configurable strings
--------------------------------

These instructions are for translating configurable strings (those that are customizable in ``html_theme_options``).
These instructions are for translating configurable strings (those that are customizable in ``html_theme_options`` within
the `config.py` file).
trallard marked this conversation as resolved.
Show resolved Hide resolved

These instructions assume that you store your translations in a ``locale`` directory under your documentation directory, and that you want to use ``theme`` as the name of the message catalog for these strings.
These instructions assume that you store your translations in a ``locale`` directory under your documentation directory and that you want to use ``messages`` as the name of the message catalog for these strings.

Note you will also need to install `pybabel <https://babel.pocoo.org/en/latest/installation.html>`__ to handle your documentation translations.

#. In your ``conf.py`` file:

Expand All @@ -25,7 +25,7 @@ These instructions assume that you store your translations in a ``locale`` direc
import os.path
from sphinx.locale import get_translation

catalog = "theme"
catalog = "messages"
_ = get_translation(catalog)

html_theme_options = {
Expand Down Expand Up @@ -57,18 +57,20 @@ These instructions assume that you store your translations in a ``locale`` direc

.. code-block:: bash

pybabel extract . -o locale/theme.pot
pybabel extract . -o locale/messages.pot

#. Create a message catalog (changing the ``--locale`` option as desired):
#. Create a message catalog by specifying the `ISO 639-1 code <https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes>`__ for the new language (using the ``--locale`` flag):

.. code-block:: bash

pybabel init --input-file=locale/theme.pot --domain=theme --output-dir=locale --locale=fr
# for example, to add French (ISO 639-1 code: fr)
pybabel init --input-file=locale/messages.pot --domain=messages --output-dir=locale --locale=fr


#. Translate the message catalog by editing the file.

#. Compile the message catalog:

.. code-block:: bash

pybabel compile --directory=locale --domain=theme
pybabel compile --directory=locale --domain=messages
239 changes: 0 additions & 239 deletions noxfile.py

This file was deleted.

Loading
Loading