Skip to content

Commit 1653f39

Browse files
committed
feat(add-ons): add pot update support
- currently limited to xgettext, Django and Sphinx - we have not intention for generic solution here Fixes #10708 Fixes #18428
1 parent 3e8f720 commit 1653f39

29 files changed

+3260
-206
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include *.md
55
include *.py
66
recursive-include weblate/examples *
77
include weblate/billing/test-data/*
8+
include weblate/addons/extractors/sphinx/docutils.conf
89
include weblate/trans/tests/data/*
910
include weblate/trans/fixtures/simple-project.json
1011
recursive-include sbom *.json

docs/Makefile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ BUILDDIR = _build
1616
help:
1717
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
1818

19-
.PHONY: help Makefile update-po update-screenshots update-schemas update-openapi update-doc-snippets run-selenium
19+
.PHONY: help Makefile update-screenshots update-schemas update-openapi update-docs run-selenium
2020

2121
run-selenium:
2222
@rm -rf ../data-test ../test-images
@@ -51,16 +51,6 @@ update-docs:
5151
@uv run --no-sync ../manage.py list_checks -s checks -o snippets/checks-autogenerated.rst
5252
@uv run --no-sync ../manage.py list_checks -s flags -o snippets/check-flags-autogenerated.rst
5353

54-
update-po: $(wildcard locales/*/LC_MESSAGES/docs.po)
55-
56-
locales/%/LC_MESSAGES/docs.po: locales/docs.pot
57-
@if ! test -h locales/$* ; then msgmerge -U $@ -C ../weblate/locale/$*/LC_MESSAGES/django.po --previous $< ; fi
58-
59-
locales/docs.pot: gettext
60-
@cp _build/gettext/docs.pot $@
61-
@../scripts/filter-docs-po.py $@
62-
63-
6454
# Catch-all target: route all unknown targets to Sphinx using the new
6555
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
6656
%: Makefile

docs/admin/install.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ Django REST Framework
254254
* - ``saml2idp``
255255
- | `djangosaml2idp2 <https://pypi.org/project/djangosaml2idp2>`_
256256
- Integrating SAML 2 IDP into Weblate
257+
* - ``sphinx``
258+
- | `Sphinx <https://pypi.org/project/Sphinx>`_
259+
- Needed for :ref:`addon-weblate.gettext.sphinx`
257260

258261
* - ``wlhosted``
259262
- | `wlhosted <https://pypi.org/project/wlhosted>`_

docs/changes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Weblate 5.17
88
* Added :setting:`WEBSITE_ALERTS_ENABLED` setting to allow disabling project website availability checks and alerts.
99
* Shared components can now be categorized within the target project.
1010
* :ref:`api` supports specifying a category when sharing a component via ``category_id`` parameter.
11+
* Added :ref:`addon-weblate.gettext.xgettext`, :ref:`addon-weblate.gettext.django`, and :ref:`addon-weblate.gettext.sphinx` to update POT files with configurable update cadence.
1112

1213
.. rubric:: Improvements
1314

docs/snippets/addons-autogenerated.rst

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1456,6 +1456,107 @@ Reset repository to upstream
14561456
Discards all changes in the Weblate repository each night.
14571457

