Skip to content

Commit dc63d7a

Browse files
committed
https://github.com/fballiano/magento-full-catalog-translate/issues/14
1 parent 7694985 commit dc63d7a

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
0.7.2
2+
-----
3+
* mbstring extension is required (check added) if you use Google Translate API.
4+
* if you translate an attribute that has a text longer than 5000 chars with
5+
Google Translate API, the script will output a warning and skip that specific
6+
attribute for that specific product.
7+
8+
0.7.1
9+
-----
10+
* solved issue #12
11+
112
0.7.0
213
-----
314
* categories translation was added

shell/fballiano_full_catalog_translate.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function run()
5555
switch ($this->translation_system) {
5656
case "googletranslate":
5757
if (!$this->api_key) die("Please set your API key in the Magento admin configuration.\n");
58+
if (!function_exists("mb_strlen")) die("Please install mbstring PHP extension\n");
5859
break;
5960
case "custom":
6061
if (!$this->command) die("Please set the translation command in the Magento admin configuration.\n");
@@ -181,11 +182,15 @@ public function productCollectionWalkCallback($args)
181182
$translated_row["fb_translate"] = 0;
182183
foreach ($this->attributes_to_translate as $attribute) {
183184
if (strlen($row[$attribute])) {
185+
if ($this->translation_system == "googletranslate" and mb_strlen($translated_row[$attribute]) >= 5000 ) {
186+
echo "\t[$attribute] more than 5000 chars long, unsupported by Google Translate, not translated\n";
187+
continue;
188+
}
184189
$translated_row[$attribute] = $this->translateString($row[$attribute]);
190+
if ($this->debug_mode) {
191+
echo "\t[$attribute] [{$row[$attribute]}] -> [{$this->language_dest} {$translated_row[$attribute]}]\n";
192+
}
185193
}
186-
if ($this->debug_mode) {
187-
echo "\t[$attribute] [{$row[$attribute]}] -> [{$this->language_dest} {$translated_row[$attribute]}]\n";
188-
}
189194
}
190195

191196
if (!$this->dry_run) $this->datapump->ingest($translated_row);

0 commit comments

Comments
 (0)