{% macro vital(addon, type) %}
  <div class="vital">
    {% if type in ('updated', 'created') %}
      <span class="updated">
        {% if type == 'updated' %}
          {# L10n: {0} is a date. #}
          {{ _('Updated {0}')|f(addon.last_updated|datetime) }}
        {% else %}
          {# L10n: {0} is a date. #}
          {{ _('Added {0}')|f(addon.created|datetime) }}
        {% endif %}
      </span>
    {% elif type in ('downloads', 'adu') %}
      {% if type == 'downloads' %}
        <span class="downloads adu">
          {% trans cnt=addon.weekly_downloads,
                   num=addon.weekly_downloads|numberfmt %}
            {{ num }} weekly download
          {% pluralize %}
            {{ num }} weekly downloads
          {% endtrans %}
        </span>
      {% else %}
        <span class="adu">
          {% set adu=addon.average_daily_users %}
          {% trans cnt=adu, num=adu|numberfmt %}
            {{ num }} user
          {% pluralize %}
            {{ num }} users
          {% endtrans %}
        </span>
      {% endif %}
    {% endif %}
  </div>
{% endmacro %}

{% macro addon_heading(addon, version) %}
  <h1{{ addon.name|locale_html }}>
    {{ addon.name }}
    {% if version %}
      <span class="version">{{ version.version }}</span>
    {% endif %}
  </h1>
{% endmacro %}

{% macro sort_vital(addon, field) %}
  {% if field in ('popular', 'downloads') or not addon.show_adu() %}
    <div class="adu downloads">
      {% with num=addon.weekly_downloads %}
        {# L10n: {0} is the number of downloads. #}
        {{ ngettext('{0} weekly download', '{0} weekly downloads',
                    num)|f(num|numberfmt) }}
      {% endwith %}
    </div>
  {% else %}
    <div class="adu">
      {% with num=addon.average_daily_users %}
        {# L10n: {0} is the number of users. #}
        {{ ngettext('{0} user', '{0} users', num)|f(num|numberfmt) }}
      {% endwith %}
    </div>
  {% endif %}
  {% if field in ('created', 'updated') %}
    <div class="updated">
      {% if field == 'created' %}
        {# L10n: {0} is a date. #}
        {{ _('Added {0}')|f(addon.created|datetime) }}
      {% else %}
        {# L10n: {0} is a date. #}
        {{ _('Updated {0}')|f(addon.last_updated|datetime) }}
      {% endif %}
    </div>
  {% endif %}
{% endmacro %}
