mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-11 12:01:23 +01:00
FIX default language defined for IN country
This commit is contained in:
@@ -73,6 +73,18 @@ class FormAdmin
|
|||||||
|
|
||||||
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
|
$langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
|
||||||
|
|
||||||
|
// If the language to select is not inside the list of available language and empty value is not available, we must find
|
||||||
|
// an alternative as the language code to pre-select (to avoid to have first element in list pre-selected).
|
||||||
|
if ($selected && !in_array($selected, $langs_available) && empty($showempty)) {
|
||||||
|
$tmparray = explode('_', $selected);
|
||||||
|
if (!empty($tmparray[1])) {
|
||||||
|
$selected = getLanguageCodeFromCountryCode($tmparray[1]);
|
||||||
|
}
|
||||||
|
if (empty($selected)) {
|
||||||
|
$selected = $langs->defaultlang;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
|
|
||||||
$out .= '<select '.($multiselect ? 'multiple="multiple" ' : '').'class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.($multiselect ? '[]' : '').'"'.($disabled ? ' disabled' : '').'>';
|
$out .= '<select '.($multiselect ? 'multiple="multiple" ' : '').'class="flat'.($morecss ? ' '.$morecss : '').'" id="'.$htmlname.'" name="'.$htmlname.($multiselect ? '[]' : '').'"'.($disabled ? ' disabled' : '').'>';
|
||||||
|
|||||||
@@ -8192,8 +8192,8 @@ function picto_from_langcode($codelang, $moreatt = '')
|
|||||||
* Return default language from country code.
|
* Return default language from country code.
|
||||||
* Return null if not found.
|
* Return null if not found.
|
||||||
*
|
*
|
||||||
* @param string $countrycode Country code like 'US', 'FR', 'CA', 'ES', 'MX', ...
|
* @param string $countrycode Country code like 'US', 'FR', 'CA', 'ES', 'IN', 'MX', ...
|
||||||
* @return string Value of locale like 'en_US', 'fr_FR', ...
|
* @return string Value of locale like 'en_US', 'fr_FR', ... or null if not found
|
||||||
*/
|
*/
|
||||||
function getLanguageCodeFromCountryCode($countrycode)
|
function getLanguageCodeFromCountryCode($countrycode)
|
||||||
{
|
{
|
||||||
@@ -8243,12 +8243,12 @@ function getLanguageCodeFromCountryCode($countrycode)
|
|||||||
'ar-SY',
|
'ar-SY',
|
||||||
'ar-TN',
|
'ar-TN',
|
||||||
'ar-YE',
|
'ar-YE',
|
||||||
'as-IN',
|
//'as-IN', // Moved after en-IN
|
||||||
'ba-RU',
|
'ba-RU',
|
||||||
'be-BY',
|
'be-BY',
|
||||||
'bg-BG',
|
'bg-BG',
|
||||||
'bn-BD',
|
'bn-BD',
|
||||||
'bn-IN',
|
//'bn-IN', // Moved after en-IN
|
||||||
'bo-CN',
|
'bo-CN',
|
||||||
'br-FR',
|
'br-FR',
|
||||||
'ca-ES',
|
'ca-ES',
|
||||||
@@ -8269,6 +8269,8 @@ function getLanguageCodeFromCountryCode($countrycode)
|
|||||||
'en-GB',
|
'en-GB',
|
||||||
'en-IE',
|
'en-IE',
|
||||||
'en-IN',
|
'en-IN',
|
||||||
|
'as-IN', // as-IN must be after en-IN (en in priority if country is IN)
|
||||||
|
'bn-IN', // bn-IN must be after en-IN (en in priority if country is IN)
|
||||||
'en-JM',
|
'en-JM',
|
||||||
'en-MY',
|
'en-MY',
|
||||||
'en-NZ',
|
'en-NZ',
|
||||||
@@ -8406,7 +8408,7 @@ function getLanguageCodeFromCountryCode($countrycode)
|
|||||||
$locale_language = locale_get_primary_language($locale);
|
$locale_language = locale_get_primary_language($locale);
|
||||||
$locale_region = locale_get_region($locale);
|
$locale_region = locale_get_region($locale);
|
||||||
if (strtoupper($countrycode) == $locale_region) {
|
if (strtoupper($countrycode) == $locale_region) {
|
||||||
//var_dump($locale.'-'.$locale_language.'-'.$locale_region);
|
//var_dump($locale.' - '.$locale_language.' - '.$locale_region);
|
||||||
return strtolower($locale_language).'_'.strtoupper($locale_region);
|
return strtolower($locale_language).'_'.strtoupper($locale_region);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user