Fixing catalog() to return 3 char matches

This commit is contained in:
phpnut 2009-10-30 14:43:52 -05:00
parent 80b1eb4ee2
commit 7bead5df30
2 changed files with 13 additions and 0 deletions

View file

@ -474,6 +474,8 @@ class L10n extends Object {
} else if (is_string($language)) { } else if (is_string($language)) {
if (isset($this->__l10nCatalog[$language])) { if (isset($this->__l10nCatalog[$language])) {
return $this->__l10nCatalog[$language]; return $this->__l10nCatalog[$language];
} else if (isset($this->__l10nMap[$language]) && isset($this->__l10nCatalog[$this->__l10nMap[$language]])) {
return $this->__l10nCatalog[$this->__l10nMap[$language]];
} }
return false; return false;
} }

View file

@ -981,6 +981,17 @@ class L10nTest extends CakeTestCase {
'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8') 'pt-br' => array('language' => 'Portuguese (Brazil)', 'locale' => 'pt_br', 'localeFallback' => 'por', 'charset' => 'utf-8')
); );
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);
$result = $l10n->catalog(array('eng', 'deu', 'zho', 'rum', 'zul', 'yid'));
$expected = array(
'eng' => array('language' => 'English', 'locale' => 'eng', 'localeFallback' => 'eng', 'charset' => 'utf-8'),
'deu' => array('language' => 'German (Standard)', 'locale' => 'deu', 'localeFallback' => 'deu', 'charset' => 'utf-8'),
'zho' => array('language' => 'Chinese', 'locale' => 'chi', 'localeFallback' => 'chi', 'charset' => 'utf-8'),
'rum' => array('language' => 'Romanian', 'locale' => 'rum', 'localeFallback' => 'rum', 'charset' => 'utf-8'),
'zul' => array('language' => 'Zulu', 'locale' => 'zul', 'localeFallback' => 'zul', 'charset' => 'utf-8'),
'yid' => array('language' => 'Yiddish', 'locale' => 'yid', 'localeFallback' => 'yid', 'charset' => 'utf-8')
);
$this->assertEqual($result, $expected);
} }
} }
?> ?>