Skip to content

Commit

Permalink
Fix german mistranslations
Browse files Browse the repository at this point in the history
  • Loading branch information
Ajordat committed Jul 7, 2024
1 parent 8802a9c commit 6599ea0
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
<tr data-href="{% url 'deck-detail' pk=deck.id %}">
<td>
{% if user.is_superuser %}
<a role="button" href="#" class="btn btn-sm btn-outline-secondary disabled {% if deck.hit_count.hits < 10 %}me-3{% else %}me-2{% endif %}">
<i class="fa-solid fa-eye"></i> {{ deck.hit_count.hits }}
{% with hits=deck.hit_count.hits %}
<a role="button" href="#" class="btn btn-sm btn-outline-secondary disabled {% if hits < 10 %}me-3{% else %}me-2{% endif %}">
<i class="fa-solid fa-eye"></i> {{ hits }}
</a>
{% endwith %}
{% endif %}
<a role="button" href="#" class="btn btn-sm btn-outline-danger {%if deck.id in loved_decks %}active{% else %}disabled{% endif %}">
<i class="fa-solid fa-heart"></i> {{ deck.love_count }}
Expand Down
35 changes: 28 additions & 7 deletions alteredbuilder/decks/templatetags/markdown_extras.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,26 @@

ALTERED_API = "https://www.altered.gg/cards/"
REFERENCE_RE = r"\[\[(.*?)\]\]"
ICON_LIST = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "etb", "exhaust", "forest", "hand", "mountain", "reserve", "discard", "water", "x"]
ICON_LIST = [
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"etb",
"exhaust",
"forest",
"hand",
"mountain",
"reserve",
"discard",
"water",
"x",
]


class InlineCardReferenceProcessor(InlineProcessor):
Expand Down Expand Up @@ -50,13 +69,13 @@ def extendMarkdown(self, md: md.Markdown) -> None:

class InlineImageProcessor(Treeprocessor):
def run(self, root: Element) -> Element | None:
for element in root.iter('img'):
for element in root.iter("img"):
attrib = element.attrib
tail = element.tail
element.clear()
element.tag = 'a'
element.attrib['href'] = attrib.pop('src')
element.text = attrib.pop('alt')
element.tag = "a"
element.attrib["href"] = attrib.pop("src")
element.text = attrib.pop("alt")
element.tail = tail
# element.attrib |= attrib
for k, v in attrib.items():
Expand All @@ -65,7 +84,7 @@ def run(self, root: Element) -> Element | None:

class ImageExtension(Extension):
def extendMarkdown(self, md: md.Markdown) -> None:
md.treeprocessors.register(InlineImageProcessor(), 'inlineimageprocessor', 20)
md.treeprocessors.register(InlineImageProcessor(), "inlineimageprocessor", 20)


