Translate WordPress with GTranslate - Version 2.9.13

Version Description

  • Added translation support for PDF invoices in WooCommerce PDF Invoices plugin
  • Fixed email translation issue with custom domains
  • Fixed typo in Sundanese language name
Download this release

Release Info

Developer edo888
Plugin Icon 128x128 Translate WordPress with GTranslate
Version 2.9.13
Comparing to
See all releases

Code changes from version 2.9.12 to 2.9.13

Files changed (2) hide show
  1. gtranslate.php +105 -3
  2. readme.txt +6 -1
gtranslate.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Translate your website and make it multilingual. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support Forum</a>.
6
- Version: 2.9.12
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
@@ -265,7 +265,7 @@ class GTranslate extends WP_Widget {
265
 
266
  extract($data);
267
 
268
- $gt_lang_array_json = '{"af":"Afrikaans","sq":"Albanian","am":"Amharic","ar":"Arabic","hy":"Armenian","az":"Azerbaijani","eu":"Basque","be":"Belarusian","bn":"Bengali","bs":"Bosnian","bg":"Bulgarian","ca":"Catalan","ceb":"Cebuano","ny":"Chichewa","zh-CN":"Chinese (Simplified)","zh-TW":"Chinese (Traditional)","co":"Corsican","hr":"Croatian","cs":"Czech","da":"Danish","nl":"Dutch","en":"English","eo":"Esperanto","et":"Estonian","tl":"Filipino","fi":"Finnish","fr":"French","fy":"Frisian","gl":"Galician","ka":"Georgian","de":"German","el":"Greek","gu":"Gujarati","ht":"Haitian Creole","ha":"Hausa","haw":"Hawaiian","iw":"Hebrew","hi":"Hindi","hmn":"Hmong","hu":"Hungarian","is":"Icelandic","ig":"Igbo","id":"Indonesian","ga":"Irish","it":"Italian","ja":"Japanese","jw":"Javanese","kn":"Kannada","kk":"Kazakh","km":"Khmer","ko":"Korean","ku":"Kurdish (Kurmanji)","ky":"Kyrgyz","lo":"Lao","la":"Latin","lv":"Latvian","lt":"Lithuanian","lb":"Luxembourgish","mk":"Macedonian","mg":"Malagasy","ms":"Malay","ml":"Malayalam","mt":"Maltese","mi":"Maori","mr":"Marathi","mn":"Mongolian","my":"Myanmar (Burmese)","ne":"Nepali","no":"Norwegian","ps":"Pashto","fa":"Persian","pl":"Polish","pt":"Portuguese","pa":"Punjabi","ro":"Romanian","ru":"Russian","sm":"Samoan","gd":"Scottish Gaelic","sr":"Serbian","st":"Sesotho","sn":"Shona","sd":"Sindhi","si":"Sinhala","sk":"Slovak","sl":"Slovenian","so":"Somali","es":"Spanish","su":"Sudanese","sw":"Swahili","sv":"Swedish","tg":"Tajik","ta":"Tamil","te":"Telugu","th":"Thai","tr":"Turkish","uk":"Ukrainian","ur":"Urdu","uz":"Uzbek","vi":"Vietnamese","cy":"Welsh","xh":"Xhosa","yi":"Yiddish","yo":"Yoruba","zu":"Zulu"}';
269
  $gt_lang_array = get_object_vars(json_decode($gt_lang_array_json));
270
  include dirname(__FILE__) . '/native_names_map.php'; // defines $native_names_map array
271
  //echo '<pre>' . print_r($native_names_map, true) . '</pre>';
@@ -1196,7 +1196,7 @@ EOT;
1196
  <option value="sl"><?php _e('Slovenian', 'gtranslate'); ?></option>
1197
  <option value="so"><?php _e('Somali', 'gtranslate'); ?></option>
1198
  <option value="es"><?php _e('Spanish', 'gtranslate'); ?></option>
1199
- <option value="su"><?php _e('Sudanese', 'gtranslate'); ?></option>
1200
  <option value="sw"><?php _e('Swahili', 'gtranslate'); ?></option>
1201
  <option value="sv"><?php _e('Swedish', 'gtranslate'); ?></option>
1202
  <option value="tg"><?php _e('Tajik', 'gtranslate'); ?></option>
@@ -2660,6 +2660,11 @@ if($data['pro_version'] or $data['enterprise_version']) {
2660
  $server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
2661
  $server = $servers[$server_id];
2662
  $host = $_SERVER['HTTP_X_GT_LANG'] . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
 
 
 
 
 
2663
  $protocol = ((isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS'] == 'on' or $_SERVER['HTTPS'] == 1)) or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http';
2664
 
2665
  $headers = array();
@@ -2741,6 +2746,103 @@ if($data['pro_version'] or $data['enterprise_version']) {
2741
  return $args;
2742
  }
2743
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2744
  add_filter('wp_mail', 'gt_translate_emails', 10000, 1);
2745
  }
2746
  }
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Translate your website and make it multilingual. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support Forum</a>.
6
+ Version: 2.9.13
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
265
 
266
  extract($data);
267
 
268
+ $gt_lang_array_json = '{"af":"Afrikaans","sq":"Albanian","am":"Amharic","ar":"Arabic","hy":"Armenian","az":"Azerbaijani","eu":"Basque","be":"Belarusian","bn":"Bengali","bs":"Bosnian","bg":"Bulgarian","ca":"Catalan","ceb":"Cebuano","ny":"Chichewa","zh-CN":"Chinese (Simplified)","zh-TW":"Chinese (Traditional)","co":"Corsican","hr":"Croatian","cs":"Czech","da":"Danish","nl":"Dutch","en":"English","eo":"Esperanto","et":"Estonian","tl":"Filipino","fi":"Finnish","fr":"French","fy":"Frisian","gl":"Galician","ka":"Georgian","de":"German","el":"Greek","gu":"Gujarati","ht":"Haitian Creole","ha":"Hausa","haw":"Hawaiian","iw":"Hebrew","hi":"Hindi","hmn":"Hmong","hu":"Hungarian","is":"Icelandic","ig":"Igbo","id":"Indonesian","ga":"Irish","it":"Italian","ja":"Japanese","jw":"Javanese","kn":"Kannada","kk":"Kazakh","km":"Khmer","ko":"Korean","ku":"Kurdish (Kurmanji)","ky":"Kyrgyz","lo":"Lao","la":"Latin","lv":"Latvian","lt":"Lithuanian","lb":"Luxembourgish","mk":"Macedonian","mg":"Malagasy","ms":"Malay","ml":"Malayalam","mt":"Maltese","mi":"Maori","mr":"Marathi","mn":"Mongolian","my":"Myanmar (Burmese)","ne":"Nepali","no":"Norwegian","ps":"Pashto","fa":"Persian","pl":"Polish","pt":"Portuguese","pa":"Punjabi","ro":"Romanian","ru":"Russian","sm":"Samoan","gd":"Scottish Gaelic","sr":"Serbian","st":"Sesotho","sn":"Shona","sd":"Sindhi","si":"Sinhala","sk":"Slovak","sl":"Slovenian","so":"Somali","es":"Spanish","su":"Sundanese","sw":"Swahili","sv":"Swedish","tg":"Tajik","ta":"Tamil","te":"Telugu","th":"Thai","tr":"Turkish","uk":"Ukrainian","ur":"Urdu","uz":"Uzbek","vi":"Vietnamese","cy":"Welsh","xh":"Xhosa","yi":"Yiddish","yo":"Yoruba","zu":"Zulu"}';
269
  $gt_lang_array = get_object_vars(json_decode($gt_lang_array_json));
270
  include dirname(__FILE__) . '/native_names_map.php'; // defines $native_names_map array
271
  //echo '<pre>' . print_r($native_names_map, true) . '</pre>';
1196
  <option value="sl"><?php _e('Slovenian', 'gtranslate'); ?></option>
1197
  <option value="so"><?php _e('Somali', 'gtranslate'); ?></option>
1198
  <option value="es"><?php _e('Spanish', 'gtranslate'); ?></option>
1199
+ <option value="su"><?php _e('Sundanese', 'gtranslate'); ?></option>
1200
  <option value="sw"><?php _e('Swahili', 'gtranslate'); ?></option>
1201
  <option value="sv"><?php _e('Swedish', 'gtranslate'); ?></option>
1202
  <option value="tg"><?php _e('Tajik', 'gtranslate'); ?></option>
2660
  $server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
2661
  $server = $servers[$server_id];
2662
  $host = $_SERVER['HTTP_X_GT_LANG'] . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
2663
+ if($data['custom_domains'] and !empty($data['custom_domains_data'])) {
2664
+ $custom_domains_data = json_decode(stripslashes($data['custom_domains_data']), true);
2665
+ if(isset($custom_domains_data[$_SERVER['HTTP_X_GT_LANG']]))
2666
+ $host = $custom_domains_data[$_SERVER['HTTP_X_GT_LANG']];
2667
+ }
2668
  $protocol = ((isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS'] == 'on' or $_SERVER['HTTPS'] == 1)) or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http';
2669
 
2670
  $headers = array();
2746
  return $args;
2747
  }
2748
 
2749
+ // woocommerce pdf invoice translation
2750
+ function gt_translate_invoice_pdf($html) {
2751
+ if(function_exists('curl_init') and isset($_SERVER['HTTP_X_GT_LANG'])) {
2752
+ $data = get_option('GTranslate');
2753
+ GTranslate::load_defaults($data);
2754
+
2755
+ // add notranslate for addresses
2756
+ $html = str_replace('-address"', 'notranslate -address"', $html);
2757
+
2758
+ include dirname(__FILE__) . '/url_addon/config.php';
2759
+ $server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
2760
+ $server = $servers[$server_id];
2761
+ $host = $_SERVER['HTTP_X_GT_LANG'] . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
2762
+ if($data['custom_domains'] and !empty($data['custom_domains_data'])) {
2763
+ $custom_domains_data = json_decode(stripslashes($data['custom_domains_data']), true);
2764
+ if(isset($custom_domains_data[$_SERVER['HTTP_X_GT_LANG']]))
2765
+ $host = $custom_domains_data[$_SERVER['HTTP_X_GT_LANG']];
2766
+ }
2767
+ $protocol = ((isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS'] == 'on' or $_SERVER['HTTPS'] == 1)) or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http';
2768
+
2769
+ $headers = array();
2770
+ $headers[] = 'Host: ' . $host;
2771
+ // add real visitor IP header
2772
+ if(isset($_SERVER['HTTP_CLIENT_IP']) and !empty($_SERVER['HTTP_CLIENT_IP']))
2773
+ $viewer_ip_address = $_SERVER['HTTP_CLIENT_IP'];
2774
+ if(isset($_SERVER['HTTP_CF_CONNECTING_IP']) and !empty($_SERVER['HTTP_CF_CONNECTING_IP']))
2775
+ $viewer_ip_address = $_SERVER['HTTP_CF_CONNECTING_IP'];
2776
+ if(isset($_SERVER['HTTP_X_SUCURI_CLIENTIP']) and !empty($_SERVER['HTTP_X_SUCURI_CLIENTIP']))
2777
+ $viewer_ip_address = $_SERVER['HTTP_X_SUCURI_CLIENTIP'];
2778
+ if(!isset($viewer_ip_address))
2779
+ $viewer_ip_address = $_SERVER['REMOTE_ADDR'];
2780
+
2781
+ $headers[] = 'X-GT-Viewer-IP: ' . $viewer_ip_address;
2782
+ $headers[] = 'User-Agent: GTranslate-Email-Translate';
2783
+
2784
+ // add X-Forwarded-For
2785
+ if(isset($_SERVER['HTTP_X_FORWARDED_FOR']) and !empty($_SERVER['HTTP_X_FORWARDED_FOR']))
2786
+ $headers[] = 'X-GT-Forwarded-For: ' . $_SERVER['HTTP_X_FORWARDED_FOR'];
2787
+
2788
+ $ch = curl_init();
2789
+ curl_setopt($ch, CURLOPT_URL, $protocol.'://'.$server.'.tdn.gtranslate.net'.wp_make_link_relative(plugins_url('gtranslate/url_addon/gtranslate-email.php').'?format=pdf_html&glang='.$_SERVER['HTTP_X_GT_LANG']));
2790
+ curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
2791
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
2792
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
2793
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
2794
+ if(defined('CURL_IPRESOLVE_V4')) curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
2795
+ curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/url_addon/cacert.pem');
2796
+ curl_setopt($ch, CURLOPT_POST, 1);
2797
+ curl_setopt($ch, CURLOPT_POSTFIELDS, array('body' => base64_encode(do_shortcode("<subject>PDF Invoice</subject><message>$html</message>")), 'access_key' => md5(substr(NONCE_SALT, 0, 10) . substr(NONCE_KEY, 0, 5))));
2798
+
2799
+ if($data['email_translation_debug']) {
2800
+ $fh = fopen(dirname(__FILE__) . '/url_addon/debug.txt', 'a');
2801
+ curl_setopt($ch, CURLOPT_VERBOSE, true);
2802
+ curl_setopt($ch, CURLOPT_STDERR, $fh);
2803
+ }
2804
+
2805
+ $response = curl_exec($ch);
2806
+ $response_info = curl_getinfo($ch);
2807
+ curl_close($ch);
2808
+
2809
+ if($data['email_translation_debug']) {
2810
+ file_put_contents(dirname(__FILE__) . '/url_addon/debug.txt', 'Response PDF: ' . $response . "\n", FILE_APPEND);
2811
+ file_put_contents(dirname(__FILE__) . '/url_addon/debug.txt', 'Response_info PDF: ' . print_r($response_info, true) . "\n", FILE_APPEND);
2812
+ }
2813
+
2814
+ if(isset($response_info['http_code']) and $response_info['http_code'] == 200) {
2815
+ $response = json_decode($response, true);
2816
+ if(empty($response))
2817
+ return $html;
2818
+
2819
+ $response = base64_decode($response['email-body']);
2820
+ if($response === false)
2821
+ return $html;
2822
+
2823
+ if($data['pro_version'])
2824
+ $response = str_ireplace($host, $_SERVER['HTTP_HOST'] . '/' . $_SERVER['HTTP_X_GT_LANG'], $response);
2825
+
2826
+ preg_match_all('/<subject>(.*?)<\/subject><message>(.*?)<\/message>/s', $response, $matches);
2827
+ //file_put_contents(dirname(__FILE__) . '/url_addon/debug.txt', 'Matches: ' . print_r($matches, true) . "\n", FILE_APPEND);
2828
+
2829
+ if(isset($matches[1][0], $matches[2][0])) {
2830
+ $html = $matches[2][0];
2831
+
2832
+ // fix image
2833
+ $html = str_replace('<img src="https://' . $_SERVER['HTTP_HOST'], '<img src="', $html);
2834
+
2835
+ if($data['email_translation_debug']) {
2836
+ file_put_contents(dirname(__FILE__) . '/url_addon/debug.txt', 'Translated PDF HTML: ' . $html . "\n", FILE_APPEND);
2837
+ }
2838
+ }
2839
+ }
2840
+ }
2841
+
2842
+ return $html;
2843
+ }
2844
+
2845
+ add_filter('wpo_wcpdf_get_html', 'gt_translate_invoice_pdf', 10000, 1);
2846
  add_filter('wp_mail', 'gt_translate_emails', 10000, 1);
2847
  }
2848
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Author: Translate AI Multilingual Solutions
4
  Tags: translate, translate wordpress, multilingual, translation, translate language, bilingual, localization, translation proxy, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
  Tested up to: 6.0
7
- Stable tag: 2.9.12
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://gtranslate.io/?xyz=998#pricing
@@ -251,6 +251,11 @@ If you want us to translate your website professionally or provide you a proofre
251
  8. User Dashboard
252
 
253
  == Changelog ==
 
 
 
 
 
254
  = 2.9.12 =
255
  * Fix for conflict with WP Rocket plugin when "Load JavaScript deferred" option is enabled
256
 
4
  Tags: translate, translate wordpress, multilingual, translation, translate language, bilingual, localization, translation proxy, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
  Tested up to: 6.0
7
+ Stable tag: 2.9.13
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
  Donate link: https://gtranslate.io/?xyz=998#pricing
251
  8. User Dashboard
252
 
253
  == Changelog ==
254
+ = 2.9.13 =
255
+ * Added translation support for PDF invoices in WooCommerce PDF Invoices plugin
256
+ * Fixed email translation issue with custom domains
257
+ * Fixed typo in Sundanese language name
258
+
259
  = 2.9.12 =
260
  * Fix for conflict with WP Rocket plugin when "Load JavaScript deferred" option is enabled
261