From 663ec76bb99f898eeea6eb85edf2e0b004b763e3 Mon Sep 17 00:00:00 2001 From: "cam.lafit" Date: Mon, 10 Jun 2013 10:43:01 +0200 Subject: [PATCH 1/3] Better regexp to get country browser from HTTP_ACCEPT_LANGUAGE With HTTP_ACCEPT_LANGUAGE we have two choices : * Country == language (displayed with two letter as fr,de,en,...) * Country with multi language (displayes as fr-CH, de-CH, it-CH) Previous regexp find only first case. --- controllers/front/AddressController.php | 4 +++- controllers/front/AuthController.php | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index 699a37287..eb17888ce 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -303,7 +303,9 @@ class AddressControllerCore extends FrontController $selected_country = (int)$this->_address->id_country; else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { - $array = preg_split('/,|-/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + // get all countries as language (xy) or language-country (wz-XY) + $array = array(); + preg_match("#(?<=-)\w\w|\w\w(?!-)#",$_SERVER['HTTP_ACCEPT_LANGUAGE'],$array); if (!Validate::isLanguageIsoCode($array[0]) || !($selected_country = Country::getByIso($array[0]))) $selected_country = (int)Configuration::get('PS_COUNTRY_DEFAULT'); } diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 745cca405..f348b2c50 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -107,7 +107,9 @@ class AuthControllerCore extends FrontController if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { - $array = preg_split('/,|-/', $_SERVER['HTTP_ACCEPT_LANGUAGE']); + // get all countries as language (xy) or language-country (wz-XY) + $array = array(); + preg_match("#(?<=-)\w\w|\w\w(?!-)#",$_SERVER['HTTP_ACCEPT_LANGUAGE'],$array); if (!Validate::isLanguageIsoCode($array[0]) || !($sl_country = Country::getByIso($array[0]))) $sl_country = (int)Configuration::get('PS_COUNTRY_DEFAULT'); } From 85e15c00f1b06873d6fbaf3d6c0aacfef38457b0 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Tue, 6 Aug 2013 14:30:32 +0200 Subject: [PATCH 2/3] // Added missing french translation in the installer --- install-dev/langs/fr/install.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/install-dev/langs/fr/install.php b/install-dev/langs/fr/install.php index 2d78ecee2..5819cbe8a 100644 --- a/install-dev/langs/fr/install.php +++ b/install-dev/langs/fr/install.php @@ -240,5 +240,13 @@ return array( 'Sign-up to the newsletter' => 'S\'inscrire à la newsletter de PrestaShop', 'PrestaShop can provide you with guidance on a regular basis by sending you tips on how to optimize the management of your store which will help you grow your business. If you do not wish to receive these tips, please uncheck this box.' => 'PrestaShop peut vous guider de façon régulière en vous faisant parvenir des conseils afin d\'optimiser la gestion de votre boutique et développer votre activité. Si vous ne souhaitez pas recevoir ces conseils, nous vous invitons à décocher cette case.', 'Your PHP sessions path is not writable - check with your hosting provider:' => 'Le dossier de stockage n\'est pas accessible en écriture - consultez votre hébergeur', + 'Database is created' => 'Base de données créée', + 'Cannot create the database automatically' => 'Impossible de créer la base de données automatiquement', + 'Install modules Addons' => 'Installation des modules Addons', + 'Attempt to create the database automatically' => 'Essayer de créer la base de données automatiquement', + 'Country:' => 'Pays :', + 'Must be letters and numbers with at least 8 characters' => 'Lettres et chiffres avec au moins 8 caractères', + 'To install PrestaShop, you need to have JavaScript enabled in your browser.' => 'Pour installer PrestaShop, vous devez avoir JavaScript activé dans votre navigateur', + 'For security purposes, you must delete the "install" folder.' => 'Pour des raisons de sécurité, vous devez supprimer le dossier "install" manuellement.', ), -); +); \ No newline at end of file From 3839dbee9a97a318a472b9edca2a7efeee5c4d85 Mon Sep 17 00:00:00 2001 From: Damien Metzger Date: Tue, 6 Aug 2013 15:06:46 +0200 Subject: [PATCH 3/3] / Add check in object model --- classes/ObjectModel.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 49c7440fe..3207009e2 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -547,9 +547,10 @@ abstract class ObjectModelCore if (!$res) return false; - foreach ($res as $field => &$value) - if (isset($definition['fields'][$field])) - $value = ObjectModel::formatValue($value, $definition['fields'][$field]['type']); + foreach ($res as $lang => &$row) + foreach ($row as $field => &$value) + if (isset($definition['fields'][$field])) + $value = ObjectModel::formatValue($value, $definition['fields'][$field]['type']); foreach ($res as $row) {