BUGFIX Fixed i18n::get_locale_from_lang() to return original parameter if it detects a fully qualified locale that shouldn't be converted

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@75675 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-04-29 23:15:38 +00:00
parent a39822712b
commit 3d0c4a1615
2 changed files with 9 additions and 1 deletions

View File

@ -1603,7 +1603,9 @@ class i18n extends Object {
* @return string Long locale, e.g. "en_US"
*/
static function get_locale_from_lang($lang) {
if(isset(self::$likely_subtags[$lang])) {
if(preg_match('/\-|_/', $lang)) {
return $lang;
} else if(isset(self::$likely_subtags[$lang])) {
return self::$likely_subtags[$lang];
} else {
return $lang . '_' . strtoupper($lang);

View File

@ -198,6 +198,12 @@ class i18nTest extends SapphireTest {
i18n::set_locale($oldLocale);
}
function testGetLocaleFromLang() {
$this->assertEquals('en_US', i18n::get_locale_from_lang('en'));
$this->assertEquals('de_DE', i18n::get_locale_from_lang('de_DE'));
$this->assertEquals('xy_XY', i18n::get_locale_from_lang('xy'));
}
}
class i18nTest_DataObject extends DataObject implements TestOnly {