diff --git a/core/i18n.php b/core/i18n.php index 3fd52c7c4..05680a8e2 100755 --- a/core/i18n.php +++ b/core/i18n.php @@ -860,8 +860,8 @@ class i18n extends Controller { * @return Name of the language */ static function get_language_name($code, $native = false) { - $langs = self::$common_languages; - return ($native ? $langs[$code][1] : $langs[$code][0]); + $langs = self::$all_locales; + return $langs[$code]; } /** diff --git a/core/model/Translatable.php b/core/model/Translatable.php index 54b19f60f..f80c14f75 100755 --- a/core/model/Translatable.php +++ b/core/model/Translatable.php @@ -606,12 +606,13 @@ class Translatable extends DataObjectDecorator { if (!$alreadyTranslatedLangs) $alreadyTranslatedLangs = array(); foreach ($alreadyTranslatedLangs as $i => $langCode) { $alreadyTranslatedLangs[$i] = i18n::get_language_name($langCode); + if($alreadyTranslatedLangs[$i] == null) user_error("Couldn't get language name for '$langCode'", E_USER_WARNING); } $fields->addFieldsToTab( 'Root', new Tab(_t('Translatable.TRANSLATIONS', 'Translations'), new HeaderField(_t('Translatable.CREATE', 'Create new translation'), 2), - $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLangs), + $langDropdown = new LanguageDropdownField("NewTransLang", _t('Translatable.NEWLANGUAGE', 'New language'), $alreadyTranslatedLangs, 'SiteTree', null), $createButton = new InlineFormAction('createtranslation',_t('Translatable.CREATEBUTTON', 'Create')) ) ); diff --git a/forms/LanguageDropdownField.php b/forms/LanguageDropdownField.php index 3b5875695..e1a00b94f 100755 --- a/forms/LanguageDropdownField.php +++ b/forms/LanguageDropdownField.php @@ -26,6 +26,15 @@ class LanguageDropdownField extends GroupedDropdownField { i18n::get_existing_content_languages($translatingClass), $dontInclude ); + + // Validate dontInclude + foreach($dontInclude as $i => $item) { + if(!is_numeric($item) && !is_string($item)) { + user_error("Bad value contained in dontInclude array, index $i: " . var_export($item,true), E_USER_WARNING); + unset($dontInclude[$i]); + } + } + // we accept in dontInclude both language codes and names, so another diff is required $usedlangs = array_diff( $usedlangs,