Skip to content

Commit

Permalink
https://github.com/fballiano/magento-full-catalog-translate/issues/14
Browse files Browse the repository at this point in the history
  • Loading branch information
fballiano committed Nov 24, 2016
1 parent 7694985 commit dc63d7a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 8 additions & 3 deletions shell/fballiano_full_catalog_translate.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit dc63d7a

Please sign in to comment.