Skip to content

Commit 6651a75

Browse files
author
Olivier Dolbeau
committed
Override only what we need
1 parent e32091b commit 6651a75

File tree

1 file changed

+39
-104
lines changed

1 file changed

+39
-104
lines changed

Resources/views/SymfonyProfiler/translation.html.twig

Lines changed: 39 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -4,124 +4,59 @@
44
# Authors Tobias Nyholm, Damien Alexandre (damienalexandre), Damien Harper
55
#}
66

7-
{% import _self as translation_helper %}
8-
9-
{% block panelContent %}
10-
<h2>Translation Metrics</h2>
7+
{% import _self as helper %}
118

9+
{% block panel %}
10+
<h2>PHP Translation</h2>
1211
<div>
1312
<a class="btn" href="javascript:void(0);" onclick='syncAll()'>Synchronize all translations</a><br />
1413
<div id="top-result-area"></div>
1514
</div>
1615

17-
<div class="metrics">
18-
<div class="metric">
19-
<span class="value">{{ collector.countdefines }}</span>
20-
<span class="label">Defined messages</span>
21-
</div>
22-
23-
<div class="metric">
24-
<span class="value">{{ collector.countFallbacks }}</span>
25-
<span class="label">Fallback messages</span>
26-
</div>
27-
28-
<div class="metric">
29-
<span class="value">{{ collector.countMissings }}</span>
30-
<span class="label">Missing messages</span>
31-
</div>
32-
</div>
16+
<form action="{{ path('php_translation_profiler_translation_create_assets', {'token': token}) }}" method="post"
17+
id="translations-list" onSubmit="return saveTranslations(this);" >
18+
<span class="hidden">
19+
<img src="{{ asset("bundles/translation/css/images/loader.svg") }}" width="60" id="svg-loader">
20+
</span>
3321

34-
<h2>Translation Messages</h2>
35-
36-
{# sort translation messages in groups #}
37-
{% set messages_defined, messages_missing, messages_fallback = [], [], [] %}
38-
{% for key, message in collector.messages %}
39-
{% if message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_DEFINED') %}
40-
{% set messages_defined = messages_defined|merge({(key): message}) %}
41-
{% elseif message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_MISSING') %}
42-
{% set messages_missing = messages_missing|merge({(key): message}) %}
43-
{% elseif message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK') %}
44-
{% set messages_fallback = messages_fallback|merge({(key): message}) %}
45-
{% endif %}
46-
{% endfor %}
22+
{{ parent() }}
4723

48-
<form action="{{ path('php_translation_profiler_translation_create_assets', {'token': token}) }}" method="post"
49-
id="translations-list" onSubmit="return saveTranslations(this);" >
50-
<span class="hidden">
51-
<img src="{{ asset("bundles/translation/css/images/loader.svg") }}" width="60" id="svg-loader">
52-
</span>
53-
54-
<div class="sf-tabs">
55-
<div class="tab">
56-
<h3 class="tab-title">Defined <span class="badge">{{ messages_defined|length }}</span></h3>
57-
58-
<div class="tab-content">
59-
<p class="help">
60-
These messages are correctly translated into the given locale.
61-
</p>
62-
63-
{% if messages_defined is empty %}
64-
<div class="empty">
65-
<p>None of the used translation messages are defined for the given locale.</p>
66-
</div>
67-
{% else %}
68-
{{ translation_helper.render_table(messages_defined) }}
69-
{% endif %}
70-
</div>
71-
</div>
72-
73-
<div class="tab">
74-
<h3 class="tab-title">Fallback <span class="badge">{{ messages_fallback|length }}</span></h3>
75-
76-
<div class="tab-content">
77-
<p class="help">
78-
These messages are not available for the given locale
79-
but Symfony found them in the fallback locale catalog.
80-
</p>
81-
82-
{% if messages_fallback is empty %}
83-
<div class="empty">
84-
<p>No fallback translation messages were used.</p>
85-
</div>
86-
{% else %}
87-
{{ translation_helper.render_table(messages_fallback) }}
88-
{% endif %}
89-
</div>
90-
</div>
91-
92-
<div class="tab">
93-
<h3 class="tab-title">Missing <span class="badge">{{ messages_missing|length }}</span></h3>
94-
95-
<div class="tab-content">
96-
<p class="help">
97-
These messages are not available for the given locale and cannot
98-
be found in the fallback locales. Add them to the translation
99-
catalogue to avoid Symfony outputting untranslated contents.
100-
</p>
101-
102-
{% if messages_missing is empty %}
103-
<div class="empty">
104-
<p>There are no messages of this category.</p>
105-
</div>
106-
{% else %}
107-
{{ translation_helper.render_table(messages_missing, true) }}
108-
{% endif %}
109-
</div>
110-
</div>
111-
</div>
24+
<p class="full-width" id="translationResult"></p>
11225

113-
<p class="full-width" id="translationResult"></p>
26+
<button type="submit" class="btn">
27+
Add selected messages
28+
</button>
11429

115-
<button type="submit" class="btn">
116-
Add selected messages
117-
</button>
30+
</form>
11831

119-
</form>
12032
{% include "@Translation/SymfonyProfiler/javascripts.html.twig" %}
12133
{% endblock %}
12234

123-
{% block panel %}
124-
{{ block('panelContent') }}
35+
{% block defined_messages %}
36+
{% set messages = [] %}
37+
{% for key, message in collector.messages|filter(message => message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_DEFINED')) %}
38+
{% set messages = messages|merge({(key): message}) %}
39+
{% endfor %}
40+
41+
{{ helper.render_table(messages) }}
42+
{% endblock %}
43+
44+
{% block fallback_messages %}
45+
{% set messages = [] %}
46+
{% for key, message in collector.messages|filter(message => message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_EQUALS_FALLBACK')) %}
47+
{% set messages = messages|merge({(key): message}) %}
48+
{% endfor %}
49+
50+
{{ helper.render_table(messages) }}
51+
{% endblock %}
52+
53+
{% block missing_messages %}
54+
{% set messages = [] %}
55+
{% for key, message in collector.messages|filter(message => message.state == constant('Symfony\\Component\\Translation\\DataCollectorTranslator::MESSAGE_MISSING')) %}
56+
{% set messages = messages|merge({(key): message}) %}
57+
{% endfor %}
58+
59+
{{ helper.render_table(messages, true) }}
12560
{% endblock %}
12661

12762
{% macro render_table(messages, checkedByDefault = false) %}

0 commit comments

Comments
 (0)