{% 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">
<li class="dropdown active">
  <a class="dropdown-toggle" data-toggle="dropdown" href="#" id="views-title">
    {{active_tab_label}} <span class="caret"></span>
  </a>
  <ul class="dropdown-menu" id="views-menu">
    <li><a href="#suggestions" data-toggle="tab">{% trans "Suggested translations" %}</a></li>
    {% if user.is_authenticated %}
    <li><a href="#your-languages" data-toggle="tab">{% trans "Your languages" %}</a></li>
    <li><a href="#your-subscriptions" data-toggle="tab">{% trans "Watched translations" %}</a></li>
    {% endif %}
    {% for componentlist in componentlists %}
    <li><a href="#{{ componentlist.tab_slug }}" data-toggle="tab">{{ componentlist.name }}</a></li>
    {% endfor %}
  </ul>
</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-load="activity" data-yearly="{% url 'yearly_activity' %}" data-monthly="{% url 'monthly_activity' %}">{% 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 '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>
    <li><a href="{% url 'stats' %}">{% trans "Statistics" %}</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 and user.profile.hide_completed as hide_completed %}
        {% 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 and user.profile.hide_completed as hide_completed %}
{% 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 %}
    {% if translations %}
    {% include "list-translations.html" %}
    <p>{% include "legend.html" %}</p>
    {% else %}
    <p class="help-block">{% trans "Could not find any matching translation in this component list, probably not translated to your languages." %}</p>
    {% endif %}
    {% 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 class="tab-pane" id="history">
{% include "last-changes-content.html" %}
<a class="btn btn-link" href="{% url 'changes' %}?{{ last_changes_url }}">{% trans "Browse all changes" %}</a>
</div>

</div>

{% endblock %}
