From dc63d7a63ef0165d7f0670ae063c6cb19073ce9e Mon Sep 17 00:00:00 2001 From: Fabrizio Balliano Date: Thu, 24 Nov 2016 22:13:03 +0000 Subject: [PATCH] https://github.com/fballiano/magento-full-catalog-translate/issues/14 --- CHANGELOG.md | 11 +++++++++++ shell/fballiano_full_catalog_translate.php | 11 ++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43bf5f7..afeaa9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +0.7.2 +----- +* mbstring extension is required (check added) if you use Google Translate API. +* if you translate an attribute that has a text longer than 5000 chars with + Google Translate API, the script will output a warning and skip that specific + attribute for that specific product. + +0.7.1 +----- +* solved issue #12 + 0.7.0 ----- * categories translation was added diff --git a/shell/fballiano_full_catalog_translate.php b/shell/fballiano_full_catalog_translate.php index fd9f065..b4b7c45 100755 --- a/shell/fballiano_full_catalog_translate.php +++ b/shell/fballiano_full_catalog_translate.php @@ -55,6 +55,7 @@ public function run() switch ($this->translation_system) { case "googletranslate": if (!$this->api_key) die("Please set your API key in the Magento admin configuration.\n"); + if (!function_exists("mb_strlen")) die("Please install mbstring PHP extension\n"); break; case "custom": if (!$this->command) die("Please set the translation command in the Magento admin configuration.\n"); @@ -181,11 +182,15 @@ public function productCollectionWalkCallback($args) $translated_row["fb_translate"] = 0; foreach ($this->attributes_to_translate as $attribute) { if (strlen($row[$attribute])) { + if ($this->translation_system == "googletranslate" and mb_strlen($translated_row[$attribute]) >= 5000 ) { + echo "\t[$attribute] more than 5000 chars long, unsupported by Google Translate, not translated\n"; + continue; + } $translated_row[$attribute] = $this->translateString($row[$attribute]); + if ($this->debug_mode) { + echo "\t[$attribute] [{$row[$attribute]}] -> [{$this->language_dest} {$translated_row[$attribute]}]\n"; + } } - if ($this->debug_mode) { - echo "\t[$attribute] [{$row[$attribute]}] -> [{$this->language_dest} {$translated_row[$attribute]}]\n"; - } } if (!$this->dry_run) $this->datapump->ingest($translated_row);