{% extends "rosetta/base.html" %}
{% load rosetta i18n %}

{% block header %}
    {{block.super}}
    <div id="user-tools">
        <p>
            <span><a href="{% url rosetta-pick-file %}">{% trans "Pick another file" %}</a> / 
            <a href="{% url rosetta-download-file %}">{% trans "Download this catalog" %}</a></span>
        </p>
    </div>
{% endblock %}
{% block breadcumbs %}
    <a href="{% url rosetta-pick-file %}">{% trans "Home" %}</a> &rsaquo; 
    {{ rosetta_i18n_lang_name }} &rsaquo; 
    {{ rosetta_i18n_app|title }} &rsaquo; 
    {% blocktrans with rosetta_i18n_pofile.percent_translated|floatformat:2 as percent_translated  %}Progress: {{ percent_translated }}%{% endblocktrans %}
    {% if not rosetta_i18n_write %}<span class="alert">{% trans "File is read-only: download the file when done editing!" %}</span>{% endif %}
{% endblock %}
{% block pagetitle %}{% trans "English" %} - {{rosetta_i18n_lang_name}} ({{ rosetta_i18n_pofile.percent_translated|floatformat:0 }}%){% endblock %}
{% block main %}
    <h1>{% blocktrans  %}Translate into {{rosetta_i18n_lang_name}}{% endblocktrans %}</h1>
    
    <ul class="object-tools">
        <li class="nobubble">{% trans "Display:" %}</li>
        <li {% ifequal rosetta_i18n_filter 'untranslated' %}class="active"{% endifequal %}><a href="?filter=untranslated">{% trans "Untranslated only" %}</a></li>
        <li {% ifequal rosetta_i18n_filter 'translated' %}class="active"{% endifequal %}><a href="?filter=translated">{% trans "Translated only" %}</a></li>
        <li {% ifequal rosetta_i18n_filter 'fuzzy' %}class="active"{% endifequal %}><a href="?filter=fuzzy">{% trans "Fuzzy only" %}</a></li>
        <li {% ifequal rosetta_i18n_filter 'all' %}class="active"{% endifequal %}><a href="?filter=all">{% trans "All" %}</a></li>
    </ul>
    <div id="changelist" class="module{% if rosetta_i18n_lang_bidi %} rtl{% endif %}">
        <div id="toolbar">
        <form id="changelist-search" action="" method="post">
            <div><!-- DIV needed for valid HTML -->
                {% rosetta_csrf_token %}
                <label for="searchbar"><img src="{{ADMIN_MEDIA_PREFIX}}img/admin/icon_searchbox.png" alt="{% trans "Search" %}" /></label>
                <input type="text" size="40" name="query" value="{% if query %}{{query}}{% endif %}" id="searchbar" />
                <input type="submit" name="search" value="{% trans "Go" %}" />
            </div>
        </form>
        </div>
        
        <form method="post" action="">
            <table>
                <thead>
                    <tr>
                        {% rosetta_csrf_token %}
                        <th>{% trans "Original" %}</th>
                        {% if main_language %}<th>{{ main_language }}</th>{% endif %}
                        <th>{{ rosetta_i18n_lang_name }}</th>
                        <th class="c">{% trans "Fuzzy" %}</th>
                        <th>{% trans "Occurrences(s)" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for  message in messages %}
                    <tr class="{% cycle row1,row2 %}">
                        {% if message.msgid_plural %}
                            <td class="original plural">
                                <div class="plural-container">
                                    <span class="part">{{message.msgid|format_message|linebreaksbr}}</span>
                                    <span class="part">{{message.msgid_plural|format_message|linebreaksbr}}</span>
                                </div>
                            </td>
                            <td class="translation">
                                {% for k, msgstr in message.msgstr_plural.items|dictsort:"0"  %}
                                    <label for="m_{{message.id}}_{{k}}">{{k}}:</label>
                                    <textarea rows="{{message.msgid|format_message|lines_count}}" cols="40" id="m_{{message.id}}_{{k}}" name="m_{{message.id}}_{{k}}">{{msgstr}}</textarea>
                                {% endfor %}
                            </td>
                        {% else %}
                            <td class="original">{{ message.msgid|format_message|linebreaksbr }}</td>
                            {% if main_language %}<td class="original">{{ message.main_lang|format_message|linebreaksbr }}</td>{% endif %}
                            <td class="translation">
                                <textarea rows="{{message.msgid|format_message|lines_count}}" cols="40" name="m_{{message.id}}">{{message.msgstr}}</textarea>
                                {% if ENABLE_TRANSLATION_SUGGESTIONS %}<a href="#" class="suggest">{% trans "suggest" %}</a>{% endif %}
                            </td>
                        {% endif %}
                            <td class="c">
                                <input type="checkbox" name="f_{{message.id}}" value="1" {% if message|is_fuzzy %}checked="checked"{% endif %} />
                            </td>
                            <td class="location">
                                {% for fn,lineno in message.occurrences %}
                                    <code{% if forloop.counter|gt:"3" %} class="hide"{% endif %}>{{ fn }}:{{lineno}}</code> 
                                {% endfor %}
                                {% if message.occurrences|length|gt:"3" %}
                                    <a href="#">&hellip; ({% blocktrans count message.occurrences|length|minus:"3" as more_count %}{{more_count}} more{% plural %}{{more_count}} more{% endblocktrans %})</a>
                                {% endif %}
                            </td>
                    </tr>
                    {% endfor %}
                </tbody>
            </table>
            <div class="submit-row">
                <p class="paginator">
                    {% if query %}
                        <input type="hidden" name="query" value="{{query}}"  />
                    {% endif %}
                    <input type="submit" class="default" name="_next" value="{% trans "Save and translate next block" %}"/>
                    
                    
                    {% if needs_pagination %}
                    {% trans "Skip to page:" %}
                    {% for i in page_range %}
                        {% ifequal i '...' %}
                        <span class="space">{{ i }}</span>
                        {% else %}
                        {% ifequal i page %}
                            <span class="this-page">{{i}}</span>
                        {% else %}    
                            <a href="?page={{i}}{% if query %}&amp;query={{query}}{% endif %}">{{i}}</a>
                        {% endifequal %}
                        {% endifequal %}
                    {% endfor %}
                    {% else %}
                    {% trans "Displaying:" %}
                    {% endif %}
                    <strong>{% blocktrans count rosetta_i18n_pofile|length as message_number and paginator.object_list|length as hits %}{{hits}}/{{message_number}} message{% plural %}{{hits}}/{{message_number}} messages{% endblocktrans %}</strong>

                    
                </p>
            </div>
        </form>
    </div>
{% endblock %}
