diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php index 8a244af2f9e..8307d010e52 100644 --- a/htdocs/core/class/translate.class.php +++ b/htdocs/core/class/translate.class.php @@ -784,7 +784,32 @@ class Translate { // We must keep only main languages if ($mainlangonly) { - $arrayofspecialmainlanguages = array('en_US', 'sq_AL', 'ar_SA', 'eu_ES', 'bn_DB', 'bs_BA', 'ca_ES', 'zh_TW', 'cs_CZ', 'da_DK', 'et_EE', 'ka_GE', 'el_GR', 'he_IL', 'kn_IN', 'km_KH', 'ko_KR', 'lo_LA', 'nb_NO', 'fa_IR', 'sr_RS', 'sl_SI', 'uk_UA', 'vi_VN'); + $arrayofspecialmainlanguages = array( + 'en'=>'en_US', + 'sq'=>'sq_AL', + 'ar'=>'ar_SA', + 'eu'=>'eu_ES', + 'bn'=>'bn_DB', + 'bs'=>'bs_BA', + 'ca'=>'ca_ES', + 'zh'=>'zh_TW', + 'cs'=>'cs_CZ', + 'da'=>'da_DK', + 'et'=>'et_EE', + 'ka'=>'ka_GE', + 'el'=>'el_GR', + 'he'=>'he_IL', + 'kn'=>'kn_IN', + 'km'=>'km_KH', + 'ko'=>'ko_KR', + 'lo'=>'lo_LA', + 'nb'=>'nb_NO', + 'fa'=>'fa_IR', + 'sr'=>'sr_RS', + 'sl'=>'sl_SI', + 'uk'=>'uk_UA', + 'vi'=>'vi_VN' + ); if (strtolower($regs[1]) != strtolower($regs[2]) && ! in_array($dir, $arrayofspecialmainlanguages)) continue; } // We must keep only languages into MAIN_LANGUAGES_ALLOWED diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 1a7e4d0c28c..60fac55f443 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1275,7 +1275,7 @@ class Website extends CommonObject /** * Component to select language inside a container (Full CSS Only) * - * @param array|string $languagecodes 'auto' to show all languages available for page, or language codes array like array('en_US','fr_FR','de_DE','es_ES') + * @param array|string $languagecodes 'auto' to show all languages available for page, or language codes array like array('en','fr','de','es') * @param Translate $weblangs Language Object * @param string $morecss More CSS class on component * @param string $htmlname Suffix for HTML name @@ -1287,6 +1287,33 @@ class Website extends CommonObject if (!is_object($weblangs)) return 'ERROR componentSelectLang called with parameter $weblangs not defined'; + $arrayofspecialmainlanguages = array( + 'en'=>'en_US', + 'sq'=>'sq_AL', + 'ar'=>'ar_SA', + 'eu'=>'eu_ES', + 'bn'=>'bn_DB', + 'bs'=>'bs_BA', + 'ca'=>'ca_ES', + 'zh'=>'zh_TW', + 'cs'=>'cs_CZ', + 'da'=>'da_DK', + 'et'=>'et_EE', + 'ka'=>'ka_GE', + 'el'=>'el_GR', + 'he'=>'he_IL', + 'kn'=>'kn_IN', + 'km'=>'km_KH', + 'ko'=>'ko_KR', + 'lo'=>'lo_LA', + 'nb'=>'nb_NO', + 'fa'=>'fa_IR', + 'sr'=>'sr_RS', + 'sl'=>'sl_SI', + 'uk'=>'uk_UA', + 'vi'=>'vi_VN' + ); + // Load tmppage if we have $websitepagefile defined $tmppage = new WebsitePage($this->db); @@ -1302,7 +1329,7 @@ class Website extends CommonObject } } - // Fill with existing translation, nothing if none + // Fill $languagecodes array with existing translation, nothing if none if (!is_array($languagecodes) && $pageid > 0) { $languagecodes = array(); @@ -1325,16 +1352,17 @@ class Website extends CommonObject } } } - // Now $languagecodes is always an array + // Now $languagecodes is always an array. Example array('en', 'fr', 'es'); - $languagecodeselected = $weblangs->defaultlang; // Because we must init with a value, but real value is the lang of main parent container + $languagecodeselected = substr($weblangs->defaultlang, 0, 2); // Because we must init with a value, but real value is the lang of main parent container if (!empty($websitepagefile)) { $pageid = str_replace(array('.tpl.php', 'page'), array('', ''), basename($websitepagefile)); if ($pageid > 0) { - $languagecodeselected = $tmppage->lang; - if (!in_array($tmppage->lang, $languagecodes)) $languagecodes[] = $tmppage->lang; // We add language code of page into combo list + $pagelang = substr($tmppage->lang, 0, 2); + $languagecodeselected = substr($pagelang, 0, 2); + if (!in_array($pagelang, $languagecodes)) $languagecodes[] = $pagelang; // We add language code of page into combo list } } @@ -1373,12 +1401,18 @@ class Website extends CommonObject '; $out .= ''; $out .= '
'.$label;
+ if ($countrycode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label);
+ $out .= '
'.$label;
$out .= '';
$out .= '
'.$label;
+ if ($countrycode == 'us') $label = preg_replace('/\s*\(.*\)/', '', $label);
+ $out .= '
'.$label;
if (empty($i) && empty($languagecodeselected)) $out .= '';
$out .= '