Use package translation on tiles

This commit is contained in:
rubenwardy 2024-02-25 18:48:42 +00:00
parent 9173d3c578
commit 1b5791a358
2 changed files with 6 additions and 5 deletions

@ -494,7 +494,7 @@ class Package(db.Model):
def get_id(self):
return "{}/{}".format(self.author.username, self.name)
def get_translated(self, lang=None):
def get_translated(self, lang=None, load_desc=True):
if lang is None:
locale = get_locale()
if locale:
@ -510,13 +510,13 @@ class Package(db.Model):
return {
"title": self.title,
"short_desc": self.short_desc,
"desc": self.desc,
"desc": self.desc if load_desc else None,
}
return {
"title": translation.title or self.title,
"short_desc": translation.short_desc or self.short_desc,
"desc": translation.desc or self.desc,
"desc": (translation.desc or self.desc) if load_desc else None,
}
def get_sorted_dependencies(self, is_hard=None):

@ -1,10 +1,11 @@
{% macro render_pkgtile(package, show_author) -%}
{% set meta = package.get_translated(load_desc=False) %}
<li class="packagetile flex-fill"><a href="{{ package.get_url('packages.view') }}">
<img src="{{ package.get_thumb_or_placeholder() }}" loading="lazy">
<div class="packagegridscrub"></div>
<div class="packagegridinfo">
<h3>
{{ package.title }}
{{ meta.title }}
{% if show_author %}<br />
<small>{{ package.author.display_name }}</small>
@ -17,7 +18,7 @@
</h3>
<p>
{{ package.short_desc }}
{{ meta.short_desc }}
</p>
{% if not package.license.is_foss and not package.media_license.is_foss and package.type != package.type.TXP %}