{# We replace '.%l' with the actual language only when it occurs as an extension at the end of the string and only when #}
{# there isn't another file with that name. This allows to securily reverse the replacement and should work great in #}
{# the common case. Yet, it still allows the marginal case of both 'foo.%l' and 'foo.c' in the submission format. #}
{% set files = iterkeys(t.files)|list + iterkeys(t.managers)|list %}
{% if files|length == 0 %}
{% trans %}None{% endtrans %}
{% elif files|length == 1 %}
{% set filename = next(iterkeys(t.files)) %}
{% set real_filename = filename|replace(".%l", (t.language|to_language).source_extension) %}
{% trans %}Download{% endtrans %}
{% else %}
{% for filename in files %}
{% if t.language is not none %}
{% set real_filename = filename|replace(".%l", (t.language|to_language).source_extension) %}
{% else %}
{% set real_filename = filename %}
{% endif %}