File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 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+
1120.7.0
213-----
314* categories translation was added
Original file line number Diff line number Diff 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 );
You can’t perform that action at this time.
0 commit comments