Skip to content

Commit a39d8f4

Browse files
committed
index: Localize Weblate badge on i18n instances
It will now show the translation status for the used language instead of the overall completion for all languages. The badge widget's text is also in the used language. The drawback is that to do this I had to inject the localized image directive in the `rst_epilog` for all pages, even though we only need it for the index.
1 parent 08b390f commit a39d8f4

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

conf.py

+8
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,11 @@
110110
# Exclude class reference when marked with tag i18n.
111111
if is_i18n:
112112
exclude_patterns = ['classes']
113+
# Couldn't find a way to retrieve variables nor do advanced string
114+
# concat from reST, so had to hardcode this in the "epilog" added to
115+
# all pages. This is used in index.rst to display the Weblate badge.
116+
rst_epilog = """
117+
.. |weblate_widget| image:: https://hosted.weblate.org/widgets/godot-engine/{weblate_locale}/godot-docs/287x66-white.png
118+
:alt: Translation status
119+
:target: https://hosted.weblate.org/engage/godot-engine/{weblate_locale}/?utm_source=widget
120+
""".format(weblate_locale = language)

index.rst

+11-4
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,17 @@ in the top left corner.
5151
``#godotengine-doc`` channel on `irc.freenode.net
5252
<http://webchat.freenode.net/?channels=#godotengine-doc>`_!
5353

54-
.. image:: https://hosted.weblate.org/widgets/godot-engine/-/godot-docs/287x66-white.png
55-
:alt: Translation state
56-
:align: center
57-
:target: https://hosted.weblate.org/engage/godot-engine/?utm_source=widget
54+
.. only:: not i18n
55+
56+
.. image:: https://hosted.weblate.org/widgets/godot-engine/-/godot-docs/287x66-white.png
57+
:alt: Translation status
58+
:align: center
59+
:target: https://hosted.weblate.org/engage/godot-engine/?utm_source=widget
60+
61+
.. only:: i18n
62+
63+
.. centered:: |weblate_widget|
64+
5865

5966
The main documentation for the site is organized into the following sections:
6067

0 commit comments

Comments
 (0)