Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 30e3b6d

Browse filesBrowse files
committed
feature #23625 Feature #23583 Add current and fallback locales in WDT / Profiler (nemoneph)
This PR was merged into the 3.4 branch. Discussion ---------- Feature #23583 Add current and fallback locales in WDT / Profiler | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23583 | License | MIT | Doc PR | - The goal of this PR is to add informations about the locale and the fallback locales in the translation WDT panel / and profiler Commits ------- 98a8a6c Feature #23583 Add current and fallback locales in WDT / Profiler
2 parents 76ccce7 + 98a8a6c commit 30e3b6d
Copy full SHA for 30e3b6d

File tree

2 files changed

+33
-0
lines changed
Filter options

2 files changed

+33
-0
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/translation.html.twig
+20Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
{% endset %}
1313

1414
{% set text %}
15+
<div class="sf-toolbar-info-piece">
16+
<b>Locale</b>
17+
<span class="sf-toolbar-status">
18+
{{ collector.locale|default('-') }}
19+
</span>
20+
</div>
1521
<div class="sf-toolbar-info-piece">
1622
<b>Missing messages</b>
1723
<span class="sf-toolbar-status sf-toolbar-status-{{ collector.countMissings ? 'red' }}">
@@ -61,6 +67,20 @@
6167
{% endblock %}
6268

6369
{% block panelContent %}
70+
71+
<h2>Translation Locales</h2>
72+
73+
<div class="metrics">
74+
<div class="metric">
75+
<span class="value">{{ collector.locale|default('-') }}</span>
76+
<span class="label">Locale</span>
77+
</div>
78+
<div class="metric">
79+
<span class="value">{{ collector.fallbackLocales|join(', ')|default('-') }}</span>
80+
<span class="label">Fallback locales</span>
81+
</div>
82+
</div>
83+
6484
<h2>Translation Metrics</h2>
6585

6686
<div class="metrics">

‎src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ public function lateCollect()
4545
$this->data = $this->computeCount($messages);
4646
$this->data['messages'] = $messages;
4747

48+
$this->data['locale'] = $this->translator->getLocale();
49+
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();
50+
4851
$this->data = $this->cloneVar($this->data);
4952
}
5053

@@ -87,6 +90,16 @@ public function getCountDefines()
8790
return isset($this->data[DataCollectorTranslator::MESSAGE_DEFINED]) ? $this->data[DataCollectorTranslator::MESSAGE_DEFINED] : 0;
8891
}
8992

93+
public function getLocale()
94+
{
95+
return !empty($this->data['locale']) ? $this->data['locale'] : null;
96+
}
97+
98+
public function getFallbackLocales()
99+
{
100+
return (isset($this->data['fallback_locales']) && count($this->data['fallback_locales']) > 0) ? $this->data['fallback_locales'] : array();
101+
}
102+
90103
/**
91104
* {@inheritdoc}
92105
*/

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.