mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
a39822712b
commit
3d0c4a1615
@ -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);
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user