Fix default language of reminders

This commit is contained in:
Laurent Destailleur 2019-02-28 13:11:14 +01:00
parent 513fc8f410
commit 429da47d68
2 changed files with 9 additions and 2 deletions

View File

@ -2756,9 +2756,13 @@ class Adherent extends CommonObject
{
$adherent->fetch_thirdparty();
// Language code to use ($languagecodeformember) is default language of thirdparty, if no thirdparty, the language found from country of member then country of thirdparty, and if still not found we use the language of company.
$languagefromcountrycode = getLanguageCodeFromCountryCode($adherent->country_code ? $adherent->country_code : $adherent->thirdparty->country_code);
$languagecodeformember = (empty($adherent->thirdparty->default_lang) ? ($languagefromcountrycode ? $languagefromcountrycode : $mysoc->default_lang) : $adherent->thirdparty->default_lang);
// Send reminder email
$outputlangs = new Translate('', $conf);
$outputlangs->setDefaultLang(empty($adherent->thirdparty->default_lang) ? $mysoc->default_lang : $adherent->thirdparty->default_lang);
$outputlangs->setDefaultLang($languagecodeformember);
$outputlangs->loadLangs(array("main", "members"));
dol_syslog("sendReminderForExpiredSubscription Language for member id ".$adherent->id." set to ".$outputlangs->defaultlang." mysoc->default_lang=".$mysoc->default_lang);

View File

@ -6829,7 +6829,8 @@ function picto_from_langcode($codelang, $moreatt = '')
}
/**
* Return default language from country code
* Return default language from country code.
* Return null if not found.
*
* @param string $countrycode Country code like 'US', 'FR', 'CA', ...
* @return string Value of locale like 'en_US', 'fr_FR', ...
@ -6838,6 +6839,8 @@ function getLanguageCodeFromCountryCode($countrycode)
{
global $mysoc;
if (empty($countrycode)) return null;
if (strtoupper($countrycode) == 'MQ') return 'fr_CA';
if (strtoupper($countrycode) == 'SE') return 'sv_SE'; // se_SE is Sami/Sweden, and we want in priority sv_SE for SE country
if (strtoupper($countrycode) == 'CH')