14581458
.. AUTOGENERATED END: weblate.hosted.reset
1459+
.. AUTOGENERATED START: weblate.gettext.django
1460+
.. This section is automatically generated by `./manage.py list_addons`. Do not edit manually.
1461+
1462+
.. _addon-weblate.gettext.django:
1463+
1464+
Update POT file (Django)
1465+
------------------------
1466+
1467+
.. versionadded:: 5.17
1468+
1469+
:Add-on ID: ``weblate.gettext.django``
1470+
:Configuration: +----------------------+----------------------+----------------------------------------------------------------------------------+
1471+
| ``interval`` | Update frequency | How often the add-on should update the POT file when the component is refreshed. |
1472+
| | | |
1473+
| | | .. list-table:: Available choices: |
1474+
| | | :width: 100% |
1475+
| | | |
1476+
| | | * - ``daily`` |
1477+
| | | - Daily |
1478+
| | | * - ``weekly`` |
1479+
| | | - Weekly |
1480+
| | | * - ``monthly`` |
1481+
| | | - Monthly |
1482+
+----------------------+----------------------+----------------------------------------------------------------------------------+
1483+
| ``normalize_header`` | Normalize POT header | Updates selected gettext header fields using component configuration. |
1484+
+----------------------+----------------------+----------------------------------------------------------------------------------+
1485+
1486+
:Triggers: :ref:`addon-event-add-on-installation`, :ref:`addon-event-repository-post-update`
1487+
1488+
Updates the gettext template using Django's built-in makemessages command.
1489+
1490+
.. AUTOGENERATED END: weblate.gettext.django
1491+
.. AUTOGENERATED START: weblate.gettext.sphinx
1492+
.. This section is automatically generated by `./manage.py list_addons`. Do not edit manually.
1493+
1494+
.. _addon-weblate.gettext.sphinx:
1495+
1496+
Update POT file (Sphinx)
1497+
------------------------
1498+
1499+
.. versionadded:: 5.17
1500+
1501+
:Add-on ID: ``weblate.gettext.sphinx``
1502+
:Configuration: +----------------------+----------------------+----------------------------------------------------------------------------------+
1503+
| ``interval`` | Update frequency | How often the add-on should update the POT file when the component is refreshed. |
1504+
| | | |
1505+
| | | .. list-table:: Available choices: |
1506+
| | | :width: 100% |
1507+
| | | |
1508+
| | | * - ``daily`` |
1509+
| | | - Daily |
1510+
| | | * - ``weekly`` |
1511+
| | | - Weekly |
1512+
| | | * - ``monthly`` |
1513+
| | | - Monthly |
1514+
+----------------------+----------------------+----------------------------------------------------------------------------------+
1515+
| ``normalize_header`` | Normalize POT header | Updates selected gettext header fields using component configuration. |
1516+
+----------------------+----------------------+----------------------------------------------------------------------------------+
1517+
1518+
:Triggers: :ref:`addon-event-add-on-installation`, :ref:`addon-event-repository-post-update`
1519+
1520+
Updates the gettext template using Sphinx's gettext builder without loading
1521+
project configuration.
1522+
1523+
.. AUTOGENERATED END: weblate.gettext.sphinx
1524+
.. AUTOGENERATED START: weblate.gettext.xgettext
1525+
.. This section is automatically generated by `./manage.py list_addons`. Do not edit manually.
1526+
1527+
.. _addon-weblate.gettext.xgettext:
1528+
1529+
Update POT file (xgettext)
1530+
--------------------------
1531+
1532+
.. versionadded:: 5.17
1533+
1534+
:Add-on ID: ``weblate.gettext.xgettext``
1535+
:Configuration: +----------------------+----------------------+-----------------------------------------------------------------------------------------+
1536+
| ``interval`` | Update frequency | How often the add-on should update the POT file when the component is refreshed. |
1537+
| | | |
1538+
| | | .. list-table:: Available choices: |
1539+
| | | :width: 100% |
1540+
| | | |
1541+
| | | * - ``daily`` |
1542+
| | | - Daily |
1543+
| | | * - ``weekly`` |
1544+
| | | - Weekly |
1545+
| | | * - ``monthly`` |
1546+
| | | - Monthly |
1547+
+----------------------+----------------------+-----------------------------------------------------------------------------------------+
1548+
| ``normalize_header`` | Normalize POT header | Updates selected gettext header fields using component configuration. |
1549+
+----------------------+----------------------+-----------------------------------------------------------------------------------------+
1550+
| ``language`` | xgettext language | Programming language passed to xgettext, for example Python or C. |
1551+
+----------------------+----------------------+-----------------------------------------------------------------------------------------+
1552+
| ``source_patterns`` | Source file patterns | Newline-separated repository-relative glob patterns for files to extract with xgettext. |
1553+
+----------------------+----------------------+-----------------------------------------------------------------------------------------+
1554+
1555+
:Triggers: :ref:`addon-event-add-on-installation`, :ref:`addon-event-repository-post-update`
1556+
1557+
Updates the gettext template using xgettext on selected source files.
1558+
1559+
.. AUTOGENERATED END: weblate.gettext.xgettext
14591560
14601561
14611562
.. Depreciated Addons

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ alibaba = [
197197
"aliyun-python-sdk-core>=2.16.0,<3.0.0"
198198
]
199199
all = [
200-
"weblate[alibaba,amazon,gerrit,gelf,google,ldap,mercurial,openai,postgres,zxcvbn]"
200+
"weblate[alibaba,amazon,gerrit,gelf,google,ldap,mercurial,openai,postgres,sphinx,zxcvbn]"
201201
]
202202
amazon = [
203203
"boto3>=1.38.0,<2.0"
@@ -230,6 +230,9 @@ saml = [
230230
saml2idp = [
231231
"djangosaml2idp2==0.9.1"
232232
]
233+
sphinx = [
234+
"Sphinx"
235+
]
233236
wlhosted = [
234237
"wlhosted"
235238
]
@@ -633,6 +636,7 @@ zip-safe = false
633636

634637
[tool.setuptools.package-data]
635638
weblate = [
639+
"addons/extractors/sphinx/docutils.conf",
636640
"locale/**/*.mo",
637641
"locale/**/*.po",
638642
"locale/**/*.pot",

scripts/filter-docs-po.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

scripts/update-locales

Lines changed: 0 additions & 89 deletions
This file was deleted.

uv.lock

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)