mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Supporting "Locale-English" and "Locale-Native" as listing arguments in LanguageDropdownField
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73467 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c14b71dfc0
commit
4e5bc0f7fa
@ -13,7 +13,7 @@ class LanguageDropdownField extends GroupedDropdownField {
|
||||
* @param string $title
|
||||
* @param array $dontInclude list of languages that won't be included
|
||||
* @param string $translatingClass Name of the class with translated instances where to look for used languages
|
||||
* @param string $list Indicates the source language list. Can be either Common-English, Common-Native Locale
|
||||
* @param string $list Indicates the source language list. Can be either Common-English, Common-Native, Locale-English, Locale-Native
|
||||
*/
|
||||
function __construct($name, $title, $dontInclude = array(), $translatingClass = 'SiteTree', $list = 'Common-English' ) {
|
||||
$usedlangs = array_diff(
|
||||
@ -27,22 +27,24 @@ class LanguageDropdownField extends GroupedDropdownField {
|
||||
array_flip($dontInclude)
|
||||
);
|
||||
|
||||
//if (isset($usedlangs[Translatable::default_lang()])) unset($usedlangs[Translatable::default_lang()]);
|
||||
//if (isset($usedlangs[Translatable::default_locale()])) unset($usedlangs[Translatable::default_locale()]);
|
||||
|
||||
if ('Common-English' == $list) $languageList = i18n::get_common_languages();
|
||||
else if ('Common-Native' == $list) $languageList = i18n::get_common_languages(true);
|
||||
else if ('Locale-English' == $list) $languageList = i18n::get_common_locales();
|
||||
else if ('Locale-Native' == $list) $languageList = i18n::get_common_locales(true);
|
||||
else $languageList = i18n::get_locale_list();
|
||||
|
||||
$alllangs = array_diff(
|
||||
$languageList,
|
||||
(array)$usedlangs,
|
||||
$dontInclude
|
||||
);
|
||||
$languageList,
|
||||
(array)$usedlangs,
|
||||
$dontInclude
|
||||
);
|
||||
$alllangs = array_flip(array_diff(
|
||||
array_flip($alllangs),
|
||||
$dontInclude
|
||||
));
|
||||
if (isset($alllangs[Translatable::default_lang()])) unset($alllangs[Translatable::default_lang()]);
|
||||
array_flip($alllangs),
|
||||
$dontInclude
|
||||
));
|
||||
if (isset($alllangs[Translatable::default_locale()])) unset($alllangs[Translatable::default_locale()]);
|
||||
|
||||
asort($alllangs);
|
||||
if (count($usedlangs)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user