{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load permissions %}
{% load crispy_forms_tags %}
{% load humanize %}
{% load icons %}

{% block breadcrumbs %}
{% if project %}
<li><a href="{{ project.get_absolute_url }}">{{ project }}</a></li>
<li><a href="{% url 'memory' project=project.slug %}">{% trans "Translation memory" %}</a></li>
{% elif from_file %}
<li><a href="{% url 'manage' %}">{% trans "Manage" %}</a></li>
<li><a href="{% url 'memory' manage='manage' %}">{% trans "Translation memory for the whole platform" %}</a></li>
{% else %}
<li><a href="{% url 'profile' %}">{{ user.profile.get_user_name }}</a></li>
<li><a href="{% url 'memory' %}">{% trans "Translation memory" %}</a></li>
{% endif %}
{% endblock %}

{% block content %}

<div class="panel panel-default">
<div class="panel-heading">
  <h4 class="panel-title">
    {% documentation_icon 'admin/memory' 'memory-user' right=True %}
    {% trans "Translation memory status" %}
  </h4>
</div>
  <table class="table table-condensed table-striped">
  {% if project %}
  <tr>
  <th>{% trans "Shared translation memory" %}</th>
  <td>
  {% if project.use_shared_tm %}
    {% comment %}Translators: Shared translation memory is enabled{% endcomment %}
    {% trans "on" %}
  {% else %}
    {% comment %}Translators: Shared translation memory is disabled{% endcomment %}
    {% trans "off" %}
  {% endif %}
  </td>
  <td>
    {% perm 'project.edit' project as user_can_edit_project %}
    {% if user_can_edit_project %}
    <a href="{% url 'settings' project=project.slug %}#workflow" class="btn btn-primary">{% trans "Configure" %}</a>
    {% endif %}

  </td>
  </tr>
  {% endif %}
  <tr>
  <th>
    {% if project %}
      {% blocktrans %}Number of entries for {{ project }}{% endblocktrans %}
    {% elif from_file %}
      {% trans "Number of entries on the whole platform" %}
    {% else %}
      {% trans "Number of your entries" %}
    {% endif %}
  </th>
  <td class="number">{{ num_entries|intcomma }}</td>
  <td>
      <a href="{{ download_url }}" class="btn btn-primary">{% trans "Download as JSON" %}</a>
      <a href="{{ download_url }}?format=tmx" class="btn btn-primary">{% trans "Download as TMX" %}</a>
  </td>
  </tr>
  {% if shared_entries %}
  <tr>
  <th>{% trans "Number of shared entries" %}</th>
  <td class="number">{{ shared_entries|intcomma }}</td>
  <td>
    {% if from_file %}
      <a href="{{ download_url }}?kind=shared" class="btn btn-primary">{% trans "Download as JSON" %}</a>
      <a href="{{ download_url }}?kind=shared&amp;format=tmx" class="btn btn-primary">{% trans "Download as TMX" %}</a>
    {% endif %}
  </td>
  </tr>
  {% endif %}
  <tr>
  <th>{% trans "Total number of entries" %}</th>
  <td class="number">{{ total_entries|intcomma }}</td>
  <td>
    {% if from_file %}
      <a href="{{ download_url }}?kind=all" class="btn btn-primary">{% trans "Download as JSON" %}</a>
      <a href="{{ download_url }}?kind=all&amp;format=tmx" class="btn btn-primary">{% trans "Download as TMX" %}</a>
    {% endif %}
  </td>
  </tr>
  </table>
</div>

{% if upload_form %}
<form action="{{ upload_url }}" method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">{% trans "Import translation memory" %}</h4></div>
  <div class="panel-body">
  {{ upload_form|crispy }}
  </div>
  <div class="panel-footer">
  <input type="submit" class="btn btn-primary" value="{% trans "Upload" %}" />
  </div>
</div>
</form>
{% endif %}

{% endblock %}
