{% extends "tp_base_extended.html" %}

{% load i18n baseurl %}

{% get_current_language as LANGUAGE_CODE %}
{% get_current_language_bidi as LANGUAGE_BIDI %}

{% block title %}
{{ block.super }} » {% trans "Translate" %} » {{ title_path }}
{% endblock %}

{% block body.id %}translatepage{% endblock body.id %}

{% block bodyclass %}{% if checking_text %}tpreview{% else %}tptranslate{% endif %}{% endblock %}

{% block extra_head %}
<script src='{{ "js/jquery/jquery.textarea-expander.js"|m }}' type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready (function() {
     $('textarea.expanding').TextAreaExpander('20', '100');
  });
</script>
{% endblock extra_head %}

{% block breadcrumbs_content %}
{% include "language/item_title.html" %}
{% endblock %}

{% block innernav %}
<!--! Navigation bar -->
<div id="innernav" class="navbar">
    {% for item in navitems %}
    {% include "language/item_block.html" %}
    {% include "language/item_stats.html" %}
    {% endfor %}
</div><!--innernav-->
{% endblock innernav %}

{% block precontent %}
{{ block.super }}
{% if checking_text %}
<div class="check">
    <img src='{{ "images/help.png"|m }}' class="checkinfo" />
    <span>{{ checking_text|safe }}</span>
</div>
{% endif %}
{% endblock precontent %}

{% block content %}
<div class="module-primary">
    <div class="nomargin">
        <!--! start/next/previous/end links -->
        {% if pagelinks %}
        <ul class="translations-nav" lang="{{ LANGUAGE_CODE }}">
            {% for pagelink in pagelinks %}
            <li><a href="{{ pagelink.href|l }}">{{ pagelink.text }}</a></li>
            {% endfor %}
        </ul>
        {% endif %}
        <div class="translate-form">
            {% if notice %}
            <div id="site-message" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">{{ notice }}</div>
            {% else %}
            <form action="{{actionurl|l}}" method="post" name="translate" id="translate">
                {{ search.search_form.as_hidden }}
                {{ search.advanced_search_form.as_hidden }}
                <table cellpadding="0" cellspacing="0" class="translate-table" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">
                    <tr lang="{{ LANGUAGE_CODE }}">
                        {% if canedit %}
                        <th colspan="1" rowspan="1" class="translate-table-title translate-edit"></th>
                        {% endif %}
                        <th colspan="1" rowspan="1" class="translate-table-title translate-original">{{ original_title }}</th>
                        <th colspan="1" rowspan="1" class="translate-table-title translate-translation">{{ translation_title }}</th>
                    </tr>
                  {% for item in items %}
                  <tr title="{{ item.translator_comments }} {{ item.developer_comments }}">
                      {% if canedit %}
                      <td>
                          {% if item.trans.editlink %}
                          <a href="{{ item.trans.editlink.href|l }}" id="{{ item.trans.editlink.linkid }}" title="{% trans 'Edit translation' %}">
                              <div class="translation-action">{{ item.itemid }}</div>
                          </a>
                          {% endif %}
                      </td>
                      {% endif %}

                      <!--! Cell with original -->
                      <td colspan="1" rowspan="1" class="translate-original {{ item.polarity }} {{ item.focus_class }}" dir="ltr">
                          <div id="{{ item.orig.itemid }}" class="translate-original {{ item.orig.focus_class }}">
                          {% for field in item.orig.pure %}
                              <input type="hidden" name="{{ field.pureid }}" value="{{ field.value }}" id="{{ field.pureid }}"/>
                          {% endfor %}
                          {% if not item.orig.isplural %}
                              <div class="translation-text" lang="en">{{ item.orig.text|safe }}</div>
                          {% else %}
                              <span class="translation-text-headers" lang="{{ LANGUAGE_CODE }}">{{ item.orig.singular_title }}</span><br />
                              <span class="translation-text" lang="en">{{ item.orig.singular_text|safe }}</span><br />
                              <span class="translation-text-headers" lang="{{ LANGUAGE_CODE }}">{{ item.orig.plural_title }}</span><br />
                              <span class="translation-text" lang="en">{{ item.orig.plural_text|safe }}</span><br />
                            {% endif %}
                          </div>

                          <!--! Alternative source language translation (if enabled and available) -->
                          {% for altsrc in item.altsrcs %}
                          {% if altsrc.available %}
                              <div class="translation-text-headers altsrclangname" lang="{{ LANGUAGE_CODE }}" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">{{ altsrc.title }}</div>
                              <div class="translate-original {{ item.orig.focus_class }}">
                              {% if not altsrc.isplural %}
                                  <div id="{{ item.orig.itemid }}" class="translation-text" lang="{{ altsrc.languagecode }}" dir="{{ altsrc.dir }}">{{ altsrc.text|safe }}</div>
                              {% else %}
                              {% for form in altsrc.forms %}
                                  {% if form.title %}
                                  <span class="translation-text-headers" lang="{{ LANGUAGE_CODE }}">{{ form.title }}</span><br />
                                  {% endif %}
                                  <span class="translation-text" lang="{{ altsrc.languagecode }}" dir="{{ altsrc.dir }}">{{ form.text|safe }}</span>
                                  {% if form.title %}
                                  <br/>
                                  {% endif %}
                              {% endfor %}
                              {% endif %}
                              </div>
                          {% endif %}
                          {% endfor %}

                          {% if item.editable and item.message_context %}
                              <div class="translate-context">
                                  {{ item.message_context }}
                              </div>
                          {% endif %}
                      </td>

                      <!--! Cell with translation (view/suggest/review/edit) -->
                      <td colspan="1" rowspan="1" class="translate-translation {{ item.polarity }} {{ item.focus_class }}">
                          <div id="{{ item.trans.itemid }}" class="translate-translation {{ item.orig.focus_class }}">
                          {% if item.editable %}
                          <!--! Begin: Normal editing -->

                              {% if item.tm %}
                              <!--! Translation memory -->
                              <div id="tm" class="sidebar" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">
                                  <div class="sidetitle" lang="{{ LANGUAGE_CODE }}">{{ related_title }}</div>
                                  {% for unit in item.tm %}
                                  <div class="tm-unit" title="{{ unit.getnotes }}" onclick="writespecial('{{ unit.target }}', '{{ item.trans.itemid }}');">
                                      <span class="tm-original" dir="ltr" lang="en">{{ unit.source }}</span>
                                      <span class="tm-translation" dir="{{ language.dir }}" lang="{{ language.code }}">{{ unit.target }}</span>
                                  </div>
                                  {% endfor %}
                              </div>
                              {% endif %}

                              {% if not item.trans.isplural %}
                              <!--! No plurals -->
                              <textarea {% if not canedit %}readonly="readonly"{% endif %} dir="{{ language.dir }}" lang="{{ language.code }}"
                                    onfocus="setfocusedelement(this);" class="translation expanding {{ item.state_class }}"
                                    name="{{ item.trans.itemid }}" id="area{{ item.trans.itemid }}" rows="{{ item.trans.rows }}">{{ item.trans.text|safe }}</textarea>
                              {% else %}
                              <!--! with plurals -->
                              {% for form in item.trans.forms %}
                              <div class="translation-text-headers" lang="{{ LANGUAGE_CODE }}">{{ form.title }}</div>
                                  <textarea {% if not canedit %}readonly="readonly"{% endif %} dir="{{ language.dir }}" lang="{{ language.code }}" onfocus="setfocusedelement(this);" class="translation expanding {{ item.state_class }}" name="{{ form.name }}" id="area{{ form.name }}" rows="{{ item.trans.rows }}">{{ form.text|safe }}</textarea>
                              {% endfor %}
                              {% endif %}

                              {% if item.hassuggestion %}
                              <!--! Reviewing mode: display original strings for diffing -->
                              <div id="translate-original-container">
                                  <strong class="{{ item.state_class }}">{{ item.trans.current_title }}</strong>
                                  <div class="translate-original-block">
                                  {% for form in item.trans.forms %}
                                      <div lang="{{ language.code }}" dir="{{ language.dir }}">{{ form.diff|safe }}</div>
                                  {% endfor %}
                                  </div>
                              </div>

                              <!--! (Re)view suggestions while editing -->
                              <div id="translate-suggestion-container">
                              {% for sugg in item.trans.suggestions %}
                                  <div id="suggestion{{ sugg.suggid }}" class="translate-suggestion-block">
                                      <strong>{{ sugg.title }}</strong>
                                      <div class="translate-suggestion">
                                      {% for form in sugg.forms %}
                                          {% if form.title %}
                                          <div class="translation-text-headers" lang="{{ LANGUAGE_CODE }}">{{ form.title }}</div>
                                          {% endif %}
                                          <div lang="{{ language.code }}" dir="{{ language.dir }}">{{ form.diff|safe }}</div>
                                          <input type="hidden" id="{{ form.suggid }}" name="{{ form.suggid }}" value="{{ form.value }}" />
                                      {% endfor %}
                                      {% if canreview %}
                                          <a title="{{ accept_title }}" accesskey="a" id="accept{{ sugg.suggid }}" class="acceptsugg"><img src='{{ "images/tick.png"|m }}' dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}" /></a>
                                          <a title="{{ reject_title }}" accesskey="r" id="reject{{ sugg.suggid }}" class="rejectsugg"><img src='{{ "images/cross.png"|m }}' dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}" /></a>
                                      {% endif %}
                                      </div>
                                  </div>
                              {% endfor %}
                              </div>
                              {% endif %}

                              <!--! Buttons, resize links, special characters -->
                              <div lang="{{ LANGUAGE_CODE }}">
                                  <div class="translate-buttons-block">
                                  {% for button in item.trans.buttons.desired %}
                                      {% ifequal button 'translate' %}
                                      <input type="submit" name="submit{{ item.trans.buttons.item }}" accesskey="s" value="{% trans 'Submit' %}" />
                                      {% endifequal %}
                                      {% ifequal button 'suggest' %}
                                      <input type="submit" name="submitsuggest{{ item.trans.buttons.item }}" accesskey="e" value="{% trans 'Suggest' %}" />
                                      {% endifequal %}
                                      {% ifequal button 'copy' %}
                                      <input type="button" accesskey="c"
                                         onclick="copyorigtranslation('{{ item.trans.buttons.item }}'); return false"
                                         value="{% trans 'Copy' %}" />
                                      {% endifequal %}
                                      {% ifequal button 'skip' %}
                                      <input type="submit" name="skip{{ item.trans.buttons.item }}" accesskey="k" value="{% trans 'Skip' %}" />
                                      {% endifequal %}
                                      {% ifequal button 'back' %}
                                      <input type="submit" name="back{{ item.trans.buttons.item }}" accesskey="b" value="{% trans 'Back' %}" />
                                      {% endifequal %}
                                  {% endfor %}
                                      <input type="hidden" name="store" value="{{ store }}" />
				      <input type="hidden" name="path" value="{{ store|l }}" />
                                  </div>
                                  {% if cantranslate %}
                                  <div class="translate-fuzzy-block">
                                      <input type="checkbox" {% if item.fuzzy %}checked="checked"{% endif %} name="fuzzy{{ item.trans.buttons.item }}" accesskey="f" id="fuzzy{{ item.trans.buttons.item }}" class="fuzzycheck" />
                                      <label for="fuzzy{{ item.trans.buttons.item }}">{{ fuzzytext }}</label>
                                  </div>
                                  {% else %}
                                  <div class="translate-fuzzy-block">
                                      <input type="checkbox" disabled="disabled" {% if item.fuzzy %}checked="checked"{% endif %} name="fuzzy{{ item.trans.buttons.item }}" id="fuzzy{{ item.trans.buttons.item }}" class="fuzzycheck" />
                                      <label for="fuzzy{{ item.trans.buttons.item }}">{{ fuzzytext }}</label>
                                  </div>
                                  {% endif %}
                              </div>

                              {% if item.trans.buttons.specialchars and canedit %}
                              <div class="translate-specialchars-block" lang="{{ language.code }}">
                                  {% for specialchar in item.trans.buttons.specialchars %}
                                      {% if not specialchar.isspace %}
                                      <a onclick="writespecial('{{ specialchar }}', '{{ item.trans.itemid }}'); return false;" href="#">{{ specialchar }}</a>
                                      {% else %}
                                      <span class="extraspace"> </span>
                                      {% endif %}
                                  {% endfor %}
                              </div>
                              {% endif %}

                              {% if canedit %}
                              <script type="text/javascript">
                                <!--! //We should comment this for old browsers, but then kid doesn't evaluate the expression -->
                                $(document).ready(function(){
                                document.forms.translate['{{ item.trans.focusbox }}'].focus();
                                });
                                <!--! //-->
                              </script>
                              {% endif %}
                          <!--! End: Normal editing -->
                          {% else %}
                          <!--! Normal view mode -->
                              <div dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}" class="{{ item.state_class }}">
                                  {% if not item.trans.isplural %}
                                  <div dir="{{ language.dir }}" lang="{{ language.code }}" class="translation-text" id="{{ item.trans.itemid }}">{{ item.trans.text|safe }}</div>
                                  {% else %}
                                  <div>
                                      {% for form in item.trans.forms %}
                                      <span class="translation-text-headers" lang="{{ LANGUAGE_CODE }}">{{ form.title }}</span><br />
                                      <span class="translation-text">{{ form.text|safe }}</span><br />
                                      {% endfor %}
                                  </div>
                                  {% endif %}

                                  <a href="#" class="{% if item.hassuggestion %}sugglink{% else %}sugglink hide{% endif %}">
                                    <span class='scount'>{{ item.trans.suggtext }}</span>
                                  </a>
                                  {% if item.trans.suggestions %}
                                  <div class="suggestions">
                                      <ul class="sugglist">
                                          {% for sugg in item.trans.suggestions %}
                                          <li>
                                              <span class="suggauthor" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">({{ sugg.author }})</span>
                                              <ul>
                                                  {% for form in sugg.forms %}
                                                  <li>{{ form.value }}</li>
                                                  {% endfor %}
                                              </ul>
                                          </li>
                                          {% endfor %}
                                      </ul>
                                  </div>
                                  {% endif %}
                              </div>
                          {% endif %}
                          </div>
                      </td>
                  </tr>
                  {% if item.editable %}
                  <tr>
                      {% if canedit %}
                      <td></td>
                      {% endif %}
                      <td class="translate-original {{ item.polarity }} comments">
                          {% if item.developer_comments %}
                          <div title="{{ developer_comments_title }}" class="developer-comments" lang="en" dir="ltr">{{ item.developer_comments|safe }}</div>
                          {% endif %}
                          {% if item.locations %}
                          <div class="translate-locations" lang="en" dir="ltr">{{ item.locations }}</div>
                          {% endif %}
                      </td>
                      <td class="translate-translation {{ item.polarity }} comments" lang="{{ LANGUAGE_CODE }}">
                          <div>{{ translator_comments_title }}</div>
                          <textarea dir="{{ language.dir }}" lang="{{ language.code }}" name="translator_comments{{ item.itemid }}"
                                    id="translator_comments{{ item.itemid }}" rows="2"
                                    class="comments expanding">{{ item.translator_comments|safe }}</textarea>
                      </td>
                  </tr>
                  {% endif %}
                  {% endfor %}
                </table>
            </form>
            {% endif %}

          {% if pagelinks %}
          <!--! start/next/previous/end links -->
          <ul class="translations-nav" lang="{{ LANGUAGE_CODE }}">
            {% for pagelink in pagelinks %}
              <li><a href="{{ pagelink.href|l }}">{{ pagelink.text }}</a></li>
            {% endfor %}
          </ul>
          {% endif %}
        </div>
  </div>
</div>
{% endblock content %}

{% block scripts_extra %}
{{ block.super }}
<script src='{{ "js/json2.min.js"|m }}' type="text/javascript"></script>
<script src='{{ "js/autoexpand.js"|m }}' type="text/javascript"></script>
<script src='{{ "js/translatepage.js"|m }}' type="text/javascript"></script>
{% endblock scripts_extra %}
