mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
8335201279
commit
7adb9ce17d
@ -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];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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'))
|
||||
)
|
||||
);
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user