Translate WordPress with GTranslate - Version 2.8.25

Version Description

  • New widget look added - Popup
  • Native template RTL support added
Download this release

Release Info

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

Code changes from version 2.8.24 to 2.8.25

Files changed (2) hide show
  1. gtranslate.php +128 -6
  2. readme.txt +6 -2
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.24
7
  Author: Edvard Ananyan
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
@@ -93,6 +93,11 @@ class GTranslate extends WP_Widget {
93
 
94
  public static function load_textdomain() {
95
  load_plugin_textdomain('gtranslate');
 
 
 
 
 
96
  }
97
 
98
  public function widget($args, $instance) {
@@ -244,7 +249,7 @@ function RefreshDoWidgetCode() {
244
  var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
245
 
246
  // make sure default language is on
247
- if(widget_look == 'flags_dropdown' || widget_look == 'dropdown_with_flags' || widget_look == 'flags' || widget_look == 'flags_name' || widget_code == 'flags_code')
248
  jQuery('#fincl_langs'+default_language).prop('checked', true);
249
  if(widget_look == 'dropdown' || widget_look == 'globe' || widget_look == 'lang_names' || widget_look == 'lang_codes')
250
  jQuery('#incl_langs'+default_language).prop('checked', true);
@@ -270,7 +275,7 @@ function RefreshDoWidgetCode() {
270
  jQuery('#alternative_flags_option').hide();
271
  }
272
 
273
- if(widget_look == 'flags' || widget_look == 'flags_dropdown' || widget_look == 'dropdown_with_flags' || widget_look == 'flags_name' || widget_look == 'flags_code') {
274
  jQuery('#flag_languages_option').show();
275
  jQuery('#alternative_flags_option').show();
276
  } else {
@@ -492,6 +497,120 @@ function hideGSatelites($) {
492
  widget_preview += '<\/script>'+new_line;
493
  }
494
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
495
  if(widget_look == 'dropdown_with_flags') {
496
  // Adding slider html
497
  widget_preview += '<div class="switcher notranslate">'+new_line;
@@ -698,7 +817,7 @@ if('$widget_look' == 'globe') {
698
  jQuery('#alternative_flags_option').hide();
699
  }
700
 
701
- if('$widget_look' == 'flags' || '$widget_look' == 'flags_dropdown' || '$widget_look' == 'dropdown_with_flags' || '$widget_look' == 'flags_name' || '$widget_look' == 'flags_code') {
702
  jQuery('#flag_languages_option').show();
703
  jQuery('#alternative_flags_option').show();
704
  } else {
@@ -790,7 +909,8 @@ EOT;
790
  <option value="flags_code"><?php _e('Flags with language code', 'gtranslate'); ?></option>
791
  <option value="lang_names"><?php _e('Language names', 'gtranslate'); ?></option>
792
  <option value="lang_codes"><?php _e('Language codes', 'gtranslate'); ?></option>
793
- <option value="globe">(new) <?php _e('Globe', 'gtranslate'); ?></option>
 
794
  </select>
795
  </td>
796
  </tr>
@@ -1042,6 +1162,8 @@ EOT;
1042
 
1043
  <p class="submit"><input type="submit" class="button-primary" name="save" value="<?php _e('Save Changes'); ?>" /></p>
1044
 
 
 
1045
  </div>
1046
 
1047
  <script type="text/javascript">
@@ -1092,7 +1214,7 @@ EOT;
1092
  <div class="postbox">
1093
  <h3 id="settings"><?php _e('Do you like GTranslate?', 'gtranslate'); ?></h3>
1094
  <div class="inside">
1095
- <p><?php _e('Please write a review on', 'gtranslate'); ?> <a href="https://wordpress.org/support/plugin/gtranslate/reviews/?filter=5">WordPress.org</a>.</p>
1096
 
1097
  <div id="fb-root"></div>
1098
  <script>(function(d, s, 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.25
7
  Author: Edvard Ananyan
8
  Author URI: https://gtranslate.io
9
  Text Domain: gtranslate
93
 
94
  public static function load_textdomain() {
95
  load_plugin_textdomain('gtranslate');
96
+
97
+ // set correct language direction
98
+ global $text_direction;
99
+ if(isset($_SERVER['HTTP_X_GT_LANG']) and in_array($_SERVER['HTTP_X_GT_LANG'], array('ar', 'iw', 'fa')))
100
+ $text_direction = 'rtl';
101
  }
102
 
103
  public function widget($args, $instance) {
249
  var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
250
 
251
  // make sure default language is on
252
+ if(widget_look == 'flags_dropdown' || widget_look == 'dropdown_with_flags' || widget_look == 'flags' || widget_look == 'flags_name' || widget_code == 'flags_code' || widget_look == 'popup')
253
  jQuery('#fincl_langs'+default_language).prop('checked', true);
254
  if(widget_look == 'dropdown' || widget_look == 'globe' || widget_look == 'lang_names' || widget_look == 'lang_codes')
255
  jQuery('#incl_langs'+default_language).prop('checked', true);
275
  jQuery('#alternative_flags_option').hide();
276
  }
277
 
278
+ if(widget_look == 'flags' || widget_look == 'flags_dropdown' || widget_look == 'dropdown_with_flags' || widget_look == 'flags_name' || widget_look == 'flags_code' || widget_look == 'popup') {
279
  jQuery('#flag_languages_option').show();
280
  jQuery('#alternative_flags_option').show();
281
  } else {
497
  widget_preview += '<\/script>'+new_line;
498
  }
499
 
500
+ if(widget_look == 'popup') {
501
+ widget_preview += '<a href="#" class="switcher-popup glink nturl notranslate" onclick="openGTPopup()">';
502
+
503
+ if(default_language == 'en' && jQuery('#alt_us:checked').length)
504
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/en-us.png" height="'+flag_size+'" width="'+flag_size+'" alt="en" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
505
+ else if(default_language == 'en' && jQuery('#alt_ca:checked').length)
506
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/en-ca.png" height="'+flag_size+'" width="'+flag_size+'" alt="en" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
507
+ else if(default_language == 'pt' && jQuery('#alt_br:checked').length)
508
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/pt-br.png" height="'+flag_size+'" width="'+flag_size+'" alt="pt" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
509
+ else if(default_language == 'es' && jQuery('#alt_mx:checked').length)
510
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/es-mx.png" height="'+flag_size+'" width="'+flag_size+'" alt="es" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
511
+ else if(default_language == 'es' && jQuery('#alt_ar:checked').length)
512
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/es-ar.png" height="'+flag_size+'" width="'+flag_size+'" alt="es" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
513
+ else if(default_language == 'es' && jQuery('#alt_co:checked').length)
514
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/es-co.png" height="'+flag_size+'" width="'+flag_size+'" alt="es" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
515
+ else if(default_language == 'fr' && jQuery('#alt_qc:checked').length)
516
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/fr-qc.png" height="'+flag_size+'" width="'+flag_size+'" alt="fr" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
517
+ else
518
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/'+default_language+'.png" height="'+flag_size+'" width="'+flag_size+'" alt="'+default_language+'" /> <span>'+gt_lang_array[default_language]+'</span><span style="color:#666;font-size:8px;font-weight:bold;">&#9660;</span></a>'+new_line;
519
+
520
+ // lightbox and content
521
+ widget_preview += '<div id="gt_fade" class="gt_black_overlay"></div>'+new_line;
522
+ widget_preview += '<div id="gt_lightbox" class="gt_white_content notranslate">'+new_line;
523
+ widget_preview += '<div style="position:relative;height:14px;"><span onclick="closeGTPopup()" style="position:absolute;right:2px;top:2px;font-weight:bold;font-size:12px;cursor:pointer;color:#444;font-family:cursive;">X</span></div>'+new_line;
524
+ widget_preview += '<div class="gt_languages">'+new_line;
525
+
526
+ var count_languages = 0;
527
+
528
+ jQuery.each(language_codes, function(i, val) {
529
+ lang = language_codes[i];
530
+ if(jQuery('#fincl_langs'+lang+':checked').length) {
531
+ lang_name = gt_lang_array[lang];
532
+
533
+ var href = '#';
534
+ if(pro_version)
535
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(0, 3).join('/'), '$site_url'.split('/').slice(0, 3).join('/')+'/'+lang);
536
+ else if(enterprise_version)
537
+ href = (lang == default_language) ? '$site_url' : '$site_url'.replace('$site_url'.split('/').slice(2, 3)[0].replace('www.', ''), lang + '.' + '$site_url'.split('/').slice(2, 3)[0].replace('www.', '')).replace('://www.', '://');
538
+
539
+ widget_preview += '<a href="'+href+'" onclick="changeGTLanguage(\''+default_language+'|'+lang+'\', this);return false;" title="'+lang_name+'" class="glink nturl'+(default_language == lang ? ' selected' : '')+'">';
540
+
541
+ if(lang == 'en' && jQuery('#alt_us:checked').length)
542
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/en-us.png" height="'+flag_size+'" width="'+flag_size+'" alt="en" /> <span>'+lang_name+'</span></a>';
543
+ else if(lang == 'en' && jQuery('#alt_ca:checked').length)
544
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/en-ca.png" height="'+flag_size+'" width="'+flag_size+'" alt="en" /> <span>'+lang_name+'</span></a>';
545
+ else if(lang == 'pt' && jQuery('#alt_br:checked').length)
546
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/pt-br.png" height="'+flag_size+'" width="'+flag_size+'" alt="pt" /> <span>'+lang_name+'</span></a>';
547
+ else if(lang == 'es' && jQuery('#alt_mx:checked').length)
548
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/es-mx.png" height="'+flag_size+'" width="'+flag_size+'" alt="es" /> <span>'+lang_name+'</span></a>';
549
+ else if(lang == 'es' && jQuery('#alt_ar:checked').length)
550
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/es-ar.png" height="'+flag_size+'" width="'+flag_size+'" alt="es" /> <span>'+lang_name+'</span></a>';
551
+ else if(lang == 'es' && jQuery('#alt_co:checked').length)
552
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/es-co.png" height="'+flag_size+'" width="'+flag_size+'" alt="es" /> <span>'+lang_name+'</span></a>';
553
+ else if(lang == 'fr' && jQuery('#alt_qc:checked').length)
554
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/fr-qc.png" height="'+flag_size+'" width="'+flag_size+'" alt="fr" /> <span>'+lang_name+'</span></a>';
555
+ else
556
+ widget_preview += '<img src="{$wp_plugin_url}/flags/'+flag_size+'/'+lang+'.png" height="'+flag_size+'" width="'+flag_size+'" alt="'+lang+'" /> <span>'+lang_name+'</span></a>';
557
+
558
+ count_languages++;
559
+ }
560
+ });
561
+
562
+ widget_preview += '</div>'+new_line;
563
+ widget_preview += '</div>'+new_line;
564
+
565
+ console.log('Count: ' + count_languages);
566
+
567
+ flag_size = parseInt(flag_size);
568
+ console.log('Flag size: ' + flag_size);
569
+
570
+ var popup_height = 25 + count_languages * ((flag_size > 16 ? flag_size : 20) + 10 + 1);
571
+
572
+ console.log('height: ' + popup_height);
573
+
574
+ var popup_columns = Math.ceil(popup_height / 375);
575
+
576
+ console.log('Cols: ' + popup_columns);
577
+
578
+ if(popup_height > 375)
579
+ popup_height = 375;
580
+
581
+ var popup_width = popup_columns * (326 + 15);
582
+
583
+ console.log('Width: ' + popup_width);
584
+
585
+ if(popup_width > 980)
586
+ popup_width = 980;
587
+
588
+ if(popup_columns > 5)
589
+ popup_columns = 5;
590
+
591
+ // style
592
+ widget_preview += '<style type="text/css">'+new_line;
593
+ widget_preview += '.gt_black_overlay {display:none;position:fixed;top:0%;left:0%;width:100%;height:100%;background-color:black;z-index:2017;-moz-opacity:0.8;opacity:.80;filter:alpha(opacity=80);}'+new_line;
594
+ widget_preview += '.gt_white_content {display:none;position:fixed;top:50%;left:50%;width:'+popup_width+'px;height:'+popup_height+'px;margin:-'+(popup_height/2)+'px 0 0 -'+(popup_width/2)+'px;padding:6px 16px;border-radius:5px;background-color:white;color:black;z-index:19881205;overflow:auto;text-align:left;}'+new_line;
595
+ widget_preview += '.gt_white_content a {display:block;padding:5px 0;border-bottom:1px solid #e7e7e7;white-space:nowrap;}'+new_line;
596
+ widget_preview += '.gt_white_content a:last-of-type {border-bottom:none;}'+new_line;
597
+ widget_preview += '.gt_white_content a.selected {background-color:#ffc;}'+new_line;
598
+ widget_preview += '.gt_white_content .gt_languages {column-count:'+popup_columns+';column-gap:10px;}'+new_line;
599
+ widget_preview += '.gt_white_content::-webkit-scrollbar-track{-webkit-box-shadow:inset 0 0 3px rgba(0,0,0,0.3);border-radius:5px;background-color:#F5F5F5;}'+new_line;
600
+ widget_preview += '.gt_white_content::-webkit-scrollbar {width:5px;}'+new_line;
601
+ widget_preview += '.gt_white_content::-webkit-scrollbar-thumb {border-radius:5px;-webkit-box-shadow: inset 0 0 3px rgba(0,0,0,.3);background-color:#888;}'+new_line;
602
+ widget_preview += '</style>'+new_line+new_line;
603
+
604
+ // javascript
605
+ widget_preview += '<script type="text/javascript">'+new_line;
606
+ widget_preview += "function openGTPopup() {document.getElementById('gt_lightbox').style.display='block';document.getElementById('gt_fade').style.display='block';}"+new_line;
607
+ widget_preview += "function closeGTPopup() {document.getElementById('gt_lightbox').style.display='none';document.getElementById('gt_fade').style.display='none';}"+new_line;
608
+ widget_preview += "function changeGTLanguage(pair, a) {doGTranslate(pair);jQuery('a.switcher-popup').html(jQuery(a).html()+'<span style=\"color:#666;font-size:8px;font-weight:bold;\">&#9660;</span>');closeGTPopup();}"+new_line;
609
+ widget_preview += "jQuery('#gt_fade').mousedown(function(e) {if(jQuery('#gt_lightbox').is(':visible')) {closeGTPopup()}});"+new_line;
610
+ widget_preview += '<\/script>'+new_line;
611
+
612
+ }
613
+
614
  if(widget_look == 'dropdown_with_flags') {
615
  // Adding slider html
616
  widget_preview += '<div class="switcher notranslate">'+new_line;
817
  jQuery('#alternative_flags_option').hide();
818
  }
819
 
820
+ if('$widget_look' == 'flags' || '$widget_look' == 'flags_dropdown' || '$widget_look' == 'dropdown_with_flags' || '$widget_look' == 'flags_name' || '$widget_look' == 'flags_code' || '$widget_look' == 'popup') {
821
  jQuery('#flag_languages_option').show();
822
  jQuery('#alternative_flags_option').show();
823
  } else {
909
  <option value="flags_code"><?php _e('Flags with language code', 'gtranslate'); ?></option>
910
  <option value="lang_names"><?php _e('Language names', 'gtranslate'); ?></option>
911
  <option value="lang_codes"><?php _e('Language codes', 'gtranslate'); ?></option>
912
+ <option value="globe"><?php _e('Globe', 'gtranslate'); ?></option>
913
+ <option value="popup">(beta) <?php _e('Popup', 'gtranslate'); ?></option>
914
  </select>
915
  </td>
916
  </tr>
1162
 
1163
  <p class="submit"><input type="submit" class="button-primary" name="save" value="<?php _e('Save Changes'); ?>" /></p>
1164
 
1165
+ <p style="margin-top:-10px;"><a target="_blank" href="https://wordpress.org/support/plugin/gtranslate/reviews/?filter=5"><?php _e('Love GTranslate? Give us 5 stars on WordPress.org :)', 'gtranslate'); ?></a></p>
1166
+
1167
  </div>
1168
 
1169
  <script type="text/javascript">
1214
  <div class="postbox">
1215
  <h3 id="settings"><?php _e('Do you like GTranslate?', 'gtranslate'); ?></h3>
1216
  <div class="inside">
1217
+ <p><?php _e('Give us 5 stars on', 'gtranslate'); ?> <a href="https://wordpress.org/support/plugin/gtranslate/reviews/?filter=5">WordPress.org</a> :)</p>
1218
 
1219
  <div id="fb-root"></div>
1220
  <script>(function(d, s, id) {
readme.txt CHANGED
@@ -4,7 +4,7 @@ Author: Edvard Ananyan
4
  Tags: translate wordpress, multilingual, translate, translation, language, bilingual, localization, translation proxy, i18n, l10n, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
  Tested up to: 4.8
7
- Stable tag: 2.8.24
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
@@ -35,7 +35,7 @@ Please check our [FAQ](https://gtranslate.io/?xyz=998#faq) to get quick answers.
35
  * Themes and plugins translation
36
  * Right to left language support
37
  * Google language translator widget
38
- * Available styles Dropdown, Flags, Flags with dropdown, Nice dropdown with flags, Flags with language names, Flags with language codes, Language names, Language codes, Globe
39
  * Floating language selector
40
  * Language bar with flags in menu
41
  * WooCommerce shop translation
@@ -218,6 +218,10 @@ You need to go to the language you want to edit, for instance, French: http://do
218
 
219
  == Changelog ==
220
 
 
 
 
 
221
  = 2.8.24 =
222
  * No-scroll option added for floating language selector
223
  * Now you can add more than one GTranslate widget to your sidebar
4
  Tags: translate wordpress, multilingual, translate, translation, language, bilingual, localization, translation proxy, i18n, l10n, localisation, multilanguage, google translate
5
  Requires at least: 2.8.1
6
  Tested up to: 4.8
7
+ Stable tag: 2.8.25
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
35
  * Themes and plugins translation
36
  * Right to left language support
37
  * Google language translator widget
38
+ * Available styles Dropdown, Flags, Flags with dropdown, Nice dropdown with flags, Flags with language names, Flags with language codes, Language names, Language codes, Globe, Popup
39
  * Floating language selector
40
  * Language bar with flags in menu
41
  * WooCommerce shop translation
218
 
219
  == Changelog ==
220
 
221
+ = 2.8.25 =
222
+ * New widget look added - Popup
223
+ * Native template RTL support added
224
+
225
  = 2.8.24 =
226
  * No-scroll option added for floating language selector
227
  * Now you can add more than one GTranslate widget to your sidebar