Permalink
Browse files

refactor the i18n behavior to be more ungreedy

  • Loading branch information...
1 parent d6eaca8 commit 543bc2b7af7b0ea7e72012d742d63e32ad096711 @skie skie committed Oct 20, 2010
Showing with 5 additions and 3 deletions.
  1. +5 −3 models/behaviors/i18nable.php
@@ -57,10 +57,12 @@ public function beforeFind(&$Model, $query) {
$settings = $this->settings[$Model->alias];
$language = Configure::read('Config.language');
if ($Model->hasField($settings['languageField']) && (!isset($query['ignoreLanguage']))) {
- if (isset($query['language'])) {
- $language = $query['language'];
+ if (empty($query['conditions'][$Model->alias. '.' . $settings['languageField']])) {
+ if (isset($query['language'])) {
+ $language = $query['language'];
+ }
+ $query['conditions'][$Model->alias . '.' . $settings['languageField']] = $language;
}
- $query['conditions'][$Model->alias . '.' . $settings['languageField']] = $language;
}
return $query;
}

0 comments on commit 543bc2b

Please sign in to comment.