{% extends "base.html" %}
{% load translations %}
{% load url from future %}
{% load crispy_forms_tags %}
{% 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>
<a class="pull-right flip" 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>
{% endblock %}

{% block content %}

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

<ul class="nav nav-pills">
  <li class="active"><a href="#overview" data-toggle="tab">{% trans "Overview" %}</a></li>
  <li><a href="#search" data-toggle="tab">{% trans "Search" %}</a></li>
  <li><a href="#history" data-toggle="tab">{% trans "History" %}</a></li>
  <li><a href="#activity" data-toggle="tab" data-href="{% url 'view_activity_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Activity" %}</a></li>
  <li><a href="#stats" data-toggle="tab">{% trans "Statistics" %}</a></li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Files" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
<li><a href="{% url 'download_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" title="{% trans "Download for an offline translation." %}">{% trans "Download source file" %}</a></li>
{% if object.supports_language_pack %}
<li><a href="{% url 'download_language_pack' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" title="{% trans "Download for using within an application." %}">{% trans "Download compiled translation" %}</a></li>
{% endif %}
{% if perms.trans.upload_translation %}
<li><a href="#upload" data-toggle="tab">{% trans "Upload translation" %}</a></li>
{% endif %}
    </ul>
  </li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Tools" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      <li><a href="{% url 'data_project' project=object.subproject.project.slug  %}">{% trans "Data exports" %}</a></li>
      <li><a href="#locking" data-toggle="tab">{% trans "Locking" %}</a></li>
      {% if perms.trans.commit_translation or perms.trans.update_translation %}
      <li><a href="#repository" data-toggle="tab" data-href="{% url 'git_status_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Repository maintenance" %}</a></li>
      {% endif %}
      {% if autoform %}
      <li><a href="#auto" data-toggle="tab">{% trans "Automatic translation" %}</a></li>
      {% endif %}
    </ul>
  </li>
{% if enable_sharing %}
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Share" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
{% with object.get_share_url as share_url and object.get_widgets_url as widgets_url %}
      <li><a href="http://www.facebook.com/sharer.php?u={{ share_url }}">{% trans "Share on Facebook!" %}</a></li>
      <li><a href="https://twitter.com/share?text={% blocktrans %}Translate {{ object }} using %23Weblate at {{ share_url }}!{% endblocktrans %}">{% trans "Tweet this translation!" %}</a></li>
      <li><a href="{{ widgets_url }}">{% trans "Status widgets" %}</a></li>
{% endwith %}
    </ul>
  </li>
{% endif %}
</ul>


<div class="tab-content">
<div class="tab-pane active" id="overview">

<div class="row">
<div class="col-md-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Translation status" %}</h4></div>
  <div class="panel-body">

<table class="table">
<tr>
<th>{% trans "Strings" %}<span class="badge pull-right flip">{{ object.total }}</span></th>
<td class="progress-cell">{% translation_progress object %}</td>
<td class="percent">{{ object.get_translated_percent }}%</td>
</tr>

<tr>
<th>{% trans "Words" %}<span class="badge pull-right flip">{{ object.total_words }}</span></th>
<td class="progress-cell">{% words_progress object %}</td>
<td class="percent">{{ object.get_words_percent }}%</td>
</tr>
</table>

{% include "legend.html" %}
</div>
</div>

<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Strings to check" %}</h4></div>
  <div class="panel-body">
<div class="list-group">
{% for c in object.get_translation_checks %}
<a class="list-group-item list-group-item-{{ c.3 }}" href="{{ object.get_translate_url }}?type={{ c.0 }}"><span class="badge">{{ c.2 }}</span>{{ c.1 }}</a>
{% endfor %}
</div>
</div>
</div>

</div>

<div class="col-md-6">

<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Project Information" %}</h4></div>
  <div class="panel-body">

<table class="table">
{% with object.subproject as object %}
{% include "subproject_info.html" %}
{% endwith %}
</table>
</div>
</div>

{% if other_translations %}
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Other components" %}</h4></div>
  <div class="panel-body">
{% with other_translations as translations %}
{% include "list-translations.html" %}
{% endwith %}
</div>
</div>
{% endif %}

</div>

</div>


</div>

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


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

{% if perms.trans.upload_translation %}
<div class="tab-pane" id="upload">
<form action="{% url 'upload_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Upload" %}</h4></div>
<div class="panel-body">
{% 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 %}
{% csrf_token %}
<table>
{{ form.as_table }}
</table>
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Upload" %}" class="btn btn-default" />
</div>
</form>

</div>
</div>
{% endif %}

{% if perms.trans.commit_translation or perms.trans.update_translation %}
<div class="tab-pane" id="repository">
<p>{% trans "Loading…" %}</p>
</div>
{% endif %}

<div class="tab-pane" id="locking">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Locking" %}</h4></div>
<div class="panel-body">
<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="btn btn-default" 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="btn btn-default" href="{% url 'lock_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Lock" %}</a>
{% endif %}
{% endif %}
</div>

</div>
</div>

<div class="tab-pane" id="search">
<div class="row">
<div class="col-md-6">

<form action="{{ object.get_translate_url }}" method="GET">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Search" %}</h4></div>
  <div class="panel-body">
{{ search_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Search" %}" class="btn btn-default" />
</div>
</div>
</form>

</div>

{% if review_form %}
<div class="col-md-6">
<form action="{{ object.get_translate_url }}" method="GET">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Review" %}</h4></div>
  <div class="panel-body">
<p>{% trans "Review translations touched by other users." %}</p>
{{ review_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Start review" %}" class="btn btn-default" />
</div>
</div>
</form>

</div>
{% endif %}

</div>
</div>

<div class="tab-pane" id="stats">
<div class="row">
<div class="col-md-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Statistics" %}</h4></div>
<div class="panel-body">
<table class="table">
<thead>
<tr>
<td></td>
<th>{% trans "Percent" %}</th>
<th>{% trans "Strings" %}</th>
<th>{% trans "Words" %}</th>
</tr>
</thead>
<tbody>
<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>
</tbody>
</table>
</div>

</div>

</div>


<div class="col-md-6">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Last activity" %}</h4></div>
<div class="panel-body">
<table class="table">
<tbody>
<tr>
<th>{% trans "Last change" %}<th>
<td class="number" colspan="3">{{ object.last_change }}</td>
</tr>
<tr>
<th>{% trans "Last author" %}<th>
<td class="number" colspan="3">{{ object.get_last_author }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

</div>

</div>

<div class="tab-pane" id="activity">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Activity" %}</h4></div>
<div class="panel-body">
<p>{% trans "Loading…" %}</p>
</div>

</div>
</div>

</div>

{% endblock %}
