{% load i18n %}
{% load translations %}
{% load icons %}

{% for item in glossary %}
  {% if "forbidden" in item.all_flags %}
    <tr class="glossary-embed danger" title="{% trans "This translation is forbidden." %}">
  {% elif "read-only" in item.all_flags %}
    <tr class="glossary-embed clickable-row warning" title="{% trans "This term should not be translated." %}">
  {% else %}
    <tr class="glossary-embed clickable-row" title="{% trans "Copy word into translation" %}">
  {% endif %}
    <td class="source">{{ item.source }}</td>
    <td class="target">
      {% if "forbidden" in item.all_flags %}
        <span class="red forbidden-term">
          {% icon "cancel.svg" %}
        </span>
      {% endif %}
      {% format_translation item.target unit.translation.language unit.translation.plural simple=True %}
    </td>
    <td>{% include "snippets/glossary-badge.html" with glossary=item.translation %}</td>
    <td><a href="{{ item.get_absolute_url }}" class="btn btn-link btn-xs" title="{% trans "Edit glossary term" %}">{% icon "pencil.svg" %}</a>
    </tr>
    {% if item.note %}
      <tr>
        <td colspan="4">
          <em>
          {{ item.note }}
          </em>
        </td>
      </tr>
    {% endif %}
    {% if item != item.source_unit and item.explanation %}
      <tr>
        <td colspan="4">
          <em>
          {{ item.explanation|markdown }}
          </em>
        </td>
      </tr>
    {% endif %}
    {% if item.source_unit.explanation %}
      <tr>
        <td colspan="4">
          <em>
          {{ item.source_unit.explanation|markdown }}
          </em>
        </td>
      </tr>
    {% endif %}
{% empty %}
    <tr>
    <td colspan="4"><em>{% trans "No related strings found in the glossary." %}</em></td>
    </tr>
{% endfor %}
