diff --git a/templates/cards/blocks/note.html.twig b/templates/cards/blocks/note.html.twig index fe58b01f32..0ddbb99202 100644 --- a/templates/cards/blocks/note.html.twig +++ b/templates/cards/blocks/note.html.twig @@ -127,34 +127,30 @@ class="note-complementary"> {% if complementary_info_array is not empty %}
- {% for complementary_info in complementary_info_array %} - {% set actor_count = complementary_info['actors'] | length %} - {% set counter = 0 %} - - {% for complementary_info_actor in complementary_info['actors'] %} - {% if app.user is not null %} - {% if complementary_info_actor is defined and complementary_info_actor.getNickname() != app.user.nickname %} - {{ complementary_info_actor.getNickname() }}{% if actor_count > 1 and counter < actor_count - 2 %}{{ ', ' | trans }}{% endif %}{# TODO translate properly#} - {% if counter == actor_count - 2 %}{{ ' and ' | trans }}{% endif %} - - {% set counter = counter + 1 %} + {% for complementary_info in complementary_info_array %} + {% set formatted = [] %} + {% if complementary_info['action'] is defined and not null %} + + {% for complementary_info_actor in complementary_info['actors'] %} + {% if complementary_info_actor is defined and (app.user is null or complementary_info_actor.getNickname() != app.user.nickname) %} + {% set tmp %}{{ complementary_info_actor.getNickname() }}{% endset %} + {% set formatted = formatted|merge([tmp]) %} {% endif %} - {% else %} - {% if complementary_info_actor is defined %} - {{ complementary_info_actor.getNickname() }}{% if actor_count > 1 and counter < actor_count - 2 %}{{ ', ' | trans }}{% endif %}{# TODO translate properly#} - {% if counter == actor_count - 2 %}{{ ' and ' | trans }}{% endif %} - {% set counter = counter + 1 %} - {% endif %} - {% endif %} - {% endfor %} - - {% if complementary_info['action'] is defined and not null and counter > 0 %} - {% if counter > 1 %}{{ ' have ' | trans }} - {% else %}{{ ' has ' | trans }} - {% endif %}{{ complementary_info['action'] ~ ' this note' | trans }} + {% endfor %} + {{ trans( + { + '1': "{formatted} has {action} this note", + 'other': "{formatted} have {action} this note" + }, + { + 'count': formatted|length, + 'formatted': trans_list(formatted), + 'action': complementary_info['action'] + } + ) | raw }} + {% endif %} - - {% endfor %} + {% endfor %}
{% endif %}