Skip to content

Commit

Permalink
feat(alerts): add monolingual glossary alert
Browse files Browse the repository at this point in the history
Things will not work as expected in this setup, so be clear in this.

See #11520
  • Loading branch information
nijel committed May 7, 2024
1 parent 790ab12 commit d77a150
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Released on May 9th 2024.

* Visually highlight explanation in :ref:`glossary`.
* Add :ref:`addons` history tab in management.
* New :ref:`alerts` when :ref:`glossary` might not work as expected.

**Bug fixes**

Expand Down
6 changes: 6 additions & 0 deletions weblate/templates/trans/alert/monolingualglossary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% load i18n %}
{% load translations %}

<p>{% trans "Using monolingual files as a glossary is not recommended because adding strings to target language only is not possible in monolingual files." %}</p>

<p>{% trans "You can continue using the glossary this way, but some features will be unavailable." %}</p>
11 changes: 11 additions & 0 deletions weblate/trans/models/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -657,3 +657,14 @@ def check_component(component: Component) -> bool | None | dict:
oldest_change = component.change_set.order_by("timestamp").first()
# Weird, each component should have change
return oldest_change is None or oldest_change.timestamp < cutoff


@register
class MonolingualGlossary(BaseAlert):
verbose = gettext_lazy("Glossary using monolingual files.")
doc_page = "user/glossary"
dismissable = True

@staticmethod
def check_component(component: Component) -> bool | None | dict:
return component.is_glossary and bool(component.template)

0 comments on commit d77a150

Please sign in to comment.