Skip to content

Commit

Permalink
replaced calls to with to produce flat message arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
hardchor committed Oct 12, 2013
1 parent d3f6051 commit 88a0ae2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 1 addition & 5 deletions Controller/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,7 @@ public function exposeTranslationAction(Request $request, $domain_name, $_locale

$messages = array();
foreach ($catalogues as $catalogue) {
$messages = array_merge_recursive($messages, $catalogue->all());
}

foreach ($messages as &$domain) {
$domain = array_map(function($m){ return is_array($m) ? end($m) : $m; }, $domain);
$messages = array_replace_recursive($messages, $catalogue->all());
}

$content = $this->engine->render('BazingaExposeTranslationBundle::exposeTranslation.' . $_format . '.twig', array(
Expand Down
4 changes: 1 addition & 3 deletions Dumper/TranslationDumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ public function dump($targetDir = 'web', $symlink = false, $directory = null)
foreach ($this->getTranslationMessages() as $locale => $domains) {
foreach ($domains as $domain => $messageList) {
foreach ($formats as $format) {
$messageList = array_map(function($m){ return is_array($m) ? end($m) : $m; }, $messageList);

$content = $this->engine->render('BazingaExposeTranslationBundle::exposeTranslation.' . $format . '.twig', array(
'messages' => array($domain => $messageList),
'locale' => $locale,
Expand Down Expand Up @@ -160,7 +158,7 @@ private function getTranslationMessages()
$catalogue = $this->loaders[$extension]->load($file, $locale, $domain);

if (isset($messages[$locale])) {
$messages[$locale] = array_merge_recursive($messages[$locale], $catalogue->all());
$messages[$locale] = array_replace_recursive($messages[$locale], $catalogue->all());
} else {
$messages[$locale] = $catalogue->all();
}
Expand Down

0 comments on commit 88a0ae2

Please sign in to comment.