{% extends "admin/base.html" %} {% block primary_content_inner %}

{{ _('AI translation') }}

{% snippet 'ai_translation/admin/_nav.html', active='instructions', ai_settings_url=ai_settings_url %} {# Which languages, at the top (browser tests 2026-11-26 and 27: they were only named under the trial). #} {% if per_language and source_language_name %}{% set names = per_language | map(attribute='language') | list %}

{{ _('Translates from {source} into {targets}.').format(source=source_language_name, targets=(names[:-1] | join(', ') ~ ' ' ~ _('and') ~ ' ' ~ names[-1]) if names | length > 1 else names | join('')) }}

{% endif %} {% if ai_problem %}
{{ _('The AI cannot translate yet, so this instruction is not used:') }} {{ ai_problem }} {% if ai_settings_url %}{{ _('AI settings') }}{% endif %}
{% elif ai_settings_url %}

{{ _('The model that translates is chosen on the page') }} {{ _('AI settings') }}.

{% endif %}

{{ _('This is the whole instruction to the AI for a translation. The text here is only our default: change any of it to fit this catalogue. {source} and {target} are replaced by the names of the languages. The answer format is asked for separately in every request, and each request also carries the texts to translate: the title, description and keywords, and the further fields turned on under More fields.') }}

{{ _('The built-in part is in English, which the AI follows best. Your own text can be in any language.') }}

{{ _('Sent with every translation as well, per language, from the metadata schema:') }}

{% if per_language %} {% else %}

{{ _('The metadata schema names no languages to translate into.') }}

{% endif %} {# #trial: after a trial, or a trial that failed, the page opens at the trial, its result and its errors #}
{{ h.csrf_input() }} {{ _('Now:') }} {% if saved and not instructions %}{{ _('empty: the AI gets no instruction') }}{% elif saved %}{{ _('changed on this page') }}{% else %}{{ _('the default text is used') }}{% endif %} {% for e in errors.instructions or [] %}{{ e }}{% endfor %} {{ _('Emptying the field sends the AI no instruction at all. “Use the default text” brings our default back.') }} {% if saved %}
{{ _('Show the default text') }}
{{ default }}
{% endif %}

{{ _('Try on a dataset') }}

{{ _('Runs the AI with the text in the form, without saving it. Nothing in the dataset changes.') }} {% if per_language %}{% set names = per_language | map(attribute='language') | list %}{{ _('It translates into {languages}. This can take up to a minute.').format(languages=(names[:-1] | join(', ') ~ ' ' ~ _('and') ~ ' ' ~ names[-1]) if names | length > 1 else names | join('')) }}{% endif %}

{% for e in errors.dataset or [] %}{{ e }}{% endfor %}
{% for e in errors.trial or [] %}
{{ e }}
{% endfor %} {% if trial %}
{{ _('Trial with the text in the form (nothing is saved)') }} {% for s in trial.suggestions %}
{{ s.label }} ({{ s.language_label }}): {{ s.suggested_value if s.suggested_value is string else s.suggested_value | join(', ') }}
{{ s.source_language_label }}: {{ s.source_value if s.source_value is string else s.source_value | join(', ') }}
{% else %}

{{ _('Nothing to translate in this dataset.') }}

{% endfor %} {% for f in trial.failed %}
{{ f.language_label }}: {{ f.error }}
{% endfor %}
{% endif %}
{% if saved %}
{{ h.csrf_input() }}
{% endif %} {% endblock %}