mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Don't use $tinymce_lang lookup in i18n::get_lang_from_locale(), as it mixes locales with langs and hence breaks language fallbacks in _t() (e.g. "pt_BR" returns "pt_br", rather than "pt")
This commit is contained in:
parent
c2797f3ffa
commit
a44916dc19
@ -1742,22 +1742,13 @@ class i18n extends Object implements TemplateGlobalProvider {
|
||||
|
||||
/**
|
||||
* Returns the "short" language name from a locale,
|
||||
* e.g. "en_US" would return "en". This conversion
|
||||
* is determined internally by the {@link $tinymce_lang}
|
||||
* lookup table. If no match can be found in this lookup,
|
||||
* the characters before the underscore ("_") are returned.
|
||||
*
|
||||
* @todo More generic lookup table, don't rely on tinymce specific conversion
|
||||
* e.g. "en_US" would return "en".
|
||||
*
|
||||
* @param string $locale E.g. "en_US"
|
||||
* @return string Short language code, e.g. "en"
|
||||
*/
|
||||
static function get_lang_from_locale($locale) {
|
||||
if(isset(self::$tinymce_lang[$locale])) {
|
||||
return self::$tinymce_lang[$locale];
|
||||
} else {
|
||||
return preg_replace('/(_|-).*/', '', $locale);
|
||||
}
|
||||
return preg_replace('/(_|-).*/', '', $locale);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user