register = template.Library()
Expand All @@ -82,4 +101,6 @@ def markdown(value: str) -> str:
Returns:
str: HTML code version of the received string.
"""
return md.markdown(value, extensions=["markdown_mark", AlteredExtension(), ImageExtension()])
return md.markdown(
value, extensions=["markdown_mark", AlteredExtension(), ImageExtension()]
)
27 changes: 22 additions & 5 deletions alteredbuilder/decks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,31 @@ def get_context_data(self, **kwargs) -> dict[str, Any]:
context["loved_decks"] = LovePoint.objects.filter(
user=self.request.user
).values_list("deck__id", flat=True)

if self.request.user.is_superuser:
last_week = timezone.now() - timedelta(days=14)
lps = LovePoint.objects.filter(created_at__date__gt=last_week, deck__is_public=True).values("deck").annotate(total=Count("deck"))[:6]
context["most_loved"] = Deck.objects.filter(id__in=[lp["deck"] for lp in lps]).order_by("-love_count").select_related("owner", "hero")
lps = (
LovePoint.objects.filter(
created_at__date__gt=last_week, deck__is_public=True
)
.values("deck")
.annotate(total=Count("deck"))[:6]
)
context["most_loved"] = (
Deck.objects.filter(id__in=[lp["deck"] for lp in lps])
.order_by("-love_count")
.select_related("owner", "hero")
)

hits = Hit.objects.filter(created__date__gt=last_week).values("hitcount", "hitcount__object_pk").annotate(total=Count("hitcount")).order_by("-total")[:6]
context["trending"] = Deck.objects.filter(id__in=[hit["hitcount__object_pk"] for hit in hits]).select_related("owner", "hero")
hits = (
Hit.objects.filter(created__date__gt=last_week)
.values("hitcount", "hitcount__object_pk")
.annotate(total=Count("hitcount"))
.order_by("-total")[:6]
)
context["trending"] = Deck.objects.filter(
id__in=[hit["hitcount__object_pk"] for hit in hits]
).select_related("owner", "hero")

# Extract the filters applied from the GET params and add them to the context
# to fill them into the template
Expand Down
Binary file modified alteredbuilder/locale/de/LC_MESSAGES/django.mo
Binary file not shown.
16 changes: 8 additions & 8 deletions alteredbuilder/locale/de/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -189,22 +189,22 @@ msgstr "Name Z-A"
#: decks/templates/decks/card_list.html:78
#: decks/templates/decks/card_list.html:98
msgid "Mana ASC"
msgstr ""
msgstr "Mana aufsteigend"

#: decks/templates/decks/card_list.html:79
#: decks/templates/decks/card_list.html:99
msgid "Mana DESC"
msgstr ""
msgstr "Mana absteigend"

#: decks/templates/decks/card_list.html:80
#: decks/templates/decks/card_list.html:100
msgid "Reserve ASC"
msgstr "Reservieren ASC"
msgstr "Reserve aufsteigend"

#: decks/templates/decks/card_list.html:81
#: decks/templates/decks/card_list.html:101
msgid "Reserve DESC"
msgstr "Reservieren DESC"
msgstr "Reserve absteigend"

#: decks/templates/decks/card_list.html:94
msgid "Order"
Expand Down Expand Up @@ -302,7 +302,7 @@ msgstr "Deck löschen"

#: decks/templates/decks/deck_detail.html:92
msgid "This feature cannot be used with unique cards"
msgstr "Diese Funktion kann nicht mit eindeutigen Karten verwendet werden"
msgstr "Diese Funktion kann nicht mit einzigartigen Karten verwendet werden"

#: decks/templates/decks/deck_detail.html:94
#: decks/templates/decks/deck_detail.html:100
Expand Down Expand Up @@ -364,7 +364,7 @@ msgstr "Zauber"
#: decks/templates/decks/deck_detail.html:172
#: decks/templates/decks/deck_detail.html:231
msgid "Permanents"
msgstr "Festangestellte"
msgstr "Bleibende Karte"

#: decks/templates/decks/deck_detail.html:180
msgid "Stats"
Expand Down Expand Up @@ -392,7 +392,7 @@ msgstr "Jederzeit"

#: decks/templates/decks/deck_detail.html:216
msgid "Initial hand"
msgstr "Anfangszeiger"
msgstr "Starthand"

#: decks/templates/decks/deck_detail.html:237
msgid "Format legality"
Expand Down Expand Up @@ -543,7 +543,7 @@ msgstr ""
#: decks/templates/decks/snippets/card_table.html:34
#, python-format
msgid "No %(type)ss"
msgstr "Nein %(type)ss"
msgstr "Kein %(type)ss"

#: decks/templates/decks/snippets/pagination.html:9
#: decks/templates/decks/snippets/pagination.html:15
Expand Down
Binary file modified alteredbuilder/locale/de/LC_MESSAGES/djangojs.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion alteredbuilder/locale/de/LC_MESSAGES/djangojs.po
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,4 @@ msgstr ""

#: decks/static/js/deck-stats.js:80
msgid "Reserve"
msgstr "Reservieren"
msgstr "Reserve"

0 comments on commit 6599ea0

Please sign in to comment.