[*] BO : improved automatic language creation
This commit is contained in:
@@ -688,25 +688,24 @@ class LanguageCore extends ObjectModel
|
|||||||
if (Language::getIdByIso($iso_code))
|
if (Language::getIdByIso($iso_code))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// Initialize the language
|
||||||
$lang = new Language();
|
$lang = new Language();
|
||||||
$lang->iso_code = $iso_code;
|
$lang->iso_code = $iso_code;
|
||||||
$lang->active = true;
|
$lang->active = true;
|
||||||
|
|
||||||
|
// If the language pack has not been provided, retrieve it from prestashop.com
|
||||||
if (!$lang_pack)
|
if (!$lang_pack)
|
||||||
$lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
|
$lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code));
|
||||||
|
|
||||||
|
// If a language pack has been found or provided, prefill the language object with the value
|
||||||
if ($lang_pack)
|
if ($lang_pack)
|
||||||
{
|
foreach (get_object_vars($lang_pack) as $key => $value)
|
||||||
if (isset($lang_pack->name)
|
$lang->$key = $value;
|
||||||
&& isset($lang_pack->version)
|
|
||||||
&& isset($lang_pack->iso_code))
|
// Use the values given in parameters to override the data retrieved automatically
|
||||||
$lang->name = $lang_pack->name;
|
if ($params_lang !== null && is_array($params_lang))
|
||||||
}
|
|
||||||
elseif ($params_lang !== null && is_array($params_lang))
|
|
||||||
foreach ($params_lang as $key => $value)
|
foreach ($params_lang as $key => $value)
|
||||||
$lang->$key = $value;
|
$lang->$key = $value;
|
||||||
else
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!$lang->add(true, false, $only_add))
|
if (!$lang->add(true, false, $only_add))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user