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

{% block content %}

{% if not user.is_authenticated %}
<p class="alert alert-info">
{% if demo_server %}
{% blocktrans %}This site runs <a href="{{ weblate_url }}">Weblate</a> demo server.{% endblocktrans %}
{% else %}
{% blocktrans %}This site runs <a href="{{ weblate_url }}">Weblate</a> for translating the software projects listed below.{% endblocktrans %}
{% endif %}
{% trans "You need to be logged in for translating, otherwise you can only make suggestions." %}
</p>
{% endif %}

{% whiteboard_messages %}


<ul class="nav nav-pills">
{% if user.is_authenticated %}
<li {% active_link "your-subscriptions" %}><a href="#your-subscriptions" data-toggle="tab">{% trans "Watched translations" %} <span class="badge">{{ usersubscriptions|length }}</span></a></li>
<li {% active_link "your-languages" %}><a href="#your-languages" data-toggle="tab">{% trans "Your languages" %} <span class="badge">{{ userlanguages|length }}</span></a></li>
{% endif %}
<li {% active_link "suggestions" %}><a href="#suggestions" data-toggle="tab">{% trans "Suggested translations" %} <span class="badge">{{ suggestions|length }}</span></a></li>
{% for componentlist in componentlists %}
<li {% active_link componentlist.tab_slug %}><a href="#{{ componentlist.tab_slug }}" data-toggle="tab">{{ componentlist.name }} <span class="badge">{{ componentlist.translations|length }}</span></a></li>
{% endfor %}
  <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="{% url 'changes' %}">{% trans "History" %}</a></li>
    <li><a href="#activity" data-toggle="tab" data-load="activity" data-yearly="{% url 'yearly_activity' %}" data-monthly="{% url 'monthly_activity' %}">{% trans "Activity" %}</a></li>
    <li><a href="{% url 'stats' %}">{% trans "Statistics" %}</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">
    <li><a href="#search" data-toggle="tab">{% trans "Search" %}</a></li>
    <li><a href="{% url 'languages' %}">{% trans "Languages summary" %}</a></li>
    <li><a href="{% url 'projects' %}">{% trans "All projects" %}</a></li>
    <li><a href="{% url 'checks' %}">{% trans "Checks overview" %}</a></li>
    <li><a href="{% url 'data_root' %}">{% trans "Data export" %}</a></li>
    <li><a href="{% url 'widgets_root' %}">{% trans "Widgets" %}</a></li>
  </ul>
</li>
</ul>

<div class="tab-content">
{% if user.is_authenticated %}
<div {% active_tab "your-subscriptions" %}>
{% if subscribed_projects %}
    {% if usersubscriptions %}
        {% with usersubscriptions as translations and 2 as show_language %}
        {% include "list-translations.html" %}
        {% endwith %}
        <p>{% include "legend.html" %}</p>
    {% else %}
        {% with subscribed_projects as projects %}
        {% include "list-projects.html" %}
        {% endwith %}
    {% endif %}
{% else %}
    <p class="help-block">{% trans "Choose your languages in preferences and you will get an overview here of available translations for those languages in your watched projects." %}</p>
{% endif %}
<p>
    <a class="btn btn-default" href="{% url 'profile' %}#languages">{% trans "Manage your languages" %}</a>
    <a class="btn btn-default" href="{% url 'profile' %}#subscriptions">{% trans "Manage watched projects" %}</a>
</p>
</div>

<div {% active_tab "your-languages" %}>
{% if userlanguages %}
{% with userlanguages as translations and 2 as show_language %}
{% include "list-translations.html" %}
{% endwith %}
<p>{% include "legend.html" %}</p>
{% else %}
<p class="help-block">{% trans "Choose your languages in preferences and you will get an overview here of available translations for those languages in all projects." %}</p>
{% endif %} {# userlanguages #}
<p><a class="btn btn-default" href="{% url 'profile' %}#languages">{% trans "Manage your languages" %}</a></p>
</div>
{% endif %} {# user.is_authenticated #}

{# Suggested translations #}
<div {% active_tab "suggestions" %}>
{% if suggestions %}
{% with suggestions as translations and 2 as show_language and user.profile.hide_completed as hide_completed %}
{% include "list-translations.html" %}
{% endwith %}
<p>{% include "legend.html" %}</p>
{% else %}
<p class="help-block">{% trans "Could not find any suggestions for you, please choose your languages in preferences to get more suggestions." %}</p>
{% endif %}
{% if user.is_authenticated %}
<p><a class="btn btn-default" href="{% url 'profile' %}#languages">{% trans "Manage your languages" %}</a></p>
{% else %}
<p><a class="btn btn-default" href="{% url 'register' %}">{% trans "Register to manage your languages" %}</a></p>
{% endif %}
</div>


{% for componentlist in componentlists %}
    <div {% active_tab componentlist.tab_slug %}>
    {% with componentlist.translations as translations and 2 as show_language and user.profile.hide_completed as hide_completed %}
    {% include "list-translations.html" %}
    <p>{% include "legend.html" %}</p>
    {% endwith %}
    <p><a class="btn btn-default" href="{% url 'profile' %}#languages">{% trans "Manage your languages" %}</a></p>
</div>{% endfor %}

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

<form action="{% url 'search' %}" method="GET">
{{ search_form|crispy }}
<input type="submit" value="{% trans "Search" %}" class="btn btn-default" />
</form>

</div>

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

</div>

{% endblock %}
