{% extends "lfc/manage/base.html" %}
{% load i18n %}

{% block javascript %}
    {{ form.media }}
    <script>
        $(function() {
            $("#id_translation-title").live("keyup", function() {
                var slug = $("#id_translation-title").val()
                slug = URLify(slug, 200)
                $("#id_translation-slug").val(slug);
            });
        });
    </script>
{% endblock %}

{% block left-slot-wrapper %}{% endblock %}

{% block content %}
    <div style="padding:20px 30px 0 30px">
        <h2>{% trans 'Translate object' %} "{{canonical.title}}"</h2>

        <form action="{% url 'lfc_save_translation' %}"
              method="post"
              enctype="multipart/form-data"
              class="translate-form">
            {% csrf_token %}
            <table width="100%">
                <tr>
                    <td width="50%">
                        <table width="100%">
                            {% for field in form_canonical %}
                                <div class="field">
                                    <div class="label">
                                        {{ field.label_tag }}:
                                    </div>

                                    {% if field.errors %}
                                        <div class="error">
                                            {{ field|safe }}
                                            {{ field.errors }}
                                        </div>
                                    {% else %}
                                        <div>
                                            {{ field|safe }}
                                        </div>
                                    {% endif %}
                                </div>
                            {% endfor %}
                        </table>
                    </td>
                    <td width="50%">

                        <table width="100%">
                            {% for field in form_translation %}
                                <div class="field">
                                    <div class="label">
                                        {{ field.label_tag }}:
                                    </div>

                                    {% if field.errors %}
                                        <div class="error">
                                            {{ field|safe }}
                                            {{ field.errors }}
                                        </div>
                                    {% else %}
                                        <div>
                                            {{ field|safe }}
                                        </div>
                                    {% endif %}
                                </div>
                            {% endfor %}
                        </table>
                        <input type="hidden" name="translation_language" value="{{ translation_language }}">
                        <input type="hidden" name="canonical_id" value="{{canonical.id}}" />
                        <input type="hidden" name="translation_id" value="{{translation_id}}" />

                        <input type="submit" name="save" value="{% trans 'Save' %}" />
                        <input type="submit" name="cancel" value="{% trans 'Cancel' %}" />
                    </td>
                </tr>
            </table>

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