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

{% block breadcrumbs %}
<li><a href="{{ object.subproject.project.get_absolute_url }}">{{ object.subproject.project }}</a></li>
<li><a href="{{ object.subproject.get_absolute_url }}">{{ object.subproject.name }}</a></li>
<li><a href="{{ object.get_absolute_url }}">{{ object.language }}</a></li>
{% endblock %}

{% block content %}

{% include "show-lock.html" %}

<h2>{% trans "Project Information" %}</h2>

<a class="menu-float" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image-lang' project=object.subproject.project.slug widget='shields' color='badge' lang=object.language.code extension='svg' %}" />
</a>

<table class="info">
{% include "translation_info.html" %}
</table>

{% with object.get_translation_checks as checks%}
{% if checks %}
<h2>{% trans "Strings to check" %}</h2>
<ul>
{% for c in checks %}
<li><a href="{{ object.get_translate_url }}?type={{ c.0 }}">{{ c.1 }}</a></li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}

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

<div class="tabs" id="translation-tabs">
<ul>
<li><a href="#changes">{% trans "History" %}</a></li>
<li><a href="#search">{% trans "Search" %}</a></li>
<li><a href="#files">{% trans "Files" %}</a></li>
{% if autoform %}
<li><a href="#auto">{% trans "Automatic translation" %}</a></li>
{% endif %}
{% if perms.trans.commit_translation or perms.trans.update_translation %}
<li><a href="{% url 'git_status_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Git maintenance" %}</a></li>
{% endif %}
<li><a href="#locking">{% trans "Locking" %}</a></li>
<li><a href="#share">{% trans "Share" %}</a></li>
<li><a href="#stats">{% trans "Stats" %}</a></li>
<li><a href="{% url 'view_activity_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Activity" %}</a></li>
</ul>

<div id="search">
<form action="{{ object.get_translate_url }}" method="GET">
{{ search_form.as_p }}
<input type="submit" value="{% trans "Search" %}" class="button" />
</form>
</div>

<div id="files">

<h3>{% trans "Download" %}</h3>
{% url 'download_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code as download_url %}
<p>{% blocktrans %}You can <a href="{{ download_url }}">download</a> file for offline translation.{% endblocktrans %}</p>

{% if object.supports_language_pack %}
{% url 'download_language_pack' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code as pack_download_url %}
<p>{% blocktrans %}You can also <a href="{{ pack_download_url }}">download</a> compiled file to use within the application.{% endblocktrans %}</p>
{% endif %}

{% if perms.trans.upload_translation %}
<h3>{% trans "Upload" %}</h3>
{% if perms.trans.overwrite_translation %}
<p>{% trans "Uploaded file will be merged with current translation. In case you want to overwrite already translated strings, don't forget to enable it." %}</p>
{% else %}
<p>{% trans "Uploaded file will be merged with current translation." %}</p>
{% endif %}

<form action="{% url 'upload_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<p><input type="submit" value="{% trans "Upload" %}" class="button" /></p>
</form>
{% endif %}
</div>

<div id="changes">

<h3>{% trans "History" %}</h3>
{% include "last-changes.html" %}

{% if review_form %}
<h3>{% trans "Review" %}</h3>

<p>{% trans "Review translations touched by other users." %}</p>
<form action="{{ object.get_translate_url }}" method="GET">
<table>
{{ review_form.as_table }}
</table>
<p><input type="submit" value="{% trans "Start review" %}" class="button" /></p>
</form>
{% endif %}
</div>

{% if autoform %}
<div id="auto">
<p>{% trans "Automatic translation takes existing translations in this project and applies it to the current subproject. It can be used to push translations to a different branch, to fix inconsistent translations or to translate new subproject using translation memory." %}</p>
<form action="{% url 'auto_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<table>
{{ autoform.as_table }}
</table>
<p><input type="submit" value="{% trans "Process" %}" class="button" /></p>
</form>
</div>
{% endif %}

<div id="locking">
<p>{% trans "Locking the translation will prevent others to work on translation." %}</p>
{% if object.is_user_locked %}
<p>{% trans "Locked by:" %} {{ object.get_lock_user_display }}</p>
<p>{% trans "Lock expires:" %} {{ object.lock_time|naturaltime }}</p>
{% else %}
<p>{% trans "Translation is currently not locked." %}</p>
{% endif %}
{% if perms.trans.lock_translation %}
{% if object.lock_user == request.user %}
<a class="button" href="{% url 'unlock_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Unlock" %}</a>
{% elif not object.is_user_locked %}
<a class="button" href="{% url 'lock_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Lock" %}</a>
{% endif %}
{% endif %}
</div>

<div id="share">
{% with object.subproject.project as project %}
{% include 'share.html' %}
{% endwith %}
</div>

<div id="stats">
<table>
<tr>
<td></td>
<th>{% trans "Percent" %}</th>
<th>{% trans "Strings" %}</th>
<th>{% trans "Words" %}</th>
</tr>
<tr>
<th>{% trans "Total" %}</th>
<td class="percent"></td>
<td class="number">{{ object.total }}</td>
<td class="number">{{ object.total_words }}</td>
</tr>
<tr>
<th>{% trans "Translated" %}</th>
<td class="percent">{{ object.get_translated_percent }}%</td>
<td class="number">{{ object.translated }}</td>
<td class="number">{{ object.translated_words }}</td>
</tr>
<tr>
<th>{% trans "Fuzzy" %}</th>
<td class="percent">{{ object.get_fuzzy_percent }}%</td>
<td class="number">{{ object.fuzzy }}</td>
<td class="number"></td>
</tr>
<tr>
<th>{% trans "Failing check" %}</th>
<td class="percent">{{ object.get_failing_checks_percent }}%</td>
<td class="number">{{ object.failing_checks }}</td>
<td class="number"></td>
</tr>
<tr>
<td colspan="4">&nbsp;</td>
</tr>
<tr>
<th>{% trans "Last change" %}<th>
<td class="number" colspan="3">{{ object.get_last_change }}</td>
</tr>
<tr>
<th>{% trans "Last author" %}<th>
<td class="number" colspan="3">{{ object.get_last_author }}</td>
</tr>
</table>
</div>

</div>

{% endblock %}


