[TEMPLATES][I18N] Fixup use of trans filter, in favour of trans tags. These are much more flexible and facilitate parameterized translations, rather than using concats. The only appropriate use of the trans filter is when a whole string in a variable needs to be translated (which should probably be avoided anyway)

This commit is contained in:
2022-03-01 11:27:19 +00:00
parent 0b864e85fd
commit b3374333f3
25 changed files with 93 additions and 87 deletions

View File

@@ -5,7 +5,7 @@
<section class="frame-section frame-section-padding">
{% include '/cards/blocks/attachment.html.twig' with {'attachment': attachment, 'note': bare_notes[key], 'title': attachment.getBestTitle(bare_notes[key])} only %}
<a class="frame-section-button-like"
href="{{ attachment.getDownloadUrl(bare_notes[key]) }}"> {{ 'Download link' | trans }}</a>
href="{{ attachment.getDownloadUrl(bare_notes[key]) }}">{% trans %}Download link{% endtrans %}</a>
</section>
{% else %}
<div id="empty-notes"><h1>{% trans %}No attachments here.{% endtrans %}</h1></div>

View File

@@ -3,7 +3,7 @@
<section class="frame-section frame-section-padding">
<div class="section-title">
<span class="heading-no-margin">
{{ 'Notes related' | trans }}
{% trans %}Related notes{% endtrans %}
</span>
</div>
@@ -11,4 +11,4 @@
{% set args = { 'type': 'vanilla_compact', 'note': note } %}
{{ NoteFactory.constructor(args) }}
{% endfor %}
</section>
</section>

View File

@@ -1,13 +1,13 @@
<section class="frame-section frame-section-padding">
<div class="section-title">
<span class="heading-no-margin">
{{ 'Attachment tags' | trans }}
{% trans %}Attachment tags{% endtrans %}
</span>
</div>
{% for tag in related_tags %}
<i>#{{ tag['tag'] }}</i>
{% else %}
{{ 'No tags' | trans }}
{% trans %}No tags{% endtrans %}
{% endfor %}
</section>
</section>

View File

@@ -1,7 +1,7 @@
{% extends 'stdgrid.html.twig' %}
{% import "/cards/macros/note/factory.html.twig" as NoteFactory %}
{% block title %}{{ 'Delete ' | trans }}{{ 'note' | trans }}{% endblock %}
{% block title %}{% trans %}Delete note{% endtrans %}{% endblock %}
{% block stylesheets %}
{{ parent() }}

View File

@@ -1,7 +1,8 @@
{% extends 'stdgrid.html.twig' %}
{% import "/cards/macros/note/factory.html.twig" as NoteFactory %}
{% block title %}{{ 'Favourite ' | trans }}{{ note.getActorNickname() }}{{ '\'s note.' | trans }}{% endblock %}
{% set nickname = note.getActorNickname() %}
{% block title %}{% trans %}Favourite %nickname%'s note{% endtrans %}{% endblock %}
{% block stylesheets %}
{{ parent() }}

View File

@@ -1,7 +1,8 @@
{% extends 'stdgrid.html.twig' %}
{% import "/cards/macros/note/factory.html.twig" as NoteFactory %}
{% block title %}{{ 'Remove favourite from ' | trans }}{{ note.getActorNickname() }}{{ '\'s note.' | trans }}{% endblock %}
{% set nickname = note.getActorNickname() %}
{% block title %}{% trans %}Remove favourite from %nickname%'s note{% endtrans %}{% endblock %}
{% block stylesheets %}
{{ parent() }}

View File

@@ -1,7 +1,8 @@
{% for tab in tabs %}
<li>
<a href="{{ tab.url }}" title="{{ tab.active ? ('Hide ' ~ tab['icon']) : ('Show ' ~ tab['icon']) | trans }}">
{{ tab['icon'] }}
{% set icon = tab['icon'] %}
<a href="{{ tab.url }}" title="{% if tab.active %}{% trans %}Hide %icon%{% endtrans %}{% else %}{% trans %}Show %icon%{% endtrans %}{% endif %}">
{{ icon }}
<span class="icon {{ tab.active ? 'icon-eye-opened' : 'icon-eye-closed' }}"></span>
</a>
</li>

View File

@@ -1,7 +1,8 @@
{% extends 'stdgrid.html.twig' %}
{% import "/cards/macros/note/factory.html.twig" as NoteFactory %}
{% block title %}{{ 'Repeat ' | trans }}{{ note.getActorNickname() }}{{ '\'s note.' | trans }}{% endblock %}
{% set nickname = note.getActorNickname() %}
{% block title %}{% trans %}Repeat %nickname%'s note{% endtrans %}{% endblock %}
{% block stylesheets %}
{{ parent() }}

View File

@@ -1,7 +1,8 @@
{% extends 'stdgrid.html.twig' %}
{% import "/cards/macros/note/factory.html.twig" as NoteFactory %}
{% block title %}{{ 'Remove repeat from ' | trans }}{{ note.getActorNickname() }}{{ '\'s note.' | trans }}{% endblock %}
{% set nickname = note.getActorNickname() %}
{% block title %}{% trans %}Remove repeat from %nickname%'s note{% endtrans %}{% endblock %}
{% block stylesheets %}
{{ parent() }}

View File

@@ -72,7 +72,7 @@ class TreeNotes extends Plugin
'replies' => array_map(
fn ($n) => [
'note' => $n,
'replies' => [],
'replies' => [], // We want only one depth level
'show_more' => ($n->getRepliesCount() > $max_replies_to_show),
'total_replies' => $n->getRepliesCount(),
],

View File

@@ -1,10 +1,10 @@
{% import '/cards/macros/note/factory.html.twig' as NoteFactory %}
<section class="note-replies" title="{{ 'Replies to ' | trans }}{{ nickname }}{{ '\'s note' | trans }}">
<section class="note-replies" title="{% trans %}Replies to %nickname%'s note{% endtrans %}">
<div class="note-replies-start"></div>
<div class="u-in-reply-to replies">
{% for reply in conversation.replies %}
<span class="note-replies-indicator" role="presentation"></span>
{% set args = reply | merge({ 'type': 'vanilla_full' }) %}
{% set args = reply | merge({ 'type': 'vanilla_full'}) %}
{{ NoteFactory.constructor(args) }}
{% endfor %}
{% if conversation.show_more %}
@@ -16,4 +16,4 @@
</a>
{% endif %}
</div>
</section>
</section>