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

{% block breadcrumbs %}
<li><a href="{{ project.get_absolute_url }}">{{ project }}</a></li>
<li><a href="{% url 'show_dictionaries' project=project.slug %}">{% trans "glossaries" %}</a></li>
<li><a href="{% url 'show_dictionary' project=project.slug lang=language.code %}">{{ language }}</a></li>
{% endblock %}

{% block content %}



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

<span class="navi-toolbar ui-widget-header ui-corner-all">
<span id="navi">
<a id="button-first" {% if words.number == 1 %}class="button-disabled"{% endif %} href="?page=1&amp;letter={{ letter }}">{% trans "First" %}</a>
<a id="button-prev" {% if not words.has_previous %}class="button-disabled"{% else %}href="?page={{ words.previous_page_number }}&amp;letter={{ letter }}"{% endif %}>{% trans "Previous" %}</a>
<a id="button-pos" class="textbutton">{% blocktrans with words.number as position and words.paginator.num_pages as total %}{{ position }} / {{ total }}{% endblocktrans %}</a>
<a id="button-next" {% if not words.has_next %}class="button-disabled"{% else %}href="?page={{ words.next_page_number }}&amp;letter={{ letter }}"{% endif %}>{% trans "Next" %}</a>
<a id="button-end" {% if words.paginator.num_pages == words.number %}class="button-disabled"{% endif %} href="?page={{ words.paginator.num_pages }}&amp;letter={{ letter }}">{% trans "Last" %}</a>
</span>
<form class="autosubmit">{{ letterform.as_p }}</form>
</span>

{% if words.object_list %}
<table>
<thead>
<tr>
<th>{% trans "Source" %}</th>
<th>{% trans "Translation" %}</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{% for word in words.object_list %}
<tr>
<td class="translatetext">{{ word.source }}</td>
<td class="translatetext">{{ word.target }}</td>
<td>
{% if perms.trans.change_dictionary %}
<form action="{% url 'edit_dictionary' project=project.slug lang=language.code %}" method="get">
<input type="hidden" name="id" value="{{ word.id }}" />
<input type="submit" class="button" value="{% trans "Edit" %}" />
</form>
{% endif %}
</td>
<td>
{% if perms.trans.delete_dictionary %}
<form action="{% url 'delete_dictionary' project=project.slug lang=language.code %}" method="post">
{% csrf_token %}
<input type="hidden" name="id" value="{{ word.id }}" />
<input type="submit" class="button" value="{% trans "Delete" %}" />
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p>{% trans "No words found!" %}</p>
{% endif %}

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

<div class="tabs" id="dictionary-tabs">
<ul>
{% if perms.trans.add_dictionary %}
<li><a href="#add">{% trans "Add new word" %}</a></li>
{% endif %}
{% if perms.trans.upload_dictionary %}
<li><a href="#import">{% trans "Import glossary" %}</a></li>
{% endif %}
<li><a href="#export">{% trans "Export glossary" %}</a></li>
<li><a href="#changes">{% trans "History" %}</a></li>
</ul>

{% if perms.trans.add_dictionary %}
<div id="add">

<form method="POST">
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
<input type="submit" class="button" value="{% trans "Add" %}" />
</form>

</div>
{% endif %}

{% if perms.trans.upload_dictionary %}
<div id="import">

<p>{% trans "You can upload any format which is understood by Translate Toolkit (including TBX, CSV or Gettext PO files)." %}</p>

<form action="{% url 'upload_dictionary' project=project.slug lang=language.code %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
<table>
{{ uploadform.as_table }}
</table>
<input type="submit" class="button" value="{% trans "Import" %}" />
</form>

</div>
{% endif %}

<div id="export">

<p>{% trans "You can download glossary in following formats:" %}</p>

<ul>
<li><a href="{% url 'download_dictionary' project=project.slug lang=language.code %}?format=csv">{% trans "Comma separated values (CSV)" %}</a></li>
<li><a href="{% url 'download_dictionary' project=project.slug lang=language.code %}?format=po">{% trans "Gettext (PO)" %}</a></li>
<li><a href="{% url 'download_dictionary' project=project.slug lang=language.code %}?format=tbx">{% trans "TermBase eXchange (TBX)" %}</a></li>
</ul>
</div>

<div id="changes">
{% include "last-changes.html" %}
</div>

{% endblock %}
