diff --git a/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_errors.tpl b/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_errors.tpl index 796d7b54e..2cce48db1 100644 --- a/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_errors.tpl +++ b/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_errors.tpl @@ -30,8 +30,22 @@

{l s='Language'} : {$lang} - {$translation_type}

{l s='Errors to translate'} : {$count} - {$limit_warning} - {if !$suoshin_exceeded} + {if $post_limit_exceeded} +
+ {if $limit_warning['error_type'] == 'suhosin'} + {l s='Warning, your hosting provider is using the suhosin patch for PHP, which limits the maximum number of fields to post in a form:'} + + {$limit_warning['post.max_vars']}{l s='for suhosin.post.max_vars.'}
+ {$limit_warning['request.max_vars']} {l s='for suhosin.request.max_vars.'}
+ {l s='Please ask your hosting provider to increase the suhosin post and request limit to'} + {else} + {l s='Warning, your PHP configuration limits the maximum number of fields to post in a form:'}
+ {$limit_warning['max_input_vars']} {l s='for max_input_vars.'}
+ {l s='Please ask your hosting provider to increase the this limit to'} + {/if} + {$limit_warning['needed_limit']} {l s='at least.'} {l s='or edit the translation file manually.'} +
+ {else}
{*{$auto_translate}$*} @@ -48,4 +62,4 @@
{/if} -{/block} \ No newline at end of file +{/block} diff --git a/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_form.tpl b/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_form.tpl index 125ce1e13..e712cfed3 100644 --- a/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_form.tpl +++ b/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_form.tpl @@ -32,7 +32,7 @@ {l s='Expressions to translate'} : {$count}.
{l s='Click on the titles to open fieldsets'}.


{l s='total missing expresssions:'} {$missing_translations|array_sum}

- {if $post_limit_exceeded == true} + {if $post_limit_exceeded}
{if $limit_warning['error_type'] == 'suhosin'} {l s='Warning, your hosting provider is using the suhosin patch for PHP, which limits the maximum number of fields to post in a form:'} diff --git a/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_mails.tpl b/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_mails.tpl index 8d07dfdf4..47790380e 100644 --- a/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_mails.tpl +++ b/admin-dev/themes/default/template/controllers/translations/helpers/view/translation_mails.tpl @@ -31,8 +31,23 @@ {$tinyMCE}

{l s='Language'} : {$lang} - {$translation_type}

+ {if $post_limit_exceeded} +
+ {if $limit_warning['error_type'] == 'suhosin'} + {l s='Warning, your hosting provider is using the suhosin patch for PHP, which limits the maximum number of fields to post in a form:'} + + {$limit_warning['post.max_vars']}{l s='for suhosin.post.max_vars.'}
+ {$limit_warning['request.max_vars']} {l s='for suhosin.request.max_vars.'}
+ {l s='Please ask your hosting provider to increase the suhosin post and request limit to'} + {else} + {l s='Warning, your PHP configuration limits the maximum number of fields to post in a form:'}
+ {$limit_warning['max_input_vars']} {l s='for max_input_vars.'}
+ {l s='Please ask your hosting provider to increase the this limit to'} + {/if} + {$limit_warning['needed_limit']} {l s='at least.'} {l s='or edit the translation file manually.'} +
+ {else}
{l s='Click on the titles to open fieldsets'}.

- {if !$suoshin_exceeded}
{$toggle_button} @@ -62,4 +77,4 @@
{/if} -{/block} \ No newline at end of file +{/block} diff --git a/classes/Language.php b/classes/Language.php index e5ad11ad7..4ba0b37b6 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -634,13 +634,13 @@ class LanguageCore extends ObjectModel return true; else { - if (@fsockopen('api.prestashop.com', 80)) + if (@fsockopen('www.prestashop.com', 80)) { $lang = new Language(); $lang->iso_code = $iso_code; $lang->active = true; - if ($lang_pack = Tools::jsonDecode(Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/get_language_pack.php?version='._PS_VERSION_.'&iso_lang='.$iso_code))) + if ($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 (isset($lang_pack->name) && isset($lang_pack->version) @@ -653,7 +653,7 @@ class LanguageCore extends ObjectModel if ($lang_pack) { - $flag = Tools::file_get_contents('http://api.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg'); + $flag = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/flags/jpeg/'.$iso_code.'.jpg'); if ($flag != null && !preg_match('//', $flag)) { $file = fopen(dirname(__FILE__).'/../img/l/'.$insert_id.'.jpg', 'w'); diff --git a/controllers/admin/AdminLanguagesController.php b/controllers/admin/AdminLanguagesController.php index ce565f64d..d37ee8082 100644 --- a/controllers/admin/AdminLanguagesController.php +++ b/controllers/admin/AdminLanguagesController.php @@ -498,7 +498,7 @@ class AdminLanguagesControllerCore extends AdminController $this->status = 'error'; $this->errors[] = '[TECHNICAL ERROR] ps_version not set or empty'; } - if (@fsockopen('api.prestashop.com', 80)) + if (@fsockopen('www.prestashop.com', 80)) { // Get all iso code available $lang_packs = Tools::file_get_contents('http://www.prestashop.com/download/lang_packs/get_language_pack.php?version='.(string)$_GET['ps_version'].'&iso_lang='.(string)$_GET['iso_lang']); diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 62df00475..ef81cb89d 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -29,7 +29,7 @@ define ('TEXTAREA_SIZED', 70); class AdminTranslationsControllerCore extends AdminController { - protected $link_lang_pack = 'http://api.prestashop.com/download/lang_packs/get_each_language_pack.php'; + protected $link_lang_pack = 'http://www.prestashop.com/download/lang_packs/get_each_language_pack.php'; protected $total_expression = 0; protected $all_iso_lang = array(); protected $modules_translations = array(); @@ -62,7 +62,16 @@ class AdminTranslationsControllerCore extends AdminController public function initContent() { if ($type = Tools::getValue('type')) - $this->content .= $this->{'initForm'.ucfirst($type)}(Tools::strtolower(Tools::getValue('lang'))); + { + $method_name = 'initForm'.$type; + if (method_exists($this, $method_name)) + $this->content .= $this->{$method_name}(Tools::strtolower(Tools::getValue('lang'))); + else + { + $this->errors[] = sprintf(Tools::displayError('"%s" does not exists. Maybe you typed the url manually.'), $type); + $this->content .= $this->initMain(); + } + } else $this->content .= $this->initMain(); @@ -316,7 +325,7 @@ class AdminTranslationsControllerCore extends AdminController if (Validate::isLangIsoCode($arr_import_lang[0])) { if ($content = Tools::file_get_contents( - 'http://api.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.$arr_import_lang[0].'.gzip', false, + 'http://www.prestashop.com/download/lang_packs/gzip/'.$arr_import_lang[1].'/'.$arr_import_lang[0].'.gzip', false, @stream_context_create(array('http' => array('method' => 'GET', 'timeout' => 5))))) { $file = _PS_TRANSLATIONS_DIR_.$arr_import_lang[0].'.gzip'; @@ -1120,14 +1129,17 @@ class AdminTranslationsControllerCore extends AdminController continue; preg_match_all('/Tools::displayError\(\''._PS_TRANS_PATTERN_.'\'(, (true|false))?\)/U', fread(fopen($fn, 'r'), filesize($fn)), $matches); foreach ($matches[1] as $key) + { $stringToTranslate[$key] = (key_exists(md5($key), $_ERRORS)) ? html_entity_decode($_ERRORS[md5($key)], ENT_COMPAT, 'UTF-8') : ''; + $this->total_expression++; + } } $this->tpl_view_vars = array( 'lang' => Tools::strtoupper($lang), 'translation_type' => $this->l('Error translations'), - 'count' => count($stringToTranslate), - 'limit_warning' => $this->displayLimitPostWarning($count), + 'count' => $this->total_expression, + 'limit_warning' => $this->displayLimitPostWarning($this->total_expression), 'post_limit_exceeded' => $this->post_limit_exceed, 'url_submit' => self::$currentIndex.'&submitTranslationsErrors=1&token='.$this->token, 'auto_translate' => '', @@ -1244,11 +1256,15 @@ class AdminTranslationsControllerCore extends AdminController $type = substr($email_file, strripos($email_file, '.') + 1); if (!isset($arr_return['files'][$email_name])) $arr_return['files'][$email_name] = array(); + // $email_file is from scandir ($dir), so we already know that file exists $arr_return['files'][$email_name][$type]['en'] = $this->getMailContent($dir, $email_file, 'en'); // check if the file exists in the language to translate if (file_exists($dir.$lang.'/'.$email_file)) + { $arr_return['files'][$email_name][$type][$lang] = $this->getMailContent($dir, $email_file, $lang); + $this->total_expression++; + } else $arr_return['files'][$email_name][$type][$lang] = ''; @@ -1259,6 +1275,9 @@ class AdminTranslationsControllerCore extends AdminController } } } + else + // @todo : allow to translate when english is missing + $this->warnings[] = sprintf(Tools::displayError('mail directory exists for %1$s but not for english in %s'), $lang, str_replace(_PS_ROOT_DIR_, '', $dir)); return $arr_return; } @@ -1490,6 +1509,7 @@ class AdminTranslationsControllerCore extends AdminController foreach ($modules_has_mails as $module_name => $module_path) { $module_mails[$module_name] = $this->getMailFiles($module_path.'/mails/', $lang, 'module_mail'); + // @todo : all subjects (for core and modules name) are currently saved in mails/$lang/lang.php instead of module directory $module_mails[$module_name]['subject'] = $core_mails['subject']; $module_mails[$module_name]['display'] = $this->displayMailContent($module_mails[$module_name], $subject_mail, $obj_lang, Tools::strtolower($module_name), sprintf($this->l('E-mails for %s module'), ''.$module_name.''), $module_name); } @@ -1541,6 +1561,7 @@ class AdminTranslationsControllerCore extends AdminController $this->tpl_view_vars = array( 'lang' => Tools::strtoupper($lang), 'translation_type' => $this->l('E-mail template translations'), + 'limit_warning' => $this->displayLimitPostWarning($this->total_expression), 'post_limit_exceeded' => $this->post_limit_exceed, 'url_submit' => self::$currentIndex.'&submitTranslationsMails=1&token='.$this->token, 'toggle_button' => $this->displayToggleButton(), @@ -1595,10 +1616,11 @@ class AdminTranslationsControllerCore extends AdminController if (Tools::file_exists_cache($directory.'/lang.php')) { - // we need to include this even if already included + // we need to include this even if already included (no include once) include($directory.'/lang.php'); foreach ($_LANGMAIL as $key => $subject) { + $this->total_expression++; $subject = str_replace('\n', ' ', $subject); $subject = str_replace("\\'", "\'", $subject);