{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% load translations %}

{% block breadcrumbs %}
<li><a href="{{ unit.translation.subproject.project.get_absolute_url }}">{{ unit.translation.subproject.project }}</a></li>
<li><a href="{{ unit.translation.subproject.get_absolute_url }}">{{ unit.translation.subproject.name }}</a></li>
<li><a href="{{ unit.translation.get_absolute_url }}">{{ unit.translation.language }}</a></li>
<li><a href="{{ unit.translation.get_translate_url }}">{% trans "translate" %}</a></li>
{% endblock %}

{% block content %}

<h2>{% trans "Translate" %}</h2>

<span id="navi-toolbar" class="ui-widget-header ui-corner-all">
<span class="navi">
<a class="button-first" href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;pos=1&amp;dir=stay{{ search_url }}">{% trans "First" %}</a>
<a class="button-prev" href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;pos={{ unit.position }}&amp;dir=back{{ search_url }}">{% trans "Previous" %}</a>
<a class="button-pos">{% blocktrans with unit.position as position %}{{ position }} / {{ total }}{% endblocktrans %}</a>
<a class="button-next" href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;pos={{ unit.position }}{{ search_url }}">{% trans "Next" %}</a>
<a class="button-end" href="{{ unit.translation.get_translate_url }}?type={{ type }}&amp;pos={{ total }}&amp;dir=stay{{ search_url }}">{% trans "Last" %}</a>
</span>

{% if filter_name %}
{% blocktrans %}Current filter: {{ filter_name }} ({{ filter_pos }} / {{ filter_count }}){% endblocktrans %}
{% endif %}
</span>

<form action="{{ unit.translation.get_translate_url }}" method="post">
{% csrf_token %}
{% if antispam %}<div id="s_content">{{ antispam }}</div>{% endif %}
<input type="hidden" name="type" value="{{ type }}" />
<input type="hidden" name="pos" value="{{ unit.position }}" />
<input type="hidden" name="q" value="{{ search_query }}" />
<input type="hidden" name="exact" value="{{ search_exact }}" />
<input type="hidden" name="src" value="{{ search_source }}" />
<input type="hidden" name="tgt" value="{{ search_target }}" />
<input type="hidden" name="ctx" value="{{ search_context }}" />
<table class="translator">
{% if secondary %}
{% for unit in secondary %}
<tr>
<th class="source">{{ unit.translation.language }}</th>
<td class="translatetext">{{ unit.target|fmttranslation:unit.translation.language }}</td>
</tr>
{% endfor %}
{% endif %}
<tr>
<th class="source">{% trans "Source" %}</th>
<td class="translatetext">{{ unit.source|fmttranslation }}</td>
</tr>
{% if unit.context %}
<tr>
<th>{% trans "Context" %}</th>
<td>{{ unit.context }}</td>
</tr>
{% endif %}
<tr>
<td></td>
<td class="toolbar"><a href="#" id="copy-text">{% trans "Copy" %}</a><img src="/media/loading.gif" id="loading" style="display: none" /></td>
</tr>
<tr>
<th>{% if unit.is_plural %}{% trans "Translations" %}{% else %}{% trans "Translation" %}{% endif %}</th>
<td class="translator">
{{ form.checksum }}
{{ form.target }}
<br />
{{ form.fuzzy }}<label for="id_fuzzy">{% trans "Fuzzy" context "Message is fuzzy" %}</label>
</td></tr>
{% with unit.active_checks as checks %}
{% if checks %}
<tr>
<th>{% trans "Failing checks" %}</th>
<td>
{% for check in checks %}
<span class="check" id="check-{{ check.id }}">
{% if perms.trans.ignore_check %}
<a href="#" class="ignorecheck" title="{% blocktrans with check.get_check_display as check %}Ignore: {{ check }}{% endblocktrans %}"></a>
{% endif %}
<a href="{{ check.get_doc_url }}" title="{{ check.get_description }}">{{ check.get_check_display }}</a>
</span>
{% endfor %}
</td>
</tr>
{% endif %}
{% endwith %}
{% with unit.suggestions as suggestions %}
{% if suggestions %}
<tr>
<th>{% trans "Suggestions" %}</th>
<td class="suggestions">
<table>
{% for suggestion in suggestions %}
<tr><td class="translatetext">{{ suggestion.target|fmttranslation:unit.translation.language }}</td></tr>
<tr><td>
{% if suggestion.user %}
{% blocktrans with suggestion.user.get_full_name as user %}Suggested by {{ user }}{% endblocktrans %}
{% else %}
{% trans "Suggested by anonymous user" %}
{% endif %}
{% if perms.trans.accept_suggestion or perms.trans.delete_suggestion %}
<div class="suggestionactions">
{% if perms.trans.accept_suggestion %}
<a href="{{ suggestion.get_translate_url }}?type={{ type }}&amp;pos={{ unit.position }}&amp;accept={{ suggestion.id }}{{ search_url }}" class="sug-accept">{% trans "Accept" %}</a>
{% endif %}
{% if perms.trans.delete_suggestion %}
<a href="{{ suggestion.get_translate_url }}?type={{ type }}&amp;pos={{ unit.position }}&amp;delete={{ suggestion.id }}{{ search_url }}" class="sug-delete">{% trans "Delete" %}</a>
{% endif %}
</div>
{% endif %}
</td>
{% endfor %}
</table>
</td>
</tr>
{% endif %}
{% endwith %}
{% if unit.location %}
<tr>
<th>{% trans "Used in" %}</th>
<td>{{ unit.get_location_links }}</td>
</tr>
{% endif %}
{% if unit.comment %}
<tr>
<th>{% trans "Comments" %}</th>
<td>{{ unit.comment }}</td>
</tr>
{% endif %}
{% if unit.flags %}
<tr>
<th>{% trans "Flags" %}</th>
<td>{{ unit.flags }}</td>
</tr>
{% endif %}
<tr><td></td><td>
{% if perms.trans.save_translation %}
<input class="button" type="submit" value="{% trans "Save" %}" name="save" tabindex="150" />
{% else %}
{% url 'django.contrib.auth.views.login' as login_url %}
{% with unit.translation.get_translate_url as translate_url %}
{% blocktrans %}<a href="{{ login_url }}?next={{ translate_url }}">Log in</a> for saving translations.{% endblocktrans %}
{% endwith %}
{% endif %}
<input class="button" type="submit" value="{% trans "Suggest" %}" name="suggest" tabindex="151" />
</td></tr>

</table>
</form>

<h2>{% trans "Translation context" %}</h2>

<div class="translate-tabs">
    <ul>
        <li><a href="#tab-nearby" title="{% trans "Messages placed around this one" %}">{% trans "Nearby messages" %}</a></li>
        <li><a href="/js/similar/{{ unit.id }}/" title="{% trans "Similar messages" %}">{% trans "Similar messages" %}</a></li>
        <li><a href="/js/other/{{ unit.id }}/?type={{ type }}&amp;pos={{ unit.position }}{{ search_url }}" title="{% trans "Same message used in different subprojects" %}">{% trans "All locations" %}</a></li>
        <li><a href="/js/dictionary/{{ unit.id }}/" title="{% trans "Words extracted from dictionary" %}">{% trans "Words in dictionary" %}</a></li>
        <li><a href="#tab-changes" title="{% trans "List of recent changes done in Weblate" %}">{% trans "Recent edits" %}</a></li>
        <li><a href="#tab-project" title="{% trans "Information about project" %}">{% trans "Project" %}</a></li>
    </ul>
    <div id="tab-nearby">
    <table>
    <thead>
    <tr><th></th><th>{% trans "Source" %}</th><th>{% trans "Translation" %}</th><th>{% trans "State" %}</th></tr>
    </thead>
    <tbody>
    {% for item in unit.nearby %}
    <tr>
    <td class="number"><a href="{{ item.get_absolute_url }}">{{ item.position }}</a></td>
    <td class="translatetext"><a href="{{ item.get_absolute_url }}">{{ item.source|fmttranslation }}</a></td>
    <td class="translatetext"><a href="{{ item.get_absolute_url }}">{{ item.target|fmttranslation:unit.translation.language }}</a></td>
    <td>{% include "unit-state.html" %}</td>
    </tr>
    {% endfor %}
    </tbody>
    </table>
    </div>
    <div id="tab-changes">
    {% if changes %}
    <table>
    {% for change in changes %}
    <tr>
    <td>{{ change.user.get_full_name }}</td>
    <td>{{ change.timestamp|date:"DATETIME_FORMAT" }}</td>
    </tr>
    {% endfor %}
    </table>
    {% else %}
    <p>{% trans "No recent activity has been recorded." %}</p>
    {% endif %}
    </div>
    <div id="tab-project">
    {% include "translation_info.html" %}
    </div>
</div>

{% endblock %}



