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

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

<a class="pull-right flip" href="{{ object.get_widgets_url }}">
<img src="{% url 'widget-image' project=object.project.slug widget='svg' color='badge' extension='svg' %}" />
</a>
{% endblock %}

{% block content %}

{% whiteboard_messages subproject=object %}

{% can_see_repository_status user object.project as user_can_see_repository_status %}
{% can_commit_translation user object.project as user_can_commit_translation %}
{% can_manage_acl user object.project as user_can_manage_acl %}
{% can_view_reports user object.project as user_can_view_reports %}
{% can_add_translation user object.project as user_can_add_translation %}

{% 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="#history" data-toggle="tab">{% trans "History" %}</a></li>
  <li><a href="#activity" data-toggle="tab" data-load="activity" data-yearly="{% url 'yearly_activity' project=object.project.slug subproject=object.slug %}" data-monthly="{% url 'monthly_activity' project=object.project.slug subproject=object.slug %}">{% trans "Activity" %}</a></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.project.slug  %}">{% trans "Data exports" %}</a></li>
      {% if user_can_commit_translation %}
      <li><a href="{{ object.get_commit_url }}">{% trans "Commit" %}</a></li>
      {% endif %}
      {% if user_can_see_repository_status %}
      <li><a href="#repository" data-toggle="tab" data-href="{% url 'git_status_subproject' project=object.project.slug subproject=object.slug %}">{% trans "Repository maintenance" %}</a></li>
      {% endif %}
      <li><a href="{% url 'show_source' project=object.project.slug subproject=object.slug %}">{% trans "Source strings review" %}</a></li>
      {% if user_can_manage_acl %}
      <li><a href="{{ object.project.get_absolute_url }}#acl">{% trans "Manage users" %}</a></li>
      {% endif %}
      {% if user_can_view_reports %}
      <li><a href="#reports" data-toggle="tab">{% trans "Translation reports" %}</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="{% url 'engage' project=object.project.slug %}">{% trans "Engage page" %}</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="container-fluid">
<div class="row">

<div class="col-lg-6">
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "Translations" %}</h4></div>
  <div class="panel-body">

{% include "list-translations.html" %}

</div>
</div>


</div>

<div class="col-lg-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">
{% include "subproject_info.html" %}
</table>
</div>
</div>

{% if object.can_add_language and user_can_add_translation %}
<form action="{% url 'new-language' project=object.project.slug subproject=object.slug %}" method="post">
{% csrf_token %}
<div class="panel panel-primary">
  <div class="panel-heading"><h4 class="panel-title">{% trans "New translation" %}</h4></div>
  <div class="panel-body">
{% if object.new_lang == 'url' %}
<p>{% blocktrans with object.project.instructions as url %}Should your language be missing, please follow <a href="{{ url }}">translator instructions</a>.{% endblocktrans %}</p>
{% else %}
<p>{% trans "Please choose the language into which you would like to translate." %}</p>
{% if object.new_lang == 'contact' %}
<p>{% trans "Project maintainers will get notified about this request and will add the language manually." %}</p>
{% endif %}
{{ new_lang_form|crispy }}
<p class="help-block"><a href="{% url 'contact' %}?subject=New+language+request+for+{{ object }}">{% trans "Can't find your language in the list above?" %}</a></p>
</div>
<div class="panel-footer">
{% if object.new_lang == 'contact' %}
<input class="btn btn-default" type="submit" value="{% trans "Request new translation" %}" />
{% else %}
<input class="btn btn-default" type="submit" value="{% trans "Start new translation" %}" />
{% endif %}
{% endif %}
</div>
</div>
</form>
{% endif %}


</div>
</div>

</div>

</div>


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

{% include "activity-tab.html" %}

{% if user_can_see_repository_status %}
<div class="tab-pane" id="repository">
<p>{% trans "Loading…" %}</p>
</div>
{% endif %}

{% if user_can_view_reports %}
<div class="tab-pane" id="reports">
<div class="row">
<div class="col-lg-6">
<form action="{% url 'credits' project=object.project.slug subproject=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Credits" %}</h4></div>
<div class="panel-body">
<p>{% trans "Credits list all translators who have contributed to this component in a given time period. It can be useful for including in your documentation or application to thank translators." %}</p>
{% csrf_token %}
{{ reports_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Generate" %}" class="btn btn-default" />
</div>
</div>
</form>
</div>
<div class="col-lg-6">
<form action="{% url 'counts' project=object.project.slug subproject=object.slug %}" method="post" enctype="multipart/form-data">
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Contributor stats" %}</h4></div>
<div class="panel-body">
<p>{% trans "Reports number of strings and words translated by each translator." %}</p>
{% csrf_token %}
{{ reports_form|crispy }}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Generate" %}" class="btn btn-default" />
</div>
</div>
</form>
</div>
</div>
</div>
{% endif %}

</div>



</div>

{% endblock %}

