Skip to content

Commit

Permalink
Show translation template if there aren't any content translations
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenwardy committed Jul 18, 2024
1 parent 80c3416 commit 9c2ecd1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
1 change: 1 addition & 0 deletions app/blueprints/packages/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
26 changes: 14 additions & 12 deletions app/templates/packages/translation.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ <h2 class="mt-0 mb-4">{{ self.title() }}</h2>
{{ _("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) }}
Expand Down Expand Up @@ -89,5 +77,19 @@ <h3 id="template">{{ _("Translation template") }}</h3>
</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 %}

0 comments on commit 9c2ecd1

Please sign in to comment.