Permalink
Browse files

Updating logic for _translated_ in `_merge()` of catalog `Base` adapter.

  • Loading branch information...
1 parent 422c835 commit 30646bb2df1febed3f04980bb98e5466a2c36ed6 @davidpersson davidpersson committed with gwoo Feb 25, 2010
Showing with 8 additions and 6 deletions.
  1. +5 −3 libraries/lithium/g11n/Message.php
  2. +3 −3 libraries/lithium/g11n/catalog/adapter/Base.php
@@ -163,15 +163,17 @@ protected static function _translated($id, $count, $locale, array $options = arr
if (!isset($page[$id])) {
return null;
}
- $translated = (array) $page[$id];
+ if (!is_array($page[$id])) {
+ return $page[$id];
+ }
if (!isset($page['plural']) || !is_callable($page['plural'])) {
return null;
}
$key = $page['plural']($count);
- if (isset($translated[$key])) {
- return $translated[$key];
+ if (isset($page[$id][$key])) {
+ return $page[$id][$key];
}
});
}
@@ -90,10 +90,10 @@ protected function _merge($data, $item) {
foreach (array('ids', 'flags', 'comments', 'occurrences') as $field) {
$data[$id][$field] = array_merge($data[$id][$field], $item[$field]);
}
- if (is_array($item['translated'])) {
- $data[$id]['translated'] = (array) $data[$id]['translated'] + $item['translated'];
- } elseif (!isset($data[$id]['translated'])) {
+ if (!isset($data[$id]['translated'])) {
$data[$id]['translated'] = $item['translated'];
+ } elseif (is_array($item['translated'])) {
+ $data[$id]['translated'] = (array) $data[$id]['translated'] + $item['translated'];
}
return $data;
}

0 comments on commit 30646bb

Please sign in to comment.