Skip to content

Commit

Permalink
changes: nice formatting of removed strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Aug 8, 2023
1 parent 8ebd538 commit b1a8387
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions weblate/templates/last-changes-content.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@
{% else %}
{% format_unit_source change.unit %}
{% endif %}
{% elif change.show_removed_string %}
<label>{{ change.component.source_translation.language }}</label>
{% format_language_string change.details.source change.component.source_translation %}
{% if change.details.target and not change.translation.is_source %}
<label>{{ change.translation.language }}</label>
{% format_language_string change.details.target change.translation %}
{% endif %}
{% elif change.target %}
<pre>{{ change.target }}</pre>
{% else %}
Expand Down
4 changes: 4 additions & 0 deletions weblate/trans/models/change.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
13 changes: 13 additions & 0 deletions weblate/trans/templatetags/translations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b1a8387

Please sign in to comment.