{% extends "tp_base.html" %}
{% load i18n assets render_pager baseurl cache locale search store_tags translation_project_tags %}
{% get_current_language as LANGUAGE_CODE %}

{% block title %}{% trans "Translate" %} | {{ block.super }}{% endblock %}

{% block body_id %}tptranslate{% endblock %}

{% block css %}
{% cache settings.CACHE_TIMEOUT translate_css user.is_authenticated settings.DEBUG %}
{{ block.super }}
{% assets "css_editor" %}
<link rel="stylesheet" type="text/css" href="{{ ASSET_URL }}" />
{% endassets %}
{% endcache %}
{% endblock css %}

{% block search %}
{% endblock %}

{% block content %}
{% cache settings.CACHE_TIMEOUT translate_content directory.id store_id cantranslate cansuggest LANGUAGE_CODE %}
<div id="editor" data-pootle-path="{{ store.pootle_path }}"
    data-directory="{{ directory.pootle_path }}"
    data-target-language="{{ language.code }}">
    <noscript>
      <h1>{% trans "Pootle's editor requires JavaScript" %}</h1>
      <p>{% trans "Please enable JavaScript in your browser preferences and reload the page." %}</p>
    </noscript>

    <div id="js-editor-act" class="hide editor-overlay loader"></div>
    <div id="js-editor-msg" class="hide editor-overlay">
      <div class="alert alert-block alert-info fade in" lang="{{ LANGUAGE_CODE }}">
        <button type="button" class="close js-editor-msg-hide">&times;</button>
        <span> <span>
      </div>
    </div>
    <div id="js-editor-error" class="hide toolbar-message">
      <div>
        <i class="icon-error pull-{% locale_align %}"></i>&nbsp;<span> </span>
      </div>
    </div>

    <table cellpadding="0" cellspacing="0" class="translate-table{% if cansuggest and not cantranslate %} suggest-mode{% endif%}" dir="{% locale_dir %}">
      <thead>
        <tr lang="{{ LANGUAGE_CODE }}">
          <th colspan="1" rowspan="1" class="translate-table-title translate-original"></th>
          <th colspan="1" rowspan="1" class="translate-table-title translate-translation"></th>
        </tr>
      </thead>
      <tbody>
      </tbody>
    </table>
</div>
{% endcache %}
{% endblock %}

{% block extra_content %}
{% cache settings.CACHE_TIMEOUT translate_extra LANGUAGE_CODE %}
<div id="toolbar">

  <div class="toolbar pull-left">
    {% render_search search_form %}

    <div class="label">{% trans "Filter by:" %}</div>
    <div id="filter-status">
      <select name="filter-status">
        {# Translators: This refers to "All strings" #}
        <option selected="selected" value="all">{% trans "All" %}</option>
        <option value="translated">{% trans "Translated" %}</option>
        <option value="incomplete">{% trans "Incomplete" %}</option>
        <option value="untranslated">{% trans "Untranslated" %}</option>
        <option value="fuzzy">{% trans "Needs work" %}</option>
        <option value="suggestions">{% trans "Suggestions" %}</option>
        <option value="mysuggestions">{% trans "My suggestions" %}</option>
        <option value="mysubmissions">{% trans "My submissions" %}</option>
        {% comment %}Translators: This is a type of filtering criterion that
        selects the strings that have been submitted by me at some point
        in time but have been overwritten by other users.{% endcomment %}
        <option value="submissionsafterme">{% trans "My overwritten submissions" %}</option>
        <option value="checks">{% trans "Checks" %}</option>
      </select>
    </div>
  </div>

  <div class="toolbar pull-right">
    <div id="editor-permalink"></div>
    <div id="prevnext" lang="{{ LANGUAGE_CODE }}" dir="{% locale_dir %}">
      <input type="submit" id="js-nav-prev" name="back" accesskey="b" value="{% trans 'Previous string' %}" title="{% trans 'Go to the previous string (Ctrl+Up)<br/><br/>Also:<br/>Previous page: Ctrl+Shift+Page&nbsp;Up<br/>First page: Ctrl+Shift+Home' %}" />
      <span id="item-navigation">
        <input id="item-number" type="text" value="1" size="1" title="{% trans 'Current page number (Ctrl+Shift+U)<br/><br/>Type in the number and press Enter<br/>to go to any position' %}" />
        /
        <span id="items-count" title="{% trans 'Total pages' %}"></span>
      </span>
      <input type="submit" id="js-nav-next" name="skip" accesskey="k" value="{% trans 'Next string' %}" title="{% trans 'Go to the next string (Ctrl+Down)<br/><br/>Also:<br/>Next page: Ctrl+Shift+Page&nbsp;Down<br/>Last page: Ctrl+Shift+End' %}" />
    </div>
  </div>
</div>
{% endcache %}
{% endblock %}

{% block scripts_extra %}
{% cache settings.CACHE_TIMEOUT translate_scripts request.is_secure cansuggest cantranslate MT_BACKENDS LOOKUP_BACKENDS user.is_authenticated LANGUAGE_CODE settings.DEBUG %}
{{ block.super }}
<script id="view_unit" type="text/x-jquery-template">
{% include_raw "unit/xhr-view.html" %}
</script>
<script id="tm_suggestions" type="text/x-jquery-template">
{% include_raw "unit/xhr-tm.html" %}
</script>
<script id="editCtx" type="text/x-jquery-template">
{% include_raw "unit/xhr-edit-ctx.html" %}
</script>
{% assets "js_editor" %}
<script type="text/javascript" src="{{ ASSET_URL }}"></script>
{% endassets %}
<script type="text/javascript">
$(function() {
  $('.js-dev-img').fancybox({nextEffect: 'none', prevEffect: 'none'});
  var options = {};
  {% if request.is_secure %}options.secure = true;{% endif %}
  {% if cansuggest or cantranslate %}
  options.mt = [];
    {% for backend, apikey in MT_BACKENDS %}
    options.mt.push({name: "{{ backend|lower }}", key: "{{ apikey }}"});
    {% endfor %}
  {% endif %}
  options.lookup = [];
  {% for backend in LOOKUP_BACKENDS %}
    options.lookup.push("{{ backend|lower }}");
  {% endfor %}
  options.tmUrl = '{{ AMAGAMA_URL }}';
  PTL.editor.init(options);
});
</script>
{% endcache %}
{% endblock scripts_extra %}

{% block footer %}
<div id="translate-footer"></div>
{% endblock footer %}
