diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 442dfcd97..6fa7f1fa5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,9 +20,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.9" - - name: Install gettext for translations - run: | - sudo apt-get install gettext - name: Build package run: | python -m pip install -U pip build diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4dbeaa920..efd9241a2 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -88,10 +88,6 @@ jobs: python -m pip install -e .[test] sphinx==${{ matrix.sphinx-version }} - name: Show installed versions run: python -m pip list - - name: Compile MO files - run: | - pip install nox - nox -s compile - name: Run tests run: pytest -m "not a11y" --color=yes --cov pydata_sphinx_theme --cov-branch --cov-report xml:cov.xml --cov-report= --cov-fail-under ${{ env.COVERAGE_THRESHOLD }} - name: Upload to Codecov diff --git a/.github/workflows/translate.yml b/.github/workflows/translate.yml new file mode 100644 index 000000000..e69de29bb diff --git a/docs/community/topics/i18n.rst b/docs/community/topics/i18n.rst index 68a8d0da7..e77c249a4 100644 --- a/docs/community/topics/i18n.rst +++ b/docs/community/topics/i18n.rst @@ -4,76 +4,73 @@ Internationalization .. warning:: This theme is still in the process of setting up internationalization. - Some of the text below may not yet be correct (for example, we do not yet have a ``locales/`` directory). + Some of the text below may not yet be correct. Follow these issues to track progress: - https://github.com/pydata/pydata-sphinx-theme/issues/1162 - - https://github.com/pydata/pydata-sphinx-theme/issues/257 -Internationalization (I18N) and localization (L10N) is performed using `Gettext `__. +Internationalization (i18n) and localization (l10n) is performed using `Gettext `__. Types of files -------------- -Gettext reads a program's source and extracts text that has been marked as translatable, known as "source strings. -Gettext uses three types of files: +Gettext reads a program's source and extracts text that has been marked as translatable, known as "source strings". Gettext uses three types of files: PO file (``.po``) - A `Portable Object (PO) file `__ is made up of many entries. - Each entry holds the relation between a source string and its translation. - ``msgid`` contains the **source string**, and ``msgstr`` contains the **translation**. - In a given PO file, all translations are expressed in a single target language. - PO files are also known as "message catalogs". - - Entries begin with comments, on lines starting with the character ``#``. - Comments are created and maintained by Gettext. - Comment lines starting with ``#:`` contain references to the program's source. - These references allow a human translator to find the source strings in their original context. - Comment lines starting with ``#,`` contain flags like ``python-format``, which indicates that the source string contains placeholders like ``%(copyright)s``. +````````````````` + +A `Portable Object (PO) file `__ is made up of many entries. Each entry holds the relation between a source string and its translation. ``msgid`` contains the **source string**, and ``msgstr`` contains the **translation**. In a given PO file, all translations are expressed in a single target language. PO files are also known as "message catalogs". + +Entries begin with comments, on lines starting with the character ``#``. Comments are created and maintained by Gettext. Comment lines starting with ``#:`` contain references to the program's source. These references allow a human translator to find the source strings in their original context. Comment lines starting with ``#,`` contain flags like ``python-format``, which indicates that the source string contains placeholders like ``%(copyright)s``. + POT file (``.pot``) - A Portable Object Template (POT) file is the same as a PO file, except the translations are empty, so that it can be used as a template for new languages. +``````````````````` + +A Portable Object Template (POT) file is the same as a PO file, except the translations are empty, so that it can be used as a template for new languages. + MO file (``.mo``) - A Machine Object (MO) file is a binary version of a PO file. PO files are compiled to MO files, which are required by Gettext. +````````````````` + +A Machine Object (MO) file is a binary version of a PO file. PO files are compiled to MO files, which are required by Gettext. .. _adding-natural-language-text: -Mark natural language text as translateable -------------------------------------------- +Mark natural language text as translatable +------------------------------------------ All natural language text must be marked as translatable, so that it can be extracted by Gettext and translated by humans. -Jinja2 provides a ``trans`` block and a ``_()`` function to mark text as translatable. -`Please refer to the Jinja2 documentation `__. -Remember to `manually escape `__ variables if needed. +Jinja2 provides a ``trans`` block and a ``_()`` function to mark text as translatable. `Please refer to the Jinja2 documentation `__. Remember to `manually escape `__ variables if needed. -Any text that is marked in this way will be discoverable by ``gettext`` and used to generate ``.po`` files (see below for information). -Once you've marked text as translateable, complete the steps for :ref:`changing-natural-language-text`. +Any text that is marked in this way will be discoverable by ``gettext`` and used to generate ``.po`` files (see below for information). Once you've marked text as translatable, complete the steps for :ref:`changing-natural-language-text`. .. _changing-natural-language-text: -Add or change natural language text ------------------------------------ +Update messages text +-------------------- -These steps cover how to add or change text that has been marked as translateable. +These steps cover how to add or change text that has been marked as translatable. #. Edit the natural language text as desired. - Ensure that it is {ref}`marked as translateable `. + Ensure that it is :ref:`marked as translatable `. #. Generate/update the message catalog template (``POT`` file) with `the PyBabel extract command `__: - .. code-block:: bash - - pybabel extract . -F babel.cfg -o src/pydata_sphinx_theme/locale/sphinx.pot -k '_ __ l_ lazy_gettext' + .. code-block:: console - **To run this in ``.nox``**: ``nox -s translate -- extract``. + pybabel extract . -F babel.cfg -o src/pydata_sphinx_theme/locale/messages.pot #. Update the message catalogs (``PO`` files) with `the PyBabel update command `__: - .. code-block:: bash + .. code-block:: console + + pybabel update -i src/pydata_sphinx_theme/locale/messages.pot -d src/pydata_sphinx_theme/locale + +.. admonition:: nox session - pybabel update -i src/pydata_sphinx_theme/locale/sphinx.pot -d src/pydata_sphinx_theme/locale -D sphinx + .. code-block:: console - **To run this in ``.nox``**: ``nox -s translate -- update``. + nox -s translate This will update these files with new information about the position and text of the language you have modified. @@ -87,10 +84,10 @@ Otherwise, a new entry is added and needs to be translated. .. _translating-the-theme: -Add translations to translateable text --------------------------------------- +Add new language +---------------- -Once text has been marked as translateable, and ``PO`` files have been generated for it, we may add translations for new languages for the phrase. +Once text has been marked as translatable, and ``PO`` files have been generated for it, we may add translations for new languages for the phrase. This section covers how to do so. .. note:: @@ -102,19 +99,31 @@ This section covers how to do so. .. code-block:: bash - pybabel init -i src/pydata_sphinx_theme/locale/sphinx.pot -d src/pydata_sphinx_theme/locale -D sphinx -l es + pybabel init -i src/pydata_sphinx_theme/locale/messages.pot -d src/pydata_sphinx_theme/locale -l es - **To run this in ``.nox``**: ``nox -s translate -- init es`` +.. admonition:: nox session -#. Edit the language's message catalog at ``pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po``. For each source string introduced by the ``msgid`` keyword, add its translation after the ``msgstr`` keyword. + .. code-block:: console -#. Compile the message catalogs of every language. This creates or updates the MO files with `PyBabel compile `__: + nox -s translate - .. code-block:: bash +Edit the messages +----------------- + +Edit the language's message catalog at ``pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po``. For each source string introduced by the ``msgid`` keyword, add its translation after the ``msgstr`` keyword. - pybabel compile -d src/pydata_sphinx_theme/locale -D sphinx +Compile the catalog +------------------- - **To run this in ``.nox``**: ``nox -s translate -- compile``. +Compile the message catalogs of every language. This creates or updates the MO files with `PyBabel compile `__: + +.. code-block:: bash + + pybabel compile -d src/pydata_sphinx_theme/locale -D sphinx + +.. note:: + + The .mo file are automatically build my the theme at build time so you should never manually run this command. Translation tips ---------------- @@ -126,25 +135,30 @@ Full sentences and clauses must always be a single translatable string. Otherwise, you can get ``next page`` translated as ``suivant page`` instead of as ``page suivante``, etc. Deal with variables and markup in translations -````````````````````````````````````````````````````````````` - -If a variable (like the ``edit_page_provider_name`` theme option) is used as part of a phrase, it must be included within the translatable string. -Otherwise, the word order in other languages can be incorrect. -In a Jinja template, simply surround the translatable string with ``{% trans variable=variable %}`` and ``{% endtrans %}}`. -For example: ``{% trans provider=provider %}Edit on {{ provider }}{% endtrans %}`` -The translatable string is extracted as the Python format string ``Edit on %(provider)s``. -This is so that the same translatable string can be used in both Python code and Jinja templates. -It is the translator's responsibility to use ``%(provider)s`` verbatim in the translation. - -If a non-translatable word or token (like HTML markup) is used as part of a phrase, it must also be included within the translatable string. -For example: ``{% trans theme_version=theme_version|e %}Built with the PyData Sphinx Theme {{ theme_version }}.{% endtrans %}`` -It is the translator's responsibility to use the HTML markup verbatim in the translation. +`````````````````````````````````````````````` + +If a variable (like the ``edit_page_provider_name`` theme option) is used as part of a phrase, it must be included within the translatable string. Otherwise, the word order in other languages can be incorrect. In a Jinja template, simply surround the translatable string with ``{% trans variable=variable %}`` and ``{% endtrans %}}``. For example: +.. code-block:: jinja + + {% trans provider=provider %}Edit on {{ provider }}{% endtrans %} + +The translatable string is extracted as the Python format string ``Edit on %(provider)s``. This is so that the same translatable string can be used in both Python code and Jinja templates. It is the translator's responsibility to use ``%(provider)s`` verbatim in the translation. + +If a non-translatable word or token (like HTML markup) is used as part of a phrase, it must also be included within the translatable string. For example: + +.. code-block:: jinja + + {% trans theme_version=theme_version|e %} + Built with the PyData Sphinx Theme {{ theme_version }}. + {% endtrans %} + +It is the translator's responsibility to use the HTML markup verbatim in the translation. References ---------- -I18N and L10N are deep topics. Here, we only cover the bare minimum needed to fulfill basics technical tasks. You might like: +i18n and l10n are deep topics. Here, we only cover the bare minimum needed to fulfill basics technical tasks. You might like: - `Internationalis(z)ing Code `__ by Computerphile on YouTube - `Falsehoods Programmers Believe About Language `__ by Ben Hamill diff --git a/docs/user_guide/i18n.rst b/docs/user_guide/i18n.rst index 7d6756aef..35df57142 100644 --- a/docs/user_guide/i18n.rst +++ b/docs/user_guide/i18n.rst @@ -57,13 +57,13 @@ 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): .. code-block:: bash - pybabel init --input-file=locale/theme.pot --domain=theme --output-dir=locale --locale=fr + pybabel init --input-file=locale/messages.pot --domain=theme --output-dir=locale --locale=fr #. Translate the message catalog by editing the file. @@ -71,4 +71,4 @@ These instructions assume that you store your translations in a ``locale`` direc .. code-block:: bash - pybabel compile --directory=locale --domain=theme + pybabel compile --directory=locale diff --git a/noxfile.py b/noxfile.py index 24fe688f3..791326c3f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -9,13 +9,35 @@ import shutil as sh import tempfile from pathlib import Path -from shlex import split from textwrap import dedent import nox nox.options.reuse_existing_virtualenvs = True -ROOT = Path(__file__).parent +nox.options.sessions = [] + +# folders useful for translation-related sessions +root_dir = Path(__file__).parent +locale_dir = root_dir / "src" / "pydata_sphinx_theme" / "locale" +babel_cfg = root_dir / "babel.cfg" +pot_file = locale_dir / "messages.pot" + + +def session(default: bool = True, **kwargs): + """Wrap the `nox.session` decorator to add a `default` parameter. + + Setting `default=False` will exclude a session from running when `nox` is + invoked without a `--session` argument. + + related to https://github.com/wntrblm/nox/issues/654 + """ + + def _session(fn): + if default: + nox.options.sessions.append(kwargs.get("name", fn.__name__)) + return nox.session(**kwargs)(fn) + + return _session def _should_install(session: nox.Session) -> bool: @@ -44,16 +66,16 @@ def _should_install(session: nox.Session) -> bool: return should_install -@nox.session(reuse_venv=True) +@session() def lint(session: nox.Session) -> None: """Check the themes pre-commit before any other session.""" session.install("pre-commit") session.run("pre-commit", "run", "-a") -@nox.session() +@session() def compile(session: nox.Session) -> None: - """Compile the theme's web assets with sphinx-theme-builder.""" + """Compile the theme's web assets.""" if _should_install(session): session.install("-e", ".") session.install("sphinx-theme-builder[cli]") @@ -61,7 +83,7 @@ def compile(session: nox.Session) -> None: session.run("stb", "compile") -@nox.session() +@session() def docs(session: nox.Session) -> None: """Build the documentation and place in docs/_build/html. Use --no-compile to skip compilation.""" if _should_install(session): @@ -69,25 +91,24 @@ def docs(session: nox.Session) -> None: session.install("sphinx-theme-builder[cli]") if "no-compile" not in session.posargs: session.run("stb", "compile") + session.run("sphinx-build", "-b=html", "docs/", "docs/_build/html", "-v") -@nox.session(name="docs-live") +@session(name="docs-live", default=False) def docs_live(session: nox.Session) -> None: """Build the docs with a live server that re-loads as you make changes.""" - session.run(*split("pybabel compile -d src/pydata_sphinx_theme/locale -D sphinx")) if _should_install(session): session.install("-e", ".[doc]") session.install("sphinx-theme-builder[cli]") session.run("stb", "serve", "docs", "--open-browser") -@nox.session() +@session() def test(session: nox.Session) -> None: """Run the test suite.""" if _should_install(session): session.install("-e", ".[test]") - session.run(*split("pybabel compile -d src/pydata_sphinx_theme/locale -D sphinx")) session.run("pytest", "-m", "not a11y", *session.posargs) @@ -112,7 +133,7 @@ def a11y(session: nox.Session) -> None: session.run("pytest", "-m", "a11y", *session.posargs) -@nox.session(name="test-sphinx") +@session(name="test-sphinx", default=False) @nox.parametrize("sphinx", ["4", "5", "6"]) def test_sphinx(session: nox.Session, sphinx: int) -> None: """Run the test suite with a specific version of Sphinx.""" @@ -122,53 +143,56 @@ def test_sphinx(session: nox.Session, sphinx: int) -> None: session.run("pytest", *session.posargs) -@nox.session() +@session() def translate(session: nox.Session) -> None: - """Translation commands. Available commands after `--` : extract, update, compile, init.""" - # get the command from posargs, default to "update" - pybabel_cmd, found = ("update", False) - for c in ["extract", "update", "compile", "init"]: - if c in session.posargs: - pybabel_cmd, found = (c, True) - - if found is False: - print( - "No translate command found. Use like: `nox -s translate -- COMMAND`." - "\ndefaulting to `update`" - "\nAvailable commands: extract, update, compile, init" - ) - - # get the language from parameters default to en. - # it can be deceiving but we don't have a table of accepted languages yet - lan = "en" if len(session.posargs) < 2 else session.posargs[-1] - - # get the path to the differnet local related pieces - locale_dir = str(ROOT / "src" / "pydata_sphinx_theme" / "locale") - babel_cfg = str(ROOT / "babel.cfg") - pot_file = str(locale_dir / "sphinx.pot") - - # install deps + """Update translation related files.""" + session.install("Babel", "jinja2") + + # fmt: off + session.run( # generate/update the .pot file + "pybabel", "extract", ".", + "-F", str(babel_cfg.relative_to(root_dir)), + "-o", str(pot_file.relative_to(root_dir)), + ) + # fmt: on + + # update the message catalog (.po) + languages = [f.stem for f in locale_dir.iterdir() if f.is_dir()] + # fmt: off + cmd = [ + "pybabel", "update", + "-i", str(pot_file.relative_to(root_dir)), + "-d", str(locale_dir.relative_to(root_dir)), + ] + # fmt: on + for lan in languages: + session.run(*cmd, "-l", lan) + + +@session(default=False) +def add_language(session: nox.Session) -> None: + """Add a language to the catalog using posargs.""" session.install("Babel") - # build the command from the parameters - cmd = ["pybabel", pybabel_cmd] - - if pybabel_cmd == "extract": - cmd += [ROOT, "-F", babel_cfg, "-o", pot_file, "-k", "_ __ l_ lazy_gettext"] - - elif pybabel_cmd == "update": - cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx"] - - elif pybabel_cmd == "compile": - cmd += ["-d", locale_dir, "-D", "sphinx"] - - elif pybabel_cmd == "init": - cmd += ["-i", pot_file, "-d", locale_dir, "-D", "sphinx", "-l", lan] + # get the language name from posargs + if len(session.posargs) != 1: + raise ValueError( + f"There should be only one posargs: the ISO code of the languge, {len(session.posargs)} given." + ) + lan = session.posargs[0] - session.run(cmd) + # init new language + # fmt: off + session.run( + "pybabel", "init", + "-i", str(pot_file), + "-d", str(locale_dir), + "-l", lan, + ) + # fmt: on -@nox.session() +@session() def profile(session: nox.Session) -> None: """Generate a profile chart with py-spy. The chart will be placed at profile.svg.""" if _should_install(session): diff --git a/pyproject.toml b/pyproject.toml index bee28fcdb..a6dbf3c84 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ dependencies = [ "beautifulsoup4", "docutils!=0.17.0", "packaging", - "Babel", "pygments>=2.7", "accessible-pygments", "typing-extensions" @@ -76,7 +75,7 @@ doc = [ "colorama", ] test = ["pytest", "pytest-cov", "pytest-regressions"] -dev = ["pyyaml", "pre-commit", "nox", "pydata-sphinx-theme[doc,test]"] +dev = ["pyyaml", "pre-commit", "nox", "pydata-sphinx-theme[doc,test]", "Babel"] a11y = ["pytest-playwright"] [project.entry-points] diff --git a/src/pydata_sphinx_theme/__init__.py b/src/pydata_sphinx_theme/__init__.py index 0c9c97741..9ec0ec072 100644 --- a/src/pydata_sphinx_theme/__init__.py +++ b/src/pydata_sphinx_theme/__init__.py @@ -10,9 +10,20 @@ from requests.exceptions import ConnectionError, HTTPError, RetryError from sphinx.application import Sphinx from sphinx.errors import ExtensionError + +# from sphinx.locale import get_translation from sphinx.util import logging -from . import edit_this_page, logo, pygment, short_link, toctree, translator, utils +from . import ( + edit_this_page, + i18n, + logo, + pygment, + short_link, + toctree, + translator, + utils, +) __version__ = "0.13.4dev0" @@ -284,6 +295,7 @@ def setup(app: Sphinx) -> Dict[str, str]: """Setup the Sphinx application.""" here = Path(__file__).parent.resolve() theme_path = here / "theme" / "pydata_sphinx_theme" + app.i18n_catalog_added = False app.add_html_theme("pydata_sphinx_theme", str(theme_path)) @@ -291,6 +303,7 @@ def setup(app: Sphinx) -> Dict[str, str]: app.connect("builder-inited", translator.setup_translators) app.connect("builder-inited", update_config) + app.connect("html-page-context", i18n.compile_translation) app.connect("html-page-context", edit_this_page.setup_edit_url) app.connect("html-page-context", toctree.add_toctree_functions) app.connect("html-page-context", update_and_remove_templates) diff --git a/src/pydata_sphinx_theme/i18n.py b/src/pydata_sphinx_theme/i18n.py new file mode 100644 index 000000000..a0b954e39 --- /dev/null +++ b/src/pydata_sphinx_theme/i18n.py @@ -0,0 +1,16 @@ +"""Compile the .mo file at build time.""" + +from pathlib import Path + +from sphinx.application import Sphinx + + +def compile_translation(app: Sphinx, *args): + """Compile the .mo file at build time. + + The property app.i18n_catalog_added is added to ensure that the catalog is added only once per run instead of once per HTML file. + """ + if not app.i18n_catalog_added: + locale_dir = (Path(__file__).parents[1] / "locale").resolve() + app.add_message_catalog("sphinx", str(locale_dir)) + app.i18n_catalog_added = True diff --git a/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/messages.po similarity index 82% rename from src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po rename to src/pydata_sphinx_theme/locale/en/LC_MESSAGES/messages.po index d49d524f6..fdd7a48fc 100644 --- a/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/en/LC_MESSAGES/messages.po @@ -1,13 +1,14 @@ -# English translations for pydata-sphinx-theme. -# Copyright (C) 2023 PyData developers -# This file is distributed under the same license as the pydata-sphinx-theme project. +# English translations for PROJECT. +# Copyright (C) 2023 ORGANIZATION +# This file is distributed under the same license as the PROJECT project. +# FIRST AUTHOR , 2023. # msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-02-16 14:32-0500\n" -"PO-Revision-Date: 2023-02-16 13:19-0500\n" +"POT-Creation-Date: 2023-04-17 07:45+0200\n" +"PO-Revision-Date: 2023-04-17 07:25+0200\n" "Last-Translator: FULL NAME \n" "Language: en\n" "Language-Team: en \n" @@ -15,7 +16,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.11.0\n" +"Generated-By: Babel 2.12.1\n" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html:50 msgid "Skip to main content" @@ -66,22 +67,6 @@ msgstr "" msgid "Edit" msgstr "" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:31 -msgid "GitHub" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:32 -msgid "GitLab" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:33 -msgid "Bitbucket" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:34 -msgid "Twitter" -msgstr "" - #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:2 msgid "Indices" msgstr "" @@ -98,7 +83,7 @@ msgstr "" msgid "Python Module Index" msgstr "" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:2 +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:3 #, python-format msgid "Last updated on %(last_updated)s." msgstr "" @@ -112,6 +97,22 @@ msgstr "" msgid "On this page" msgstr "" +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:6 +msgid "previous page" +msgstr "" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:9 +msgid "previous" +msgstr "" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:17 +msgid "next page" +msgstr "" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:19 +msgid "next" +msgstr "" + #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:2 #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:3 msgid "Section Navigation" @@ -140,18 +141,3 @@ msgid "" "%(theme_version)s." msgstr "" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:6 -msgid "previous page" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:9 -msgid "previous" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:17 -msgid "next page" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:19 -msgid "next" -msgstr "" diff --git a/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/messages.po similarity index 83% rename from src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po rename to src/pydata_sphinx_theme/locale/es/LC_MESSAGES/messages.po index cd51d2404..b040b6ab4 100644 --- a/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/es/LC_MESSAGES/messages.po @@ -1,24 +1,24 @@ # English translations for pydata-sphinx-theme. # Copyright (C) 2023 PyData developers # This file is distributed under the same license as the pydata-sphinx-theme project. -# +# # Translators: # Rambaud Pierrick , 2023 -# +# msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-02-16 14:32-0500\n" -"PO-Revision-Date: 2023-04-14 14:57+0000\n" -"Last-Translator: Rambaud Pierrick , 2023\n" -"Language-Team: Spanish (https://app.transifex.com/12rambau/teams/166811/es/)\n" +"POT-Creation-Date: 2023-04-17 07:45+0200\n" +"PO-Revision-Date: 2023-04-17 07:25+0200\n" +"Last-Translator: FULL NAME \n" +"Language: es\n" +"Language-Team: es \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.11.0\n" -"Language: es\n" -"Plural-Forms: nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" +"Generated-By: Babel 2.12.1\n" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html:50 msgid "Skip to main content" @@ -70,22 +70,6 @@ msgstr "Editar en %(provider)s" msgid "Edit" msgstr "Editar" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:31 -msgid "GitHub" -msgstr "GitHub" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:32 -msgid "GitLab" -msgstr "GitLab" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:33 -msgid "Bitbucket" -msgstr "Bitbucket" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:34 -msgid "Twitter" -msgstr "Twitter" - #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:2 msgid "Indices" msgstr "Índices" @@ -102,7 +86,7 @@ msgstr "Índice Global de Módulos" msgid "Python Module Index" msgstr "Índice de Módulos Python" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:2 +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:3 #, python-format msgid "Last updated on %(last_updated)s." msgstr "Actualizado por última vez en %(last_updated)s." @@ -116,6 +100,22 @@ msgstr "Navegación del sitio" msgid "On this page" msgstr "En esta página" +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:6 +msgid "previous page" +msgstr "página anterior" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:9 +msgid "previous" +msgstr "anterior" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:17 +msgid "next page" +msgstr "siguiente página" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:19 +msgid "next" +msgstr "siguiente" + #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:2 #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:3 msgid "Section Navigation" @@ -149,18 +149,3 @@ msgstr "" "theme.readthedocs.io/en/stable/index.html\">Tema PyData Sphinx " "%(theme_version)s." -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:6 -msgid "previous page" -msgstr "página anterior" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:9 -msgid "previous" -msgstr "anterior" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:17 -msgid "next page" -msgstr "siguiente página" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:19 -msgid "next" -msgstr "siguiente" diff --git a/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po b/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/messages.po similarity index 79% rename from src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po rename to src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/messages.po index 88bb44ecf..dcf6388c3 100644 --- a/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/sphinx.po +++ b/src/pydata_sphinx_theme/locale/fr/LC_MESSAGES/messages.po @@ -1,24 +1,24 @@ # English translations for pydata-sphinx-theme. # Copyright (C) 2023 PyData developers # This file is distributed under the same license as the pydata-sphinx-theme project. -# +# # Translators: # Rambaud Pierrick , 2023 -# +# msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-02-16 14:32-0500\n" -"PO-Revision-Date: 2023-04-14 14:57+0000\n" -"Last-Translator: Rambaud Pierrick , 2023\n" -"Language-Team: French (https://app.transifex.com/12rambau/teams/166811/fr/)\n" +"POT-Creation-Date: 2023-04-17 07:45+0200\n" +"PO-Revision-Date: 2023-04-17 07:25+0200\n" +"Last-Translator: FULL NAME \n" +"Language: fr\n" +"Language-Team: fr \n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.11.0\n" -"Language: fr\n" -"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n" +"Generated-By: Babel 2.12.1\n" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html:50 msgid "Skip to main content" @@ -44,7 +44,7 @@ msgstr "Fils d'Ariane" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html:13 msgid "Breadcrumb" -msgstr "Fil d'Ariane" +msgstr "Fils d'Ariane" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/breadcrumbs.html:16 msgid "Home" @@ -69,39 +69,23 @@ msgstr "Modifier sur %(provider)s" msgid "Edit" msgstr "Modifier" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:31 -msgid "GitHub" -msgstr "GitHub" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:32 -msgid "GitLab" -msgstr "GitLab" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:33 -msgid "Bitbucket" -msgstr "Bitbucket" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:34 -msgid "Twitter" -msgstr "Twitter" - #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:2 msgid "Indices" msgstr "Indices" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:9 msgid "General Index" -msgstr "Index général" +msgstr "" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:13 msgid "Global Module Index" -msgstr "Index général des modules" +msgstr "Index général" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:17 msgid "Python Module Index" -msgstr "Index des modules Python" +msgstr "Index général des modules" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:2 +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:3 #, python-format msgid "Last updated on %(last_updated)s." msgstr "Mis à jour le %(last_updated)s." @@ -115,6 +99,22 @@ msgstr "Navigation du site" msgid "On this page" msgstr "Sur cette page" +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:6 +msgid "previous page" +msgstr "page précédente" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:9 +msgid "previous" +msgstr "précédent" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:17 +msgid "next page" +msgstr "page suivante" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:19 +msgid "next" +msgstr "suivant" + #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:2 #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:3 msgid "Section Navigation" @@ -129,9 +129,7 @@ msgstr "Montrer le code source" msgid "" "Created using Sphinx " "%(sphinx_version)s." -msgstr "" -"Créé en utilisant Sphinx " -"%(sphinx_version)s." +msgstr "%(sphinx_version)s." #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/theme-switcher.html:5 msgid "light/dark" @@ -148,18 +146,3 @@ msgstr "" "theme.readthedocs.io/en/stable/index.html\">Thème PyData Sphinx " "%(theme_version)s." -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:6 -msgid "previous page" -msgstr "page précédente" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:9 -msgid "previous" -msgstr "précédente" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:17 -msgid "next page" -msgstr "page suivante" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:19 -msgid "next" -msgstr "suivante" diff --git a/src/pydata_sphinx_theme/locale/sphinx.pot b/src/pydata_sphinx_theme/locale/messages.pot similarity index 86% rename from src/pydata_sphinx_theme/locale/sphinx.pot rename to src/pydata_sphinx_theme/locale/messages.pot index 09447d00e..183e28528 100644 --- a/src/pydata_sphinx_theme/locale/sphinx.pot +++ b/src/pydata_sphinx_theme/locale/messages.pot @@ -8,14 +8,14 @@ msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2023-02-16 14:32-0500\n" +"POT-Creation-Date: 2023-04-17 07:45+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" -"Generated-By: Babel 2.9.1\n" +"Generated-By: Babel 2.12.1\n" #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/layout.html:50 msgid "Skip to main content" @@ -66,22 +66,6 @@ msgstr "" msgid "Edit" msgstr "" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:31 -msgid "GitHub" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:32 -msgid "GitLab" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:33 -msgid "Bitbucket" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/icon-links.html:34 -msgid "Twitter" -msgstr "" - #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/indices.html:2 msgid "Indices" msgstr "" @@ -98,7 +82,7 @@ msgstr "" msgid "Python Module Index" msgstr "" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:2 +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/last-updated.html:3 #, python-format msgid "Last updated on %(last_updated)s." msgstr "" @@ -112,6 +96,22 @@ msgstr "" msgid "On this page" msgstr "" +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:6 +msgid "previous page" +msgstr "" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:9 +msgid "previous" +msgstr "" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:17 +msgid "next page" +msgstr "" + +#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/prev-next.html:19 +msgid "next" +msgstr "" + #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:2 #: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/sidebar-nav-bs.html:3 msgid "Section Navigation" @@ -140,18 +140,3 @@ msgid "" "%(theme_version)s." msgstr "" -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:6 -msgid "previous page" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:9 -msgid "previous" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:17 -msgid "next page" -msgstr "" - -#: src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/footer-article/prev-next.html:19 -msgid "next" -msgstr "" diff --git a/tests/test_build.py b/tests/test_build.py index d49a3d0e1..a3bf34125 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -861,6 +861,7 @@ def test_translations(sphinx_build_factory) -> None: index = sphinx_build.html_tree("section1/index.html") sidebar_primary = index.select(".bd-sidebar-primary")[0] + print(sidebar_primary) assert "Navigation du site" in str(sidebar_primary) assert "Navigation de la section" in str(sidebar_primary) diff --git a/webpack.config.js b/webpack.config.js index 77d18d9e6..16b6ff05b 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -18,13 +18,6 @@ const CssMinimizerPlugin = require("css-minimizer-webpack-plugin"); const dedent = require("dedent"); const { Compilation } = require("webpack"); -/******************************************************************************* - * Compile our translation files - */ -const { exec } = require("child_process"); -const localePath = resolve(__dirname, "src/pydata_sphinx_theme/locale"); -exec(`pybabel compile -d ${localePath} -D sphinx`); - /******************************************************************************* * Paths for various assets (sources and destinations) */