Show translation template if there aren't any content translations

This commit is contained in:
rubenwardy 2024-07-18 07:25:32 +01:00
parent 80c3416ca7
commit 9c2ecd1e22
2 changed files with 15 additions and 12 deletions

@ -458,6 +458,7 @@ def move_to_state(package):
@is_package_page
def translation(package):
return render_template("packages/translation.html", package=package,
has_content_translations=any([x.title or x.short_desc for x in package.translations.all()]),
tabs=get_package_tabs(current_user, package), current_tab="translation")

@ -26,18 +26,6 @@
{{ _("Translating content meta - lua_api.md") }}
</a>
</p>
<h3 id="template">{{ _("Translation template") }}</h3>
<p>
{{ _("To quickly add support for ContentDB package translation, create a file at %(location)s with the following content:",
location="<code>locale/template.txt</code>"|safe) }}
</p>
<pre><code># textdomain: {{ package.name }}
{{ package.title | replace("@", "@@") | replace("=", "@=") }} =
{{ package.short_desc | replace("@", "@@") | replace("=", "@=") }} =
</code></pre>
{% else %}
<p>
{{ _("%(title)s is available in %(num)d languages.", title=package.title, num=num) }}
@ -89,5 +77,19 @@
</div>
{% endfor %}
{% endif %}
{% if not has_content_translations %}
<h3 id="template">{{ _("Translation template") }}</h3>
<p>
{{ _("To quickly add support for ContentDB package translation, create a file at %(location)s with the following content:",
location="<code>locale/template.txt</code>"|safe) }}
</p>
<pre><code># textdomain: {{ package.name }}
{{ package.title | replace("@", "@@") | replace("=", "@=") }} =
{{ package.short_desc | replace("@", "@@") | replace("=", "@=") }} =
</code></pre>
{% endif %}
</div>
{% endblock %}