Translate WordPress with GTranslate - Version 1.0.3

Version Description

  • Stable version released
Download this release

Release Info

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

Code changes from version 1.0.2 to 1.0.3

Files changed (2) hide show
  1. gtranslate.php +44 -34
  2. readme.txt +5 -2
gtranslate.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: GTranslate
4
  Plugin URI: http://edo.webmaster.am/gtranslate
5
  Description: Get translations with a single click between 58 languages (more than 98% of internet users) on your website!
6
- Version: 1.0.0
7
  Author: Edvard Ananyan
8
  Author URI: http://edo.webmaster.am
9
 
@@ -100,7 +100,8 @@ $script = <<<EOT
100
 
101
  function RefreshDoWidgetCode() {
102
  var new_line = "\\n";
103
- var widget_code = '<!-- GTranslate: http://edo.webmaster.am/gtranslate -->'+new_line;
 
104
  var translation_method = jQuery('#translation_method').val();
105
  var default_language = jQuery('#default_language').val();
106
  var flag_size = jQuery('#flag_size').val();
@@ -121,15 +122,15 @@ function RefreshDoWidgetCode() {
121
  }
122
  });
123
 
124
- widget_code += '<div id="google_translate_element"></div>'+new_line;
125
- widget_code += '<script type="text/javascript">'+new_line;
126
- widget_code += 'function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: \'';
127
- widget_code += default_language;
128
- widget_code += '\', includedLanguages: \'';
129
- widget_code += included_languages;
130
- widget_code += "'}, 'google_translate_element');}"+new_line;
131
- widget_code += '<\/script>';
132
- widget_code += '<script type="text/javascript" src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"><\/script>'+new_line;
133
  } else if(translation_method == 'on_fly' || translation_method == 'redirect') {
134
  // Adding flags
135
  if(jQuery('#show_flags:checked').length) {
@@ -139,37 +140,37 @@ function RefreshDoWidgetCode() {
139
  lang_name = val;
140
  flag_x = languages_map[lang.replace('-', '')+'_x'];
141
  flag_y = languages_map[lang.replace('-', '')+'_y'];
142
- widget_code += '<a href="javascript:doGTranslate(\''+default_language+'|'+lang+'\')" title="'+lang_name+'" class="gflag" style="background-position:-'+flag_x+'px -'+flag_y+'px;"><img src="{$site_url}/wp-content/plugins/gtranslate/blank.png" height="'+flag_size+'" width="'+flag_size+'" alt="'+lang_name+'" /></a>';
143
  }
144
  });
145
 
146
  // Adding stylesheet
147
- widget_code += new_line+new_line;
148
- widget_code += '<style type="text/css">'+new_line;
149
- widget_code += '<!--'+new_line;
150
- widget_code += "a.gflag {font-size:"+flag_size+"px;padding:1px 0;background-repeat:no-repeat;background-image:url('{$site_url}/wp-content/plugins/gtranslate/"+flag_size+".png');}"+new_line;
151
- widget_code += "a.gflag img {border:0;}"+new_line;
152
- widget_code += "a.gflag:hover {background-image:url('{$site_url}/wp-content/plugins/gtranslate/"+flag_size+"a.png');}"+new_line;
153
- widget_code += '-->'+new_line;
154
- widget_code += '</style>'+new_line+new_line;
155
  }
156
 
157
  // Adding dropdown
158
  if(jQuery('#show_dropdown:checked').length) {
159
  if(jQuery('#show_flags:checked').length && jQuery('#add_new_line:checked').length)
160
- widget_code += '<br />';
161
  else
162
- widget_code += ' ';
163
- widget_code += '<select onchange="doGTranslate(this);">';
164
- widget_code += '<option value="">Select Language</option>';
165
  jQuery.each(languages, function(i, val) {
166
  lang = language_codes[i];
167
  if(jQuery('#incl_langs'+lang+':checked').length) {
168
  lang_name = val;
169
- widget_code += '<option value="'+default_language+'|'+lang+'">'+lang_name+'</option>';
170
  }
171
  });
172
- widget_code += '</select>';
173
  }
174
 
175
  // Adding javascript
@@ -209,18 +210,19 @@ function RefreshDoWidgetCode() {
209
 
210
  }
211
 
 
 
212
  jQuery('#widget_code').val(widget_code);
213
 
214
- ShowWidgetPreview(widget_code);
215
 
216
  }
217
 
218
- function ShowWidgetPreview(widget_code) {
219
- var translation_method;
220
- if(translation_method == 'redirect')
221
- jQuery('#widget_preview').html(widget_code);
222
- else
223
- jQuery('#widget_preview').html(widget_code.replace(/javascript:doGTranslate/g, 'javascript:void').replace('onchange="doGTranslate(this);"', ''));
224
  }
225
 
226
  jQuery('#pro_version').attr('checked', '$pro_version'.length > 0);
@@ -532,6 +534,14 @@ EOT;
532
  }
533
 
534
  function load_defaults(& $data) {
535
- // -- TODO -- define defaults
 
 
 
 
 
 
 
 
536
  }
537
  }
3
  Plugin Name: GTranslate
4
  Plugin URI: http://edo.webmaster.am/gtranslate
5
  Description: Get translations with a single click between 58 languages (more than 98% of internet users) on your website!
6
+ Version: 1.0.3
7
  Author: Edvard Ananyan
8
  Author URI: http://edo.webmaster.am
9
 
100
 
101
  function RefreshDoWidgetCode() {
102
  var new_line = "\\n";
103
+ var widget_preview = '<!-- GTranslate: http://edo.webmaster.am/gtranslate -->'+new_line;
104
+ var widget_code = '';
105
  var translation_method = jQuery('#translation_method').val();
106
  var default_language = jQuery('#default_language').val();
107
  var flag_size = jQuery('#flag_size').val();
122
  }
123
  });
124
 
125
+ widget_preview += '<div id="google_translate_element"></div>'+new_line;
126
+ widget_preview += '<script type="text/javascript">'+new_line;
127
+ widget_preview += 'function googleTranslateElementInit() {new google.translate.TranslateElement({pageLanguage: \'';
128
+ widget_preview += default_language;
129
+ widget_preview += '\', includedLanguages: \'';
130
+ widget_preview += included_languages;
131
+ widget_preview += "'}, 'google_translate_element');}"+new_line;
132
+ widget_preview += '<\/script>';
133
+ widget_preview += '<script type="text/javascript" src="http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"><\/script>'+new_line;
134
  } else if(translation_method == 'on_fly' || translation_method == 'redirect') {
135
  // Adding flags
136
  if(jQuery('#show_flags:checked').length) {
140
  lang_name = val;
141
  flag_x = languages_map[lang.replace('-', '')+'_x'];
142
  flag_y = languages_map[lang.replace('-', '')+'_y'];
143
+ widget_preview += '<a href="javascript:doGTranslate(\''+default_language+'|'+lang+'\')" title="'+lang_name+'" class="gflag" style="background-position:-'+flag_x+'px -'+flag_y+'px;"><img src="{$site_url}/wp-content/plugins/gtranslate/blank.png" height="'+flag_size+'" width="'+flag_size+'" alt="'+lang_name+'" /></a>';
144
  }
145
  });
146
 
147
  // Adding stylesheet
148
+ widget_preview += new_line+new_line;
149
+ widget_preview += '<style type="text/css">'+new_line;
150
+ widget_preview += '<!--'+new_line;
151
+ widget_preview += "a.gflag {font-size:"+flag_size+"px;padding:1px 0;background-repeat:no-repeat;background-image:url('{$site_url}/wp-content/plugins/gtranslate/"+flag_size+".png');}"+new_line;
152
+ widget_preview += "a.gflag img {border:0;}"+new_line;
153
+ widget_preview += "a.gflag:hover {background-image:url('{$site_url}/wp-content/plugins/gtranslate/"+flag_size+"a.png');}"+new_line;
154
+ widget_preview += '-->'+new_line;
155
+ widget_preview += '</style>'+new_line+new_line;
156
  }
157
 
158
  // Adding dropdown
159
  if(jQuery('#show_dropdown:checked').length) {
160
  if(jQuery('#show_flags:checked').length && jQuery('#add_new_line:checked').length)
161
+ widget_preview += '<br />';
162
  else
163
+ widget_preview += ' ';
164
+ widget_preview += '<select onchange="doGTranslate(this);">';
165
+ widget_preview += '<option value="">Select Language</option>';
166
  jQuery.each(languages, function(i, val) {
167
  lang = language_codes[i];
168
  if(jQuery('#incl_langs'+lang+':checked').length) {
169
  lang_name = val;
170
+ widget_preview += '<option value="'+default_language+'|'+lang+'">'+lang_name+'</option>';
171
  }
172
  });
173
+ widget_preview += '</select>';
174
  }
175
 
176
  // Adding javascript
210
 
211
  }
212
 
213
+ widget_code = widget_preview + widget_code;
214
+
215
  jQuery('#widget_code').val(widget_code);
216
 
217
+ ShowWidgetPreview(widget_preview);
218
 
219
  }
220
 
221
+ function ShowWidgetPreview(widget_preview) {
222
+ widget_preview = widget_preview.replace(/javascript:doGTranslate/g, 'javascript:void')
223
+ widget_preview = widget_preview.replace('onchange="doGTranslate(this);"', '');
224
+ widget_preview = widget_preview.replace('if(jQuery.cookie', 'if(false && jQuery.cookie');
225
+ jQuery('#widget_preview').html(widget_preview);
 
226
  }
227
 
228
  jQuery('#pro_version').attr('checked', '$pro_version'.length > 0);
534
  }
535
 
536
  function load_defaults(& $data) {
537
+ $data['pro_version'] = '';
538
+ $data['new_window'] = '';
539
+ $data['load_jquery'] = '1';
540
+ $data['add_new_line'] = '1';
541
+ $data['show_dropdown'] = '1';
542
+ $data['show_flags'] = '1';
543
+ $data['default_language'] = 'en';
544
+ $data['translation_method'] = 'on_fly';
545
+ $data['flag_size'] = '16';
546
  }
547
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://edo.webmaster.am/gtranslate
5
  Tags: translate, translation, automatic translator, google translate, ajax translator, jquery translator
6
  Requires at least: 2.3
7
  Tested up to: 2.9
8
- Stable tag: 1.0.2
9
 
10
  Get translations with a single click between 58 languages (more than 98% of internet users) on your website!
11
 
@@ -50,4 +50,7 @@ It's a Google translation, hence Google quality.
50
  * RC1 version
51
 
52
  = 1.0.2 =
53
- * RC2 version
 
 
 
5
  Tags: translate, translation, automatic translator, google translate, ajax translator, jquery translator
6
  Requires at least: 2.3
7
  Tested up to: 2.9
8
+ Stable tag: 1.0.3
9
 
10
  Get translations with a single click between 58 languages (more than 98% of internet users) on your website!
11
 
50
  * RC1 version
51
 
52
  = 1.0.2 =
53
+ * RC2 version
54
+
55
+ = 1.0.3 =
56
+ * Stable version released