Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f0e0ee9

Browse files
committed
Feature #23583 Add current and fallback locales in WDT / Profiler
1 parent 9fa3895 commit f0e0ee9

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

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

Lines changed: 24 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 }}
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,24 @@
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 }}</span>
76+
<span class="label">Locale</span>
77+
</div>
78+
79+
{% if collector.fallbackLocales|length %}
80+
<div class="metric">
81+
<span class="value">{{ collector.fallbackLocales | join(' | ') }}</span>
82+
<span class="label">Fallback locales</span>
83+
</div>
84+
{% endif %}
85+
86+
</div>
87+
6488
<h2>Translation Metrics</h2>
6589

6690
<div class="metrics">

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

Lines changed: 23 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,26 @@ public function getCountDefines()
8790
return isset($this->data[DataCollectorTranslator::MESSAGE_DEFINED]) ? $this->data[DataCollectorTranslator::MESSAGE_DEFINED] : 0;
8891
}
8992

93+
/**
94+
* Gets the translator locale.
95+
*
96+
* @return string
97+
*/
98+
public function getLocale()
99+
{
100+
return isset($this->data['locale']) ? $this->data['locale'] : '';
101+
}
102+
103+
/**
104+
* Gets the fallback locales.
105+
*
106+
* @return array
107+
*/
108+
public function getFallbackLocales()
109+
{
110+
return isset($this->data['fallback_locales']) ? $this->data['fallback_locales'] : array();
111+
}
112+
90113
/**
91114
* {@inheritdoc}
92115
*/

0 commit comments

Comments
 (0)