Skip to content

Commit

Permalink
chore: use format_html_join_comma
Browse files Browse the repository at this point in the history
This allows to localize the comma.
  • Loading branch information
nijel committed Feb 17, 2025
1 parent 1e89587 commit 0b54da6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ repos:
files: docs/changes\.rst
entry: ^ *\* .*[^.]\n$
language: pygrep
- id: py-join-comma
name: Localized comma in join
types: [python]
args: [--multiline]
entry: format_html_join\(\s*", "
language: pygrep
- repo: https://github.com/sphinx-contrib/sphinx-lint
rev: v1.0.0
hooks:
Expand Down
4 changes: 2 additions & 2 deletions weblate/checks/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from siphashc import siphash

from weblate.utils.docs import get_doc_url
from weblate.utils.html import format_html_join_comma
from weblate.utils.xml import parse_xml

if TYPE_CHECKING:
Expand Down Expand Up @@ -309,8 +310,7 @@ def format_value(self, value: str) -> StrOrPromise:
def get_values_text(self, message: str, values: Iterable[str]) -> StrOrPromise:
return format_html(
message,
format_html_join(
", ",
format_html_join_comma(
"{}",
((self.format_value(value),) for value in sorted(values)),
),
Expand Down
7 changes: 4 additions & 3 deletions weblate/checks/glossary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import re
from typing import TYPE_CHECKING

from django.utils.html import escape, format_html, format_html_join
from django.utils.html import escape, format_html
from django.utils.translation import gettext, gettext_lazy

from weblate.checks.base import SourceCheck, TargetCheck
from weblate.utils.csv import PROHIBITED_INITIAL_CHARS
from weblate.utils.html import format_html_join_comma

if TYPE_CHECKING:
from weblate.trans.models import Unit
Expand Down Expand Up @@ -80,7 +81,7 @@ def get_description(self, check_obj):
escape(
gettext("Following terms are not translated according to glossary: {}")
),
format_html_join(", ", "{}", ((term,) for term in sorted(results))),
format_html_join_comma("{}", ((term,) for term in sorted(results))),
)


Expand All @@ -104,5 +105,5 @@ def get_description(self, check_obj) -> str:
"The string starts with one or more of the following forbidden characters: {}"
)
),
format_html_join(", ", "{}", PROHIBITED_INITIAL_CHARS),
format_html_join_comma("{}", PROHIBITED_INITIAL_CHARS),
)

0 comments on commit 0b54da6

Please sign in to comment.