-
Notifications
You must be signed in to change notification settings - Fork 356
i18n: Add full support #399
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
Changes from 12 commits
cf9fb89
44ad97f
41eca95
cff2374
ad60582
a4a6d68
67f1c7a
13526fd
5fab594
9bf8192
fb8f3c4
ce6ddae
069749d
ff6334b
df72f79
05d6eff
babd3c3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| include babel.cfg | ||
| include MANIFEST.in | ||
| include LICENSE | ||
| include README.md | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| # See https://github.com/sphinx-doc/sphinx/blob/4.x/babel.cfg | ||
| [jinja2: **.html] | ||
| encoding = utf-8 | ||
| ignore_tags = script,style | ||
| include_attrs = alt title summary placeholder |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| Internationalization | ||
| ==================== | ||
|
|
||
jpmckinney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| This theme contains translatable strings. Most strings 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`. | ||
|
|
||
| The theme's :doc:`options<configuring>` also contain translatable strings, which require a different process. The following 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. | ||
jpmckinney marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| #. In your ``conf.py`` file: | ||
|
|
||
| .. code-block:: python | ||
| import os.path | ||
| from sphinx.locale import get_translation | ||
| catalog = "theme" | ||
| _ = get_translation(catalog) | ||
| html_theme_options = { | ||
| "search_bar_text": _("Search the docs..."), | ||
| # You only need to translate the following if you use these features. | ||
| "icon_links_label": _("Quick Links"), | ||
| "icon_links": [ | ||
| { | ||
| "name": _("GitHub"), | ||
| "url": "https://github.com/<your-org>/<your-repo>", | ||
| "icon": "fab fa-github-square", | ||
| }, | ||
| ], | ||
| "external_links": [ | ||
| { | ||
| "name": _("link-one-name"), | ||
| "url": "https://<link-one>", | ||
| }, | ||
| ], | ||
| } | ||
| def setup(app): | ||
| locale_dir = os.path.join(os.path.abspath(os.path.dirname(__file__), "locale") | ||
| app.add_message_catalog(catalog, locale_dir) | ||
| #. Extract the strings to translate: | ||
| .. code-block:: bash | ||
| pybabel extract . -o locale/theme.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 | ||
| #. Translate the message catalog by editing the file. | ||
| #. Compile the message catalog: | ||
| .. code-block:: bash | ||
| pybabel compile --directory=locale --domain=theme | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,4 @@ User Guide | |
| configuring | ||
| sections | ||
| customizing | ||
| i18n | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -517,6 +517,9 @@ def setup(app): | |
| app.add_html_theme("pydata_sphinx_theme", theme_path) | ||
| app.set_translator("html", BootstrapHTML5Translator) | ||
|
|
||
| # https://www.sphinx-doc.org/en/master/extdev/i18n.html#extension-internationalization-i18n-and-localization-l10n-using-i18n-api | ||
| app.add_message_catalog("sphinx", os.path.join(theme_path, "locale")) | ||
|
|
||
| # Read the Docs uses ``readthedocs`` as the name of the build, and also | ||
| # uses a special "dirhtml" builder so we need to replace these both with | ||
| # our custom HTML builder | ||
|
|
@@ -529,7 +532,7 @@ def setup(app): | |
|
|
||
| # Update templates for sidebar | ||
| pkgdir = os.path.abspath(os.path.dirname(__file__)) | ||
| path_templates = os.path.join(pkgdir, "_templates") | ||
| path_templates = os.path.join(pkgdir, "templates") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Flag for @jorisvandenbossche, any reason we wouldn’t want to use templates wo the underscore? I don’t think this would affect anything downstream There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It won't affect theme users. When theme users override a template, it's based on the file's basename, not on its path within a particular theme, to my knowledge. |
||
| app.config.templates_path.append(path_templates) | ||
|
|
||
| return {"parallel_read_safe": True, "parallel_write_safe": True} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # Spanish translations for pydata-sphinx-theme. | ||
| # Copyright (C) 2021 ORGANIZATION | ||
| # This file is distributed under the same license as the pydata-sphinx-theme | ||
| # project. | ||
| # FIRST AUTHOR <EMAIL@ADDRESS>, 2021. | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: pydata-sphinx-theme 0.6.1\n" | ||
| "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" | ||
| "POT-Creation-Date: 2021-04-22 16:46-0400\n" | ||
| "PO-Revision-Date: 2021-04-22 16:46-0400\n" | ||
| "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
| "Language: es\n" | ||
| "Language-Team: es <[email protected]>\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.9.0\n" | ||
|
|
||
| #: pydata_sphinx_theme/docs-navbar.html:9 | ||
| msgid "Toggle navigation" | ||
| msgstr "Alternar navegación" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:14 | ||
| msgid "GitHub" | ||
| msgstr "GitHub" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:15 | ||
| msgid "GitLab" | ||
| msgstr "GitLab" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:16 | ||
| msgid "Bitbucket" | ||
| msgstr "Bitbucket" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:17 | ||
| msgid "Twitter" | ||
| msgstr "Twitter" | ||
|
|
||
| #: pydata_sphinx_theme/layout.html:7 | ||
| msgid "previous page" | ||
| msgstr "página anterior" | ||
|
|
||
| #: pydata_sphinx_theme/layout.html:10 | ||
jpmckinney marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| msgid "next page" | ||
| msgstr "siguiente página" | ||
|
|
||
| #: pydata_sphinx_theme/templates/copyright.html:3 | ||
| #, python-format | ||
| msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s." | ||
| msgstr "© <a href=\"%(path)s\">Copyright</a> %(copyright)s." | ||
|
|
||
| #: pydata_sphinx_theme/templates/copyright.html:5 | ||
| #, python-format | ||
| msgid "© Copyright %(copyright)s." | ||
| msgstr "© Copyright %(copyright)s." | ||
|
|
||
| #: pydata_sphinx_theme/templates/edit-this-page.html:5 | ||
| msgid "Edit this page" | ||
| msgstr "Editar esta página" | ||
|
|
||
| #: pydata_sphinx_theme/templates/last-updated.html:2 | ||
| #, python-format | ||
| msgid "Last updated on %(last_updated)s." | ||
| msgstr "Última actualización el %(last_updated)s" | ||
|
|
||
| #: pydata_sphinx_theme/templates/page-toc.html:5 | ||
| msgid "On this page" | ||
| msgstr "En esta página" | ||
|
|
||
| #: pydata_sphinx_theme/templates/sidebar-nav-bs.html:1 | ||
| msgid "Main navigation" | ||
| msgstr "Navegación principal" | ||
|
|
||
| #: pydata_sphinx_theme/templates/sphinx-version.html:2 | ||
| #, python-format | ||
| msgid "" | ||
| "Created using <a href=\"http://sphinx-doc.org/\">Sphinx</a> " | ||
| "%(sphinx_version)s." | ||
| msgstr "Creado con <a href=\"http://sphinx-doc.org/\">Sphinx</a> " | ||
| "%(sphinx_version)s." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| # French translations for pydata-sphinx-theme. | ||
| # Copyright (C) 2021 ORGANIZATION | ||
| # This file is distributed under the same license as the pydata-sphinx-theme | ||
| # project. | ||
| # FIRST AUTHOR <EMAIL@ADDRESS>, 2021. | ||
| # | ||
| msgid "" | ||
| msgstr "" | ||
| "Project-Id-Version: pydata-sphinx-theme 0.6.1\n" | ||
| "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" | ||
| "POT-Creation-Date: 2021-04-22 16:46-0400\n" | ||
| "PO-Revision-Date: 2021-04-22 16:46-0400\n" | ||
| "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" | ||
| "Language: fr\n" | ||
| "Language-Team: fr <[email protected]>\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.9.0\n" | ||
|
|
||
| #: pydata_sphinx_theme/docs-navbar.html:9 | ||
| msgid "Toggle navigation" | ||
| msgstr "Basculer la navigation" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:14 | ||
| msgid "GitHub" | ||
| msgstr "GitHub" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:15 | ||
| msgid "GitLab" | ||
| msgstr "GitLab" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:16 | ||
| msgid "Bitbucket" | ||
| msgstr "Bitbucket" | ||
|
|
||
| #: pydata_sphinx_theme/icon-links.html:17 | ||
| msgid "Twitter" | ||
| msgstr "Twitter" | ||
|
|
||
| #: pydata_sphinx_theme/layout.html:7 | ||
| msgid "previous page" | ||
| msgstr "page précédente" | ||
|
|
||
| #: pydata_sphinx_theme/layout.html:10 | ||
| msgid "next page" | ||
| msgstr "page suivante" | ||
|
|
||
| #: pydata_sphinx_theme/templates/copyright.html:3 | ||
| #, python-format | ||
| msgid "© <a href=\"%(path)s\">Copyright</a> %(copyright)s." | ||
| msgstr "© <a href=\"%(path)s\">Droit d'auteur</a> %(copyright)s." | ||
|
|
||
| #: pydata_sphinx_theme/templates/copyright.html:5 | ||
| #, python-format | ||
| msgid "© Copyright %(copyright)s." | ||
| msgstr "© Droit d'auteur %(copyright)s." | ||
|
|
||
| #: pydata_sphinx_theme/templates/edit-this-page.html:5 | ||
| msgid "Edit this page" | ||
| msgstr "Modifier cette page" | ||
|
|
||
| #: pydata_sphinx_theme/templates/last-updated.html:2 | ||
| #, python-format | ||
| msgid "Last updated on %(last_updated)s." | ||
| msgstr "Dernière mise à jour le %(last_updated)s." | ||
|
|
||
| #: pydata_sphinx_theme/templates/page-toc.html:5 | ||
| msgid "On this page" | ||
| msgstr "Sur cette page" | ||
|
|
||
| #: pydata_sphinx_theme/templates/sidebar-nav-bs.html:1 | ||
| msgid "Main navigation" | ||
| msgstr "Navigation principale" | ||
|
|
||
| #: pydata_sphinx_theme/templates/sphinx-version.html:2 | ||
| #, python-format | ||
| msgid "" | ||
| "Created using <a href=\"http://sphinx-doc.org/\">Sphinx</a> " | ||
| "%(sphinx_version)s." | ||
| msgstr "Créé à l'aide de <a href=\"http://sphinx-doc.org/\">Sphinx</a> " | ||
| "%(sphinx_version)s." |
Uh oh!
There was an error while loading. Please reload this page.