Translate WordPress with GTranslate - Version 2.8.62

Version Description

  • Tested with new WordPress 5.7 version
  • Fix for email translation debug
  • Avoid PHP warning suppression code
  • Autoswitch to browser language issue related to Chinese language code is fixed
  • Auto redirect to browser language issue related to Hebrew language code (he, iw) fixed
Download this release

Release Info

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

Code changes from version 2.8.61 to 2.8.62

Files changed (2) hide show
  1. gtranslate.php +18 -7
  2. readme.txt +10 -4
gtranslate.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support</a>.
6
- Version: 2.8.61
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
@@ -131,7 +131,7 @@ class GTranslate extends WP_Widget {
131
  $allowed_languages = json_encode($allowed_languages);
132
 
133
  echo "<script>jQuery(document).ready(function() {";
134
- echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
135
  if($data['widget_look'] == 'dropdown_with_flags') {
136
  echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
137
  } elseif($data['widget_look'] == 'popup') {
@@ -172,7 +172,7 @@ class GTranslate extends WP_Widget {
172
  $allowed_languages = json_encode($allowed_languages);
173
 
174
  echo "<script>jQuery(document).ready(function() {";
175
- echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
176
  if($data['widget_look'] == 'dropdown_with_flags') {
177
  echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
178
  } elseif($data['widget_look'] == 'popup') {
@@ -212,7 +212,7 @@ class GTranslate extends WP_Widget {
212
  $allowed_languages = json_encode($allowed_languages);
213
 
214
  $data['widget_code'] .= "<script>jQuery(document).ready(function() {";
215
- $data['widget_code'] .= "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
216
  if($data['widget_look'] == 'dropdown_with_flags') {
217
  $data['widget_code'] .= "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
218
  } elseif($data['widget_look'] == 'popup') {
@@ -1671,7 +1671,7 @@ class GTranslateWidget extends WP_Widget {
1671
  $allowed_languages = json_encode($allowed_languages);
1672
 
1673
  echo "<script>jQuery(document).ready(function() {";
1674
- echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
1675
  if($data['widget_look'] == 'dropdown_with_flags') {
1676
  echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
1677
  } elseif($data['widget_look'] == 'popup') {
@@ -2030,7 +2030,13 @@ GTranslate::load_defaults($data);
2030
 
2031
  if($data['pro_version']) { // gtranslate redirect rules with PHP (for environments with no .htaccess support (pantheon, flywheel, etc.), usually .htaccess rules override this)
2032
 
2033
- @list($request_uri, $query_params) = explode('?', $_SERVER['REQUEST_URI']);
 
 
 
 
 
 
2034
 
2035
  if(preg_match('/^\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)\/(.*)$/', $request_uri, $matches)) {
2036
  header('Location: ' . '/' . $matches[1] . '/' . $matches[3] . (empty($query_params) ? '' : '?'.$query_params), true, 301);
@@ -2257,7 +2263,9 @@ if(($data['pro_version'] or $data['enterprise_version']) and $data['detect_brows
2257
  $accept_language = $_GET['gt_auto_switch_to'];
2258
 
2259
  if($accept_language == 'zh')
2260
- $accept_language == 'zh-CN';
 
 
2261
 
2262
  if($accept_language != $data['default_language'] and in_array($accept_language, $allowed_languages) and !isset($_COOKIE['gt_auto_switch'])) {
2263
  // set cookie for 30 days and redirect
@@ -2456,6 +2464,9 @@ if($data['pro_version'] or $data['enterprise_version']) {
2456
 
2457
  // translate woocommerce
2458
  if(strpos($message, 'woocommerce') !== false) {
 
 
 
2459
  include dirname(__FILE__) . '/url_addon/config.php';
2460
  $server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
2461
  $server = $servers[$server_id];
3
  Plugin Name: GTranslate
4
  Plugin URI: https://gtranslate.io/?xyz=998
5
  Description: Makes your website <strong>multilingual</strong> and available to the world using Google Translate. For support visit <a href="https://wordpress.org/support/plugin/gtranslate">GTranslate Support</a>.
6
+ Version: 2.8.62
7
  Author: Translate AI Multilingual Solutions
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
131
  $allowed_languages = json_encode($allowed_languages);
132
 
133
  echo "<script>jQuery(document).ready(function() {";
134
+ echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
135
  if($data['widget_look'] == 'dropdown_with_flags') {
136
  echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
137
  } elseif($data['widget_look'] == 'popup') {
172
  $allowed_languages = json_encode($allowed_languages);
173
 
174
  echo "<script>jQuery(document).ready(function() {";
175
+ echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
176
  if($data['widget_look'] == 'dropdown_with_flags') {
177
  echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
178
  } elseif($data['widget_look'] == 'popup') {
212
  $allowed_languages = json_encode($allowed_languages);
213
 
214
  $data['widget_code'] .= "<script>jQuery(document).ready(function() {";
215
+ $data['widget_code'] .= "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
216
  if($data['widget_look'] == 'dropdown_with_flags') {
217
  $data['widget_code'] .= "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
218
  } elseif($data['widget_look'] == 'popup') {
1671
  $allowed_languages = json_encode($allowed_languages);
1672
 
1673
  echo "<script>jQuery(document).ready(function() {";
1674
+ echo "var allowed_languages = $allowed_languages;var accept_language = navigator.language.toLowerCase() || navigator.userLanguage.toLowerCase();switch(accept_language) {case 'zh-cn': var preferred_language = 'zh-CN'; break;case 'zh': var preferred_language = 'zh-CN'; break;case 'zh-tw': var preferred_language = 'zh-TW'; break;case 'zh-hk': var preferred_language = 'zh-TW'; break;case 'he': var preferred_language = 'iw'; break;default: var preferred_language = accept_language.substr(0, 2); break;}if(preferred_language != '".$data['default_language']."' && GTranslateGetCurrentLang() == null && document.cookie.match('gt_auto_switch') == null && allowed_languages.indexOf(preferred_language) >= 0){doGTranslate('".$data['default_language']."|'+preferred_language);document.cookie = 'gt_auto_switch=1; expires=Thu, 05 Dec 2030 08:08:08 UTC; path=/;';";
1675
  if($data['widget_look'] == 'dropdown_with_flags') {
1676
  echo "var lang_html = jQuery('div.switcher div.option').find('img[alt=\"'+preferred_language+'\"]').parent().html();if(typeof lang_html != 'undefined')jQuery('div.switcher div.selected a').html(lang_html.replace('data-gt-lazy-', ''));";
1677
  } elseif($data['widget_look'] == 'popup') {
2030
 
2031
  if($data['pro_version']) { // gtranslate redirect rules with PHP (for environments with no .htaccess support (pantheon, flywheel, etc.), usually .htaccess rules override this)
2032
 
2033
+ //@list($request_uri, $query_params) = explode('?', $_SERVER['REQUEST_URI']);
2034
+ $url_params = explode('?', $_SERVER['REQUEST_URI']);
2035
+ $request_uri = $url_params[0];
2036
+ if(isset($url_params[1]))
2037
+ $query_params = $url_params[1];
2038
+ else
2039
+ $query_params = '';
2040
 
2041
  if(preg_match('/^\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)\/(af|sq|am|ar|hy|az|eu|be|bn|bs|bg|ca|ceb|ny|zh-CN|zh-TW|co|hr|cs|da|nl|en|eo|et|tl|fi|fr|fy|gl|ka|de|el|gu|ht|ha|haw|iw|hi|hmn|hu|is|ig|id|ga|it|ja|jw|kn|kk|km|ko|ku|ky|lo|la|lv|lt|lb|mk|mg|ms|ml|mt|mi|mr|mn|my|ne|no|ps|fa|pl|pt|pa|ro|ru|sm|gd|sr|st|sn|sd|si|sk|sl|so|es|su|sw|sv|tg|ta|te|th|tr|uk|ur|uz|vi|cy|xh|yi|yo|zu)\/(.*)$/', $request_uri, $matches)) {
2042
  header('Location: ' . '/' . $matches[1] . '/' . $matches[3] . (empty($query_params) ? '' : '?'.$query_params), true, 301);
2263
  $accept_language = $_GET['gt_auto_switch_to'];
2264
 
2265
  if($accept_language == 'zh')
2266
+ $accept_language = 'zh-CN';
2267
+ elseif($accept_language == 'he')
2268
+ $accept_language = 'iw';
2269
 
2270
  if($accept_language != $data['default_language'] and in_array($accept_language, $allowed_languages) and !isset($_COOKIE['gt_auto_switch'])) {
2271
  // set cookie for 30 days and redirect
2464
 
2465
  // translate woocommerce
2466
  if(strpos($message, 'woocommerce') !== false) {
2467
+ $data = get_option('GTranslate');
2468
+ GTranslate::load_defaults($data);
2469
+
2470
  include dirname(__FILE__) . '/url_addon/config.php';
2471
  $server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
2472
  $server = $servers[$server_id];
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: edo888
3
  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: 5.6
7
- Stable tag: 2.8.61
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
@@ -175,8 +175,7 @@ For example http://example.com/*about-us* &rarr; http://example.com/*sobre-nosot
175
  This is an important part of multilingual SEO strategy. When you have URL Translate option and translate also your website URLs also known us slugs, you are creating more keywords, which count as an improvement in your page rank for that keywords.
176
 
177
  = Does it translate emails too? =
178
- Yes, you can now translate WooCommerce emails too. Email translate feature is in beta testing stage, so if you notice any problems, please contact our live chat and let us know.
179
- Please note that it is possible to notice partially translated emails at the beginning, but when our system learns more about your email templates everything will be translated.
180
 
181
  = How the free version differs from the paid versions? =
182
  Free vesion is a nice looking language selector you can place on your website. It has a built in Javascript engine which allows to translate your website automatically to multiple languages. With our free translate plugin your website URL doesn't change and the translations are not stored. While paid versions are a translation proxy also known as Translation Delivery Network. We host the translated versions of your website on our cloud network under a language specific domain. In that case every language will have a separate domain or separate URL and be indexed in search engines, which will help you to increase international traffic and sales.
@@ -252,6 +251,13 @@ If you want us to translate your website professionally or provide you a proofre
252
  8. User Dashboard
253
 
254
  == Changelog ==
 
 
 
 
 
 
 
255
  = 2.8.61 =
256
  * Tested with new WordPress 5.6 version
257
  * Ground up rebuild of our Translation Proxy cloud network for paid customers, now page translations are 3x faster on average.
3
  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: 5.7
7
+ Stable tag: 2.8.62
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
175
  This is an important part of multilingual SEO strategy. When you have URL Translate option and translate also your website URLs also known us slugs, you are creating more keywords, which count as an improvement in your page rank for that keywords.
176
 
177
  = Does it translate emails too? =
178
+ Yes, with our paid version we can also translate WooCommerce emails.
 
179
 
180
  = How the free version differs from the paid versions? =
181
  Free vesion is a nice looking language selector you can place on your website. It has a built in Javascript engine which allows to translate your website automatically to multiple languages. With our free translate plugin your website URL doesn't change and the translations are not stored. While paid versions are a translation proxy also known as Translation Delivery Network. We host the translated versions of your website on our cloud network under a language specific domain. In that case every language will have a separate domain or separate URL and be indexed in search engines, which will help you to increase international traffic and sales.
251
  8. User Dashboard
252
 
253
  == Changelog ==
254
+ = 2.8.62 =
255
+ * Tested with new WordPress 5.7 version
256
+ * Fix for email translation debug
257
+ * Avoid PHP warning suppression code
258
+ * Autoswitch to browser language issue related to Chinese language code is fixed
259
+ * Auto redirect to browser language issue related to Hebrew language code (he, iw) fixed
260
+
261
  = 2.8.61 =
262
  * Tested with new WordPress 5.6 version
263
  * Ground up rebuild of our Translation Proxy cloud network for paid customers, now page translations are 3x faster on average.