{% extends "base.html" %}
{% load i18n %}
{% load translations %}
{% load icons %}

{% block breadcrumbs %}
<li><a href="{{ project.get_absolute_url }}">{{ project.name }}</a></li>
{% if component %}
{% include "snippets/component-breadcrumb.html" with object=component %}
{% if translation %}
{% include "snippets/translation-breadcrumb.html" with object=translation %}
{% endif %}
{% elif language %}
<li>
  <a href="{{ language.get_absolute_url }}">{{ language }}</a>
</li>

{% endif %}
<li>{% trans "Search and replace" %}</li>
{% endblock %}

{% block content %}

{% trans "Please review and confirm the search and replace results." as msg %}
{% show_message "info" msg %}

{% if limited %}
  {% trans "Showing and replacing only the first 250 matches. Perform the replacement again to replace more." as msg %}
  {% show_message "warning" msg %}
{% endif %}

<form method="POST">
{% csrf_token %}
{{ form.q.as_hidden }}
{{ form.search.as_hidden }}
{{ form.replacement.as_hidden }}
{{ confirm.confirm }}

<table class="table replace-preview">
{% for unit in matching %}
<tr class="warning">
<td>
<input type="checkbox" name="units" checked="1" value="{{ unit.pk }}" id="confirm_{{ unit.pk }}" />
</td>
<td>
  <a href="{{ unit.get_absolute_url }}" class="btn btn-link btn-xs" title="{% trans "Edit" %}">{% icon "pencil.svg" %}</a>
  <label for="confirm_{{ unit.pk }}">{{ unit.translation }}: {{ unit.position }}{% if unit.context %}({{ unit.context }}){% endif %}</label>
  <br/>
  {% format_translation unit.target unit.translation.language unit.translation.plural search_match=search_query match='replaced'%}
  <br/>
  {% format_translation unit.replacement unit.translation.language unit.translation.plural search_match=replacement match='replacement' %}
</td>
</tr>
{% endfor %}
</table>
<input type="submit" class="btn btn-primary" value="{% trans "Replace" %}" />
</form>

{% endblock %}
