{% 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 %}
{% can_edit_subproject user object.project as user_can_edit_subproject %}

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

<ul class="nav nav-pills">
  <li class="active"><a href="#translations" data-toggle="tab">{% trans "Translations" %}</a></li>
  <li><a href="#information" data-toggle="tab">{% trans "Information" %}</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>
      <li><a href="{% url 'export_stats' project=object.project.slug subproject=object.slug %}?format=csv">{% trans "Download statistics (CSV)" %}</a></li>
      <li><a href="{% url 'export_stats' project=object.project.slug subproject=object.slug %}?format=json">{% trans "Download statistics (JSON)" %}</a></li>
      <li><a href="{% url 'matrix' project=object.project.slug subproject=object.slug %}">{% trans "Matrix view" %}</a></li>
      {% if user_can_commit_translation %}
      <li><a href="{{ object.get_commit_url }}" class="link-post">{% 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 %}
      {% if object.can_add_language and user_can_add_translation %}
      <li><a href="#newlang" data-toggle="tab">{% trans "Start new translation" %}</a></li>
      {% endif %}
      {% if user_can_edit_subproject %}
      <li><a href="#settings" data-toggle="tab">{% trans "Settings" %}</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 %}
{% with object.project as project %}
{% include "watch-dropdown.html" %}
{% endwith %}
</ul>


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

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

</div>

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

<table class="table table-striped">
{% include "subproject_info.html" %}
{% include "project_stats.html" %}
</table>

</div>


{% if object.can_add_language and user_can_add_translation %}

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

<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 "Start 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>

</div>
{% endif %}


<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">
{% doc_url 'devel/reporting' 'credits' as settings_doc_url %}
<a class="pull-right flip" href="{{ settings_doc_url }}"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
{% 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">
{% doc_url 'devel/reporting' 'stats' as settings_doc_url %}
<a class="pull-right flip" href="{{ settings_doc_url }}"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
{% 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 %}

{% if user_can_edit_subproject %}
<div class="tab-pane" id="settings">
<form action="{% url 'subproject' project=object.project.slug subproject=object.slug %}#settings" method="post" enctype="multipart/form-data">
{% csrf_token %}
<div class="panel panel-primary">
<div class="panel-heading">
{% doc_url 'admin/projects' 'subproject' as settings_doc_url %}
<h4 class="panel-title">
<a class="pull-right flip" href="{{ settings_doc_url }}"><i class="fa fa-question-circle" aria-hidden="true"></i></a>
{% trans "Settings" %}
</h4>
</div>
<div class="panel-body">
{% crispy settings_form %}
</div>
<div class="panel-footer">
<input type="submit" value="{% trans "Save" %}" class="btn btn-default" />
</div>
</div>
</div>
</div>
</form>
</div>
{% endif %}

</div>



</div>

{% endblock %}

