Skip to content

Commit

Permalink
Feature #23583 Add current and fallback locales in WDT / Profiler
Browse files Browse the repository at this point in the history
  • Loading branch information
nemoneph committed Sep 11, 2017
1 parent b1b6860 commit 98a8a6c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Expand Up @@ -12,6 +12,12 @@
{% endset %}

{% set text %}
<div class="sf-toolbar-info-piece">
<b>Locale</b>
<span class="sf-toolbar-status">
{{ collector.locale|default('-') }}
</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Missing messages</b>
<span class="sf-toolbar-status sf-toolbar-status-{{ collector.countMissings ? 'red' }}">
Expand Down Expand Up @@ -61,6 +67,20 @@
{% endblock %}

{% block panelContent %}

<h2>Translation Locales</h2>

<div class="metrics">
<div class="metric">
<span class="value">{{ collector.locale|default('-') }}</span>
<span class="label">Locale</span>
</div>
<div class="metric">
<span class="value">{{ collector.fallbackLocales|join(', ')|default('-') }}</span>
<span class="label">Fallback locales</span>
</div>
</div>

<h2>Translation Metrics</h2>

<div class="metrics">
Expand Down
Expand Up @@ -45,6 +45,9 @@ public function lateCollect()
$this->data = $this->computeCount($messages);
$this->data['messages'] = $messages;

$this->data['locale'] = $this->translator->getLocale();
$this->data['fallback_locales'] = $this->translator->getFallbackLocales();

$this->data = $this->cloneVar($this->data);
}

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

public function getLocale()
{
return !empty($this->data['locale']) ? $this->data['locale'] : null;
}

public function getFallbackLocales()
{
return (isset($this->data['fallback_locales']) && count($this->data['fallback_locales']) > 0) ? $this->data['fallback_locales'] : array();
}

/**
* {@inheritdoc}
*/
Expand Down

0 comments on commit 98a8a6c

Please sign in to comment.