[-] Installer: download the language pack even if this is a native language on installation
This commit is contained in:
1 parent
6c79baedc3
commit
11bc38b1f9
1 file changed
+5
-12
@@ -292,20 +292,15 @@ class LocalizationPackCore
|
|||||||
foreach ($xml->languages->language as $data)
|
foreach ($xml->languages->language as $data)
|
||||||
{
|
{
|
||||||
$attributes = $data->attributes();
|
$attributes = $data->attributes();
|
||||||
if (Language::getIdByIso($attributes['iso_code']))
|
|
||||||
continue;
|
|
||||||
$native_lang = Language::getLanguages();
|
|
||||||
$native_iso_code = array();
|
|
||||||
foreach ($native_lang as $lang)
|
|
||||||
$native_iso_code[] = $lang['iso_code'];
|
|
||||||
// if we are not in an installation context or if the pack is not available in the local directory
|
// if we are not in an installation context or if the pack is not available in the local directory
|
||||||
if (!$install_mode || !in_array((string)$attributes['iso_code'], $native_iso_code))
|
if (Language::getIdByIso($attributes['iso_code']) && !$install_mode)
|
||||||
{
|
continue;
|
||||||
|
|
||||||
$errno = 0;
|
$errno = 0;
|
||||||
$errstr = '';
|
$errstr = '';
|
||||||
if (!@fsockopen('api.prestashop.com', 80, $errno, $errstr, 5))
|
if (!$lang_pack_link = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$attributes['iso_code']))
|
||||||
$this->_errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
|
$this->_errors[] = Tools::displayError('Archive cannot be downloaded from prestashop.com.');
|
||||||
elseif (!($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$attributes['iso_code']))))
|
elseif (!$lang_pack = Tools::jsonDecode($lang_pack_link))
|
||||||
$this->_errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
|
$this->_errors[] = Tools::displayError('Error occurred when language was checked according to your Prestashop version.');
|
||||||
elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.$attributes['iso_code'].'.gzip'))
|
elseif ($content = Tools::file_get_contents('http://translations.prestashop.com/download/lang_packs/gzip/'.$lang_pack->version.'/'.$attributes['iso_code'].'.gzip'))
|
||||||
{
|
{
|
||||||
@@ -325,13 +320,11 @@ class LocalizationPackCore
|
|||||||
AdminTranslationsController::checkAndAddMailsFiles($attributes['iso_code'], $files_list);
|
AdminTranslationsController::checkAndAddMailsFiles($attributes['iso_code'], $files_list);
|
||||||
AdminTranslationsController::addNewTabs($attributes['iso_code'], $files_list);
|
AdminTranslationsController::addNewTabs($attributes['iso_code'], $files_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Language::checkAndAddLanguage((string)$attributes['iso_code']))
|
if (!Language::checkAndAddLanguage((string)$attributes['iso_code']))
|
||||||
{
|
{
|
||||||
$this->_errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$attributes['iso_code'];
|
$this->_errors[] = Tools::displayError('An error occurred while creating the language: ').(string)$attributes['iso_code'];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@unlink($file);
|
@unlink($file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user