From b1a83876a39766845e3188ae27bccf639a909ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 8 Aug 2023 14:24:55 +0200 Subject: [PATCH] changes: nice formatting of removed strings --- weblate/templates/last-changes-content.html | 7 +++++++ weblate/trans/models/change.py | 4 ++++ weblate/trans/templatetags/translations.py | 13 +++++++++++++ 3 files changed, 24 insertions(+) diff --git a/weblate/templates/last-changes-content.html b/weblate/templates/last-changes-content.html index cdda91e8424e..1cc8dbcc050f 100644 --- a/weblate/templates/last-changes-content.html +++ b/weblate/templates/last-changes-content.html @@ -82,6 +82,13 @@ {% else %} {% format_unit_source change.unit %} {% endif %} + {% elif change.show_removed_string %} + + {% format_language_string change.details.source change.component.source_translation %} + {% if change.details.target and not change.translation.is_source %} + + {% format_language_string change.details.target change.translation %} + {% endif %} {% elif change.target %}
{{ change.target }}
{% else %} diff --git a/weblate/trans/models/change.py b/weblate/trans/models/change.py index f4015290f693..fcc25746303a 100644 --- a/weblate/trans/models/change.py +++ b/weblate/trans/models/change.py @@ -638,6 +638,10 @@ def show_source(self): """Whether to show content as source change.""" return self.action in (self.ACTION_SOURCE_CHANGE, self.ACTION_NEW_SOURCE) + def show_removed_string(self): + """Whether to show content as source change.""" + return self.action == self.ACTION_STRING_REMOVE + def show_content(self): """Whether to show content as translation.""" return ( diff --git a/weblate/trans/templatetags/translations.py b/weblate/trans/templatetags/translations.py index 0ad0923058f3..a07fd712a8b7 100644 --- a/weblate/trans/templatetags/translations.py +++ b/weblate/trans/templatetags/translations.py @@ -378,6 +378,19 @@ def format_source_string( ) +@register.inclusion_tag("snippets/format-translation.html") +def format_language_string( + value: str, + translation, +): + """Formats simple string as in the language.""" + return format_translation( + plurals=split_plural(value), + language=translation.language, + plural=translation.plural, + ) + + def format_translation( plurals: list[str], language=None,