{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load crispy_forms_tags %}
{% load metrics %}

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

{% block content %}

{% announcements language=language project=project %}

<ul class="nav nav-pills">
  <li class="active"><a href="#overview" data-toggle="tab">{% trans "Components" %}</a></li>
  <li><a href="#information" data-toggle="tab">{% trans "Info" %}</a></li>
  <li><a href="#search" data-toggle="tab">{% trans "Search" %}</a></li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Insights" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
    <li><a href="#history" data-toggle="tab">{% trans "History" %}</a></li>
    </ul>
  </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_lang_project"  project=project.slug lang=language.code %}?format=zip" title="{% trans "Download for offline translation." %}">{% blocktrans %}Download original translation files as ZIP file{% endblocktrans %}</a></li>
    </ul>
  </li>
  <li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
      {% trans "Tools" %} <span class="caret"></span>
    </a>
    <ul class="dropdown-menu">
      {% if replace_form %}
          <li><a href="#replace" data-toggle="tab">{% trans "Search and replace" %}</a></li>
      {% endif %}
      {% if bulk_state_form %}
          <li><a href="#bulk-edit" data-toggle="tab">{% trans "Bulk edit" %}</a></li>
      {% endif %}
      <li><a href="{% url 'checks' %}?lang={{ language.code }}&amp;project={{ project.slug }}">{% trans "Failing checks" %}</a></li>
      {% if delete_form %}
      <li role="separator" class="divider"></li>
      <li><a href="#delete" data-toggle="tab">{% trans "Removal" %}</a></li>
      {% endif %}
    </ul>
   </li>
{% include "snippets/watch-dropdown.html" %}
</ul>

<div class="tab-content">

<div class="tab-pane active" id="overview">
{% include "snippets/list-objects.html" with objects=translations name_source="component_name" label=_("Component") %}
</div>

<div class="tab-pane" id="information">
  {% include "snippets/info.html" with language=None project=project stats=language_stats metrics=object|metrics %}
</div>

<div class="tab-pane" id="history">
{% include "last-changes-content.html" %}
<a class="btn btn-primary" href="{% url 'changes' %}?{{ last_changes_url }}">{% trans "Browse all language changes" %}</a>
</div>

<div class="tab-pane" id="search">

<form action="{% url 'search' project=project.slug lang=language.code %}" method="GET">
{% include "snippets/search-form.html" %}
</form>

</div>

{% if delete_form %}
{% include "trans/delete-form.html" %}
{% endif %}

{% if replace_form %}
<div class="tab-pane" id="replace">
<form action="{% url 'replace' project=object.project.slug lang=object.language.code %}" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">
  {% documentation_icon 'user/translating' 'search-replace' right=True %}
  {% trans "Search and replace" %}
</h4></div>
<div class="panel-body">
{% crispy replace_form %}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Replace" %}" class="btn btn-primary" />
</div>
</div>
</form>
</div>
{% endif %}

{% if bulk_state_form %}
<div class="tab-pane" id="bulk-edit">
<form action="{% url 'bulk-edit' project=object.project.slug lang=object.language.code %}" method="post" enctype="multipart/form-data">
<div class="panel panel-default">
<div class="panel-heading"><h4 class="panel-title">
  {% documentation_icon 'user/translating' 'bulk-edit' right=True %}
  {% trans "Bulk edit" %}
</h4></div>
<div class="panel-body">
{% crispy bulk_state_form %}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Apply" %}" class="btn btn-primary" />
</div>
</div>
</form>
</div>
{% endif %}




</div>

{% endblock %}
