BUGFIX: Allow translation of front-end content into all languages, not just common ones (Merged from r64943)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.2@73367 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sean Harvey 2009-03-19 03:08:59 +00:00 committed by Sam Minnee
parent 8335201279
commit 7adb9ce17d
3 changed files with 13 additions and 3 deletions

View File

@ -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];
}
/**

View File

@ -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'))
)
);

View File

@ -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,