Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 12 additions & 0 deletions contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,18 @@ upload manually to `TestPyPI <https://test.pypi.org>`_ instead.
$ twine upload --repository testpypi dist/*
$ pip install --index-url https://test.pypi.org/simple/ sphinx-codeautolink

Translations
------------
You are also welcome to contribute translations!
Use the following Babel commands to add new translations and locales.

.. code:: sh

$ cd src/sphinx_codeautolink
$ pybabel init --input-file=locale/sphinx-codeautolink.pot --domain=sphinx-codeautolink --output-dir=locale --locale=fi_FI
$ pybabel update --input-file=locale/sphinx-codeautolink.pot --domain=sphinx-codeautolink --output-dir=locale
$ pybabel compile --directory=locale --domain=sphinx-codeautolink

.. |issue_resolution| image:: http://isitmaintained.com/badge/resolution/felix-hilden/sphinx-codeautolink.svg
:target: https://isitmaintained.com/project/felix-hilden/sphinx-codeautolink
:alt: issue resolution time
Expand Down
1 change: 1 addition & 0 deletions docs/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sphinx-codeautolink adheres to

Unreleased
----------
- Add translations via i18n (:issue:`164`)
- Fix attribute and call after walrus leading parser error (:issue:`174`)
- Fix parsing error in doctest blocks with empty lines (:issue:`176`)
- Improve error message on uncaught parsing errors (:issue:`177`)
Expand Down
7 changes: 7 additions & 0 deletions src/sphinx_codeautolink/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""Sphinx extension for linking code examples to reference documentation."""

from pathlib import Path

from sphinx.application import Sphinx

from .extension import SphinxCodeAutoLink, backref, directive
from .extension.block import clean_ipython, clean_pycon
from .extension.translation import MESSAGE_CATALOG_NAME

__version__ = "0.17.0"

Expand Down Expand Up @@ -76,4 +79,8 @@ def setup(app: Sphinx):
app.add_node(
backref.SummaryNode, html=(backref.visit_summary, backref.depart_summary)
)

locale_dir = Path(__file__).resolve().parent / "locale"
app.add_message_catalog(MESSAGE_CATALOG_NAME, locale_dir)

return {"version": __version__, "env_version": 1, "parallel_read_safe": True}
5 changes: 3 additions & 2 deletions src/sphinx_codeautolink/extension/backref.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from sphinx_codeautolink.warn import logger, warn_type

from .directive import DeferredExamples
from .translation import tr


@dataclass
Expand Down Expand Up @@ -112,7 +113,7 @@ def unknown_visit(self, node) -> None:
entry = nodes.entry()
row += entry
title = nodes.paragraph()
title += nodes.Text("References to ")
title += nodes.Text(tr("References to") + " ")
title += orig_ref
entry += title

Expand All @@ -132,7 +133,7 @@ def unknown_visit(self, node) -> None:
if node.collapse:
details = DetailsNode()
summary = SummaryNode()
summary += nodes.Text("Expand for references to ")
summary += nodes.Text(tr("Expand for references to") + " ")
summary += orig_ref
details += summary
details += table
Expand Down
6 changes: 6 additions & 0 deletions src/sphinx_codeautolink/extension/translation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""Translation utilities."""

from sphinx.locale import get_translation

MESSAGE_CATALOG_NAME = "sphinx-codeautolink"
tr = get_translation(MESSAGE_CATALOG_NAME)
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# German (Germany) translations for sphinx-codeautolink.
# Copyright (C) 2025 ORGANIZATION
# This file is distributed under the same license as the sphinx-codeautolink project.
# Colin Marquardt <[email protected]>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: 1\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2025-02-23 17:30+0200\n"
"PO-Revision-Date: 2025-02-23 18:42+0100\n"
"Last-Translator: Colin Marquardt <[email protected]>\n"
"Language: de_DE\n"
"Language-Team: Colin Marquardt <[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.17.0\n"

msgid "References to"
msgstr "Referenzen auf"

msgid "Expand for references to"
msgstr "Aufklappen für Referenzen auf"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Spanish (Spain) translations for sphinx-codeautolink.
# Copyright (C) 2025 ORGANIZATION
# This file is distributed under the same license as the sphinx-codeautolink project.
# Felix Hildén <[email protected]>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: 1\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2025-02-23 17:30+0200\n"
"PO-Revision-Date: 2025-02-23 18:05+0200\n"
"Last-Translator: Felix Hildén <[email protected]>\n"
"Language: es_ES\n"
"Language-Team: Felix Hildén <[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.17.0\n"

msgid "References to"
msgstr "Referencias a"

msgid "Expand for references to"
msgstr "Amplíe para referencias a"
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Finnish (Finland) translations for sphinx-codeautolink.
# Copyright (C) 2025 ORGANIZATION
# This file is distributed under the same license as the sphinx-codeautolink project.
# Felix Hildén <[email protected]>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: 1\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2025-02-23 17:30+0200\n"
"PO-Revision-Date: 2025-02-23 17:32+0200\n"
"Last-Translator: Felix Hildén <[email protected]>\n"
"Language: fi_FI\n"
"Language-Team: Felix Hildén <[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.17.0\n"

msgid "References to"
msgstr "Viitteet kohteeseen"

msgid "Expand for references to"
msgstr "Avaa nähdäksesi viitteet kohteeseen"
24 changes: 24 additions & 0 deletions src/sphinx_codeautolink/locale/sphinx-codeautolink.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Translations template for sphinx-codeautolink.
# Copyright (C) 2025 ORGANIZATION
# This file is distributed under the same license as the sphinx-codeautolink project.
# Felix Hildén <[email protected]>, 2025.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: 1\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: 2025-02-23 17:30+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: Felix Hildén <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.17.0\n"

msgid "References to"
msgstr ""

msgid "Expand for references to"
msgstr ""
Loading