Version Description
- Show languages in their native names
- Automatically select default language based on wordpress locale
- Coding issue with PHP Strict Standards and Fatal Error on some PHP versions fixed
- Error messages more informative
Download this release
Release Info
| Developer | edo888 |
| Plugin | |
| Version | 2.8.5 |
| Comparing to | |
| See all releases | |
Code changes from version 2.8.4 to 2.8.5
- gtranslate.php +104 -106
- native_names_map.php +107 -0
- readme.txt +10 -3
gtranslate.php
CHANGED
|
@@ -3,14 +3,14 @@
|
|
| 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.
|
| 7 |
Author: Edvard Ananyan
|
| 8 |
Author URI: https://gtranslate.io
|
| 9 |
Text Domain: gtranslate
|
| 10 |
|
| 11 |
*/
|
| 12 |
|
| 13 |
-
/* Copyright 2010 -
|
| 14 |
|
| 15 |
This program is free software; you can redistribute it and/or modify
|
| 16 |
it under the terms of the GNU General Public License as published by
|
|
@@ -37,58 +37,6 @@ add_action('plugins_loaded', array('GTranslate', 'load_textdomain'));
|
|
| 37 |
add_shortcode('GTranslate', array('GTranslate', 'get_widget_code'));
|
| 38 |
add_shortcode('gtranslate', array('GTranslate', 'get_widget_code'));
|
| 39 |
|
| 40 |
-
if(is_admin()) {
|
| 41 |
-
global $pagenow;
|
| 42 |
-
|
| 43 |
-
if(!defined('DOING_AJAX') or !DOING_AJAX)
|
| 44 |
-
new GTranslate_Notices();
|
| 45 |
-
}
|
| 46 |
-
|
| 47 |
-
$data = get_option('GTranslate');
|
| 48 |
-
GTranslate::load_defaults($data);
|
| 49 |
-
|
| 50 |
-
if(!empty($data['show_in_menu'])) {
|
| 51 |
-
add_filter('wp_nav_menu_items', 'gtranslate_menu_item', 10, 2);
|
| 52 |
-
function gtranslate_menu_item($items, $args) {
|
| 53 |
-
$data = get_option('GTranslate');
|
| 54 |
-
GTranslate::load_defaults($data);
|
| 55 |
-
|
| 56 |
-
if($args->theme_location == $data['show_in_menu'])
|
| 57 |
-
$items .= '<li style="position:relative;" class="menu-item menu-item-gtranslate"><div style="position:absolute;">'.GTranslate::get_widget_code(false).'</div></li>';
|
| 58 |
-
return $items;
|
| 59 |
-
}
|
| 60 |
-
}
|
| 61 |
-
|
| 62 |
-
if($data['floating_language_selector'] != 'no' and !is_admin()) {
|
| 63 |
-
add_action('wp_footer', 'gtranslate_display_floating');
|
| 64 |
-
function gtranslate_display_floating() {
|
| 65 |
-
$data = get_option('GTranslate');
|
| 66 |
-
GTranslate::load_defaults($data);
|
| 67 |
-
|
| 68 |
-
if($data['widget_look'] == 'dropdown_with_flags')
|
| 69 |
-
$vertical_location = '0';
|
| 70 |
-
else
|
| 71 |
-
$vertical_location = '5%';
|
| 72 |
-
|
| 73 |
-
switch($data['floating_language_selector']) {
|
| 74 |
-
case 'top_left': $html = '<div style="position:fixed;top:'.$vertical_location.';left:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 75 |
-
case 'top_right': $html = '<div style="position:fixed;top:'.$vertical_location.';right:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 76 |
-
case 'bottom_left': $html = '<div style="position:fixed;bottom:'.$vertical_location.';left:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 77 |
-
case 'bottom_right': $html = '<div style="position:fixed;bottom:'.$vertical_location.';right:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 78 |
-
default: $html = ''; break;
|
| 79 |
-
}
|
| 80 |
-
|
| 81 |
-
echo $html;
|
| 82 |
-
}
|
| 83 |
-
}
|
| 84 |
-
|
| 85 |
-
if($data['url_translation'] and ($data['pro_version'] or $data['enterprise_version'])) {
|
| 86 |
-
add_action('wp_head', 'gtranslate_url_translation_meta', 1);
|
| 87 |
-
function gtranslate_url_translation_meta() {
|
| 88 |
-
echo '<meta name="uri-translation" content="on" />';
|
| 89 |
-
}
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
class GTranslate extends WP_Widget {
|
| 93 |
public static function activate() {
|
| 94 |
$data = array(
|
|
@@ -172,7 +120,7 @@ class GTranslate extends WP_Widget {
|
|
| 172 |
echo $args['after_widget'];
|
| 173 |
}
|
| 174 |
|
| 175 |
-
function get_widget_code($atts) {
|
| 176 |
$data = get_option('GTranslate');
|
| 177 |
GTranslate::load_defaults($data);
|
| 178 |
|
|
@@ -215,6 +163,9 @@ class GTranslate extends WP_Widget {
|
|
| 215 |
|
| 216 |
$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"}';
|
| 217 |
$gt_lang_array = get_object_vars(json_decode($gt_lang_array_json));
|
|
|
|
|
|
|
|
|
|
| 218 |
|
| 219 |
if(!empty($language_codes))
|
| 220 |
$gt_lang_codes_json = json_encode(explode(',', $language_codes));
|
|
@@ -226,13 +177,11 @@ class GTranslate extends WP_Widget {
|
|
| 226 |
else
|
| 227 |
$gt_lang_codes2_json = '[]';
|
| 228 |
|
| 229 |
-
|
| 230 |
-
#unset($data['widget_code']);
|
| 231 |
-
#echo '<pre>', print_r($data, true), '</pre>';
|
| 232 |
-
|
| 233 |
$script = <<<EOT
|
| 234 |
|
| 235 |
-
var
|
|
|
|
|
|
|
| 236 |
var languages = [], language_codes = $gt_lang_codes_json, language_codes2 = $gt_lang_codes2_json;
|
| 237 |
|
| 238 |
//for(var key in gt_lang_array)
|
|
@@ -250,7 +199,7 @@ function RefreshDoWidgetCode() {
|
|
| 250 |
var new_line = "\\n";
|
| 251 |
var widget_preview = '<!-- GTranslate: https://gtranslate.io/ -->'+new_line;
|
| 252 |
var widget_code = '';
|
| 253 |
-
var translation_method = 'onfly';
|
| 254 |
var widget_look = jQuery('#widget_look').val();
|
| 255 |
var default_language = jQuery('#default_language').val();
|
| 256 |
var flag_size = jQuery('#flag_size').val();
|
|
@@ -259,6 +208,7 @@ function RefreshDoWidgetCode() {
|
|
| 259 |
var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
|
| 260 |
var show_in_menu = jQuery('#show_in_menu').val();
|
| 261 |
var floating_language_selector = jQuery('#floating_language_selector').val();
|
|
|
|
| 262 |
var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
|
| 263 |
|
| 264 |
if(pro_version || enterprise_version) {
|
|
@@ -303,13 +253,22 @@ function RefreshDoWidgetCode() {
|
|
| 303 |
jQuery('#flag_size_option').show();
|
| 304 |
}
|
| 305 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 306 |
if(pro_version && enterprise_version)
|
| 307 |
pro_version = false;
|
| 308 |
|
| 309 |
if(translation_method == 'on_fly' || translation_method == 'redirect' || translation_method == 'onfly') {
|
| 310 |
// Adding flags
|
| 311 |
-
if(widget_look == 'flags' || widget_look == 'flags_dropdown'
|
| 312 |
-
//console.log('adding flags');
|
| 313 |
jQuery.each(language_codes, function(i, val) {
|
| 314 |
lang = language_codes[i];
|
| 315 |
if(jQuery('#fincl_langs'+lang+':checked').length) {
|
|
@@ -336,9 +295,8 @@ function RefreshDoWidgetCode() {
|
|
| 336 |
}
|
| 337 |
|
| 338 |
// Adding dropdown
|
| 339 |
-
if(widget_look == 'dropdown' || widget_look == 'flags_dropdown'
|
| 340 |
-
|
| 341 |
-
if(/* jQuery('#show_flags:checked').length*/ (widget_look == 'flags' || widget_look == 'flags_dropdown') && jQuery('#add_new_line:checked').length)
|
| 342 |
widget_preview += '<br />';
|
| 343 |
else
|
| 344 |
widget_preview += ' ';
|
|
@@ -356,8 +314,6 @@ function RefreshDoWidgetCode() {
|
|
| 356 |
|
| 357 |
// Adding onfly html and css
|
| 358 |
if(translation_method == 'onfly') {
|
| 359 |
-
//console.log('adding onfly html, css and javascript');
|
| 360 |
-
|
| 361 |
widget_code += '<style type="text/css">'+new_line;
|
| 362 |
widget_code += '<!--'+new_line;
|
| 363 |
widget_code += "#goog-gt-tt {display:none !important;}"+new_line;
|
|
@@ -372,8 +328,6 @@ function RefreshDoWidgetCode() {
|
|
| 372 |
widget_code += 'function googleTranslateElementInit2() {new google.translate.TranslateElement({pageLanguage: \'';
|
| 373 |
widget_code += default_language;
|
| 374 |
widget_code += '\',autoDisplay: false';
|
| 375 |
-
//if(analytics)
|
| 376 |
-
// widget_code += ",gaTrack: (typeof ga!='undefined'),gaId: (typeof ga!='undefined' ? ga.getAll()[0].get('trackingId') : '')";
|
| 377 |
widget_code += "}, 'google_translate_element2');}"+new_line;
|
| 378 |
widget_code += '<\/script>';
|
| 379 |
widget_code += '<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit2"><\/script>'+new_line;
|
|
@@ -386,7 +340,6 @@ function RefreshDoWidgetCode() {
|
|
| 386 |
widget_preview += '<style type="text/css">'+new_line;
|
| 387 |
widget_preview += '.gglobe {background-image:url($wp_plugin_url/gtglobe.svg);opacity:0.8;border-radius:50%;height:40px;width:40px;cursor:pointer;display:block;-moz-transition: all 0.3s;-webkit-transition: all 0.3s;transition: all 0.3s;}'+new_line;
|
| 388 |
widget_preview += '.gglobe:hover {opacity:1;-moz-transform: scale(1.2);-webkit-transform: scale(1.2);transform: scale(1.2);}'+new_line;
|
| 389 |
-
//widget_preview += '.gsatelites {position:relative;}'+new_line;
|
| 390 |
widget_preview += '.gsatelite {background-color:#777777;opacity:0.95;border-radius:50%;height:24px;width:24px;cursor:pointer;position:absolute;z-index:100000;display:none;-moz-transition: all 0.3s;-webkit-transition: all 0.3s;transition: all 0.3s;}'+new_line;
|
| 391 |
widget_preview += '.gsatelite:hover {opacity:1;-moz-transform: scale(1.3);-webkit-transform: scale(1.3);transform: scale(1.3);}'+new_line;
|
| 392 |
widget_preview += '</style>'+new_line+new_line;
|
|
@@ -538,8 +491,6 @@ function hideGSatelites($) {
|
|
| 538 |
}
|
| 539 |
|
| 540 |
// Adding javascript
|
| 541 |
-
//console.log('adding doGTranslate javascript');
|
| 542 |
-
|
| 543 |
widget_code += new_line+new_line;
|
| 544 |
widget_code += '<script type="text/javascript">'+new_line;
|
| 545 |
if(pro_version && translation_method == 'redirect' && new_window) {
|
|
@@ -599,12 +550,10 @@ jQuery('#url_translation').attr('checked', '$url_translation'.length > 0);
|
|
| 599 |
jQuery('#new_window').attr('checked', '$new_window'.length > 0);
|
| 600 |
jQuery('#show_in_menu').val('$show_in_menu');
|
| 601 |
jQuery('#floating_language_selector').val('$floating_language_selector');
|
|
|
|
| 602 |
jQuery('#analytics').attr('checked', '$analytics'.length > 0);
|
| 603 |
-
jQuery('#load_jquery').attr('checked', '$load_jquery'.length > 0);
|
| 604 |
jQuery('#add_new_line').attr('checked', '$add_new_line'.length > 0);
|
| 605 |
-
|
| 606 |
jQuery('#default_language').val('$default_language');
|
| 607 |
-
//jQuery('#translation_method').val('$translation_method');
|
| 608 |
jQuery('#widget_look').val('$widget_look');
|
| 609 |
jQuery('#flag_size').val('$flag_size');
|
| 610 |
|
|
@@ -689,7 +638,7 @@ foreach($alt_flags as $flag)
|
|
| 689 |
$script .= "jQuery('#alt_$flag').attr('checked', true);\n";
|
| 690 |
?>
|
| 691 |
|
| 692 |
-
<form id="gtranslate" name="form1" method="post" action="<?php echo admin_url('options-general.php?page=gtranslate_options'); ?>">
|
| 693 |
|
| 694 |
<div class="postbox-container og_left_col">
|
| 695 |
|
|
@@ -698,16 +647,6 @@ foreach($alt_flags as $flag)
|
|
| 698 |
<h3 id="settings"><?php _e('Widget options', 'gtranslate'); ?></h3>
|
| 699 |
<div class="inside">
|
| 700 |
<table style="width:100%;" cellpadding="4">
|
| 701 |
-
<!--tr>
|
| 702 |
-
<td class="option_name">Translation method:</td>
|
| 703 |
-
<td>
|
| 704 |
-
<select id="translation_method" name="translation_method" onChange="RefreshDoWidgetCode()">
|
| 705 |
-
<option value="google_default">Google Default</option>
|
| 706 |
-
<option value="redirect">Redirect</option>
|
| 707 |
-
<option value="onfly">On Fly</option>
|
| 708 |
-
</select>
|
| 709 |
-
</td>
|
| 710 |
-
</tr-->
|
| 711 |
<tr>
|
| 712 |
<td class="option_name"><?php _e('Widget look', 'gtranslate'); ?>:</td>
|
| 713 |
<td>
|
|
@@ -861,7 +800,6 @@ foreach($alt_flags as $flag)
|
|
| 861 |
<option value="<?php echo $location; ?>"><?php echo $description; ?></option>
|
| 862 |
<?php endforeach; ?>
|
| 863 |
</select>
|
| 864 |
-
<!--input id="show_in_primary_menu" name="show_in_primary_menu" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/-->
|
| 865 |
</td>
|
| 866 |
</tr>
|
| 867 |
<tr id="floating_option">
|
|
@@ -876,11 +814,10 @@ foreach($alt_flags as $flag)
|
|
| 876 |
</select>
|
| 877 |
</td>
|
| 878 |
</tr>
|
| 879 |
-
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
|
| 883 |
-
</tr-->
|
| 884 |
<tr id="flag_size_option">
|
| 885 |
<td class="option_name"><?php _e('Flag size', 'gtranslate'); ?>:</td>
|
| 886 |
<td>
|
|
@@ -900,7 +837,7 @@ foreach($alt_flags as $flag)
|
|
| 900 |
<ul style="list-style-type:none;width:25%;float:left;" class="connectedSortable1">
|
| 901 |
<?php for($j = $i * 15; $j < 15 * ($i+1); $j++): ?>
|
| 902 |
<?php if(isset($gt_lang_codes[$j])): ?>
|
| 903 |
-
<li><input type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()" id="fincl_langs<?php echo $gt_lang_codes[$j]; ?>" name="fincl_langs[]" value="<?php echo $gt_lang_codes[$j]; ?>"><label for="fincl_langs<?php echo $gt_lang_codes[$j]; ?>"><?php _e($gt_lang_array[$gt_lang_codes[$j]], 'gtranslate'); ?></label></li>
|
| 904 |
<?php endif; ?>
|
| 905 |
<?php endfor; ?>
|
| 906 |
</ul>
|
|
@@ -919,10 +856,6 @@ foreach($alt_flags as $flag)
|
|
| 919 |
<td class="option_name"><?php _e('Line break after flags', 'gtranslate'); ?>:</td>
|
| 920 |
<td><input id="add_new_line" name="add_new_line" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
|
| 921 |
</tr>
|
| 922 |
-
<!--tr>
|
| 923 |
-
<td class="option_name">Show dropdown:</td>
|
| 924 |
-
<td><input id="show_dropdown" name="show_dropdown" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
|
| 925 |
-
</tr-->
|
| 926 |
<tr id="dropdown_languages_option" style="display:none;">
|
| 927 |
<td class="option_name" colspan="2"><?php _e('Languages', 'gtranslate'); ?>: <a onclick="jQuery('.connectedSortable2 input').attr('checked', true);RefreshDoWidgetCode()" style="cursor:pointer;text-decoration:underline;"><?php _e('Check All', 'gtranslate'); ?></a> | <a onclick="jQuery('.connectedSortable2 input').attr('checked', false);RefreshDoWidgetCode()" style="cursor:pointer;text-decoration:underline;"><?php _e('Uncheck All', 'gtranslate'); ?></a><br /><br />
|
| 928 |
<div>
|
|
@@ -931,7 +864,7 @@ foreach($alt_flags as $flag)
|
|
| 931 |
<ul style="list-style-type:none;width:25%;float:left;" class="connectedSortable2">
|
| 932 |
<?php for($j = $i * 26; $j < 26 * ($i+1); $j++): ?>
|
| 933 |
<?php if(isset($gt_lang_codes[$j])): ?>
|
| 934 |
-
<li><input type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()" id="incl_langs<?php echo $gt_lang_codes[$j]; ?>" name="incl_langs[]" value="<?php echo $gt_lang_codes[$j]; ?>"><label for="incl_langs<?php echo $gt_lang_codes[$j]; ?>"><?php _e($gt_lang_array[$gt_lang_codes[$j]], 'gtranslate'); ?></label></li>
|
| 935 |
<?php endif; ?>
|
| 936 |
<?php endfor; ?>
|
| 937 |
</ul>
|
|
@@ -1071,8 +1004,8 @@ foreach($alt_flags as $flag)
|
|
| 1071 |
$data['new_window'] = isset($_POST['new_window']) ? intval($_POST['new_window']) : '';
|
| 1072 |
$data['show_in_menu'] = isset($_POST['show_in_menu']) ? sanitize_text_field($_POST['show_in_menu']) : '';
|
| 1073 |
$data['floating_language_selector'] = isset($_POST['floating_language_selector']) ? sanitize_text_field($_POST['floating_language_selector']) : 'no';
|
|
|
|
| 1074 |
$data['analytics'] = isset($_POST['analytics']) ? intval($_POST['analytics']) : '';
|
| 1075 |
-
$data['load_jquery'] = isset($_POST['load_jquery']) ? intval($_POST['load_jquery']) : '';
|
| 1076 |
$data['add_new_line'] = isset($_POST['add_new_line']) ? intval($_POST['add_new_line']) : '';
|
| 1077 |
$data['default_language'] = isset($_POST['default_language']) ? sanitize_text_field($_POST['default_language']) : 'en';
|
| 1078 |
$data['translation_method'] = 'onfly';
|
|
@@ -1085,7 +1018,7 @@ foreach($alt_flags as $flag)
|
|
| 1085 |
$data['language_codes'] = (isset($_POST['language_codes']) and !empty($_POST['language_codes'])) ? sanitize_text_field($_POST['language_codes']) : 'af,sq,ar,hy,az,eu,be,bg,ca,zh-CN,zh-TW,hr,cs,da,nl,en,et,tl,fi,fr,gl,ka,de,el,ht,iw,hi,hu,is,id,ga,it,ja,ko,lv,lt,mk,ms,mt,no,fa,pl,pt,ro,ru,sr,sk,sl,es,sw,sv,th,tr,uk,ur,vi,cy,yi';
|
| 1086 |
$data['language_codes2'] = (isset($_POST['language_codes2']) and !empty($_POST['language_codes2'])) ? sanitize_text_field($_POST['language_codes2']) : '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';
|
| 1087 |
|
| 1088 |
-
echo '<p style="color:red;">' . __('Changes Saved') . '</p>';
|
| 1089 |
update_option('GTranslate', $data);
|
| 1090 |
|
| 1091 |
if($data['pro_version']) { // check if rewrite rules are in place
|
|
@@ -1099,9 +1032,15 @@ foreach($alt_flags as $flag)
|
|
| 1099 |
$htaccess = $rewrite_rules . "\r\n\r\n" . $htaccess;
|
| 1100 |
if(!empty($htaccess)) { // going to update .htaccess
|
| 1101 |
file_put_contents($htaccess_file, $htaccess);
|
| 1102 |
-
echo '<p style="color:red;">' . __('.htaccess file updated') . '</p>';
|
| 1103 |
}
|
| 1104 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1105 |
}
|
| 1106 |
|
| 1107 |
// update main_lang in config.php
|
|
@@ -1110,6 +1049,8 @@ foreach($alt_flags as $flag)
|
|
| 1110 |
$config = file_get_contents($config_file);
|
| 1111 |
$config = preg_replace('/\$main_lang = \'[a-z-]{2,5}\'/i', '$main_lang = \''.$data['default_language'].'\'', $config);
|
| 1112 |
file_put_contents($config_file, $config);
|
|
|
|
|
|
|
| 1113 |
}
|
| 1114 |
|
| 1115 |
} else { // todo: remove rewrite rules
|
|
@@ -1124,14 +1065,19 @@ foreach($alt_flags as $flag)
|
|
| 1124 |
$data['new_window'] = isset($data['new_window']) ? $data['new_window'] : '';
|
| 1125 |
$data['show_in_menu'] = isset($data['show_in_menu']) ? $data['show_in_menu'] : ((isset($data['show_in_primary_menu']) and $data['show_in_primary_menu'] == 1) ? 'primary' : '');
|
| 1126 |
$data['floating_language_selector'] = isset($data['floating_language_selector']) ? $data['floating_language_selector'] : 'no';
|
|
|
|
| 1127 |
$data['analytics'] = isset($data['analytics']) ? $data['analytics'] : '';
|
| 1128 |
-
$data['load_jquery'] = isset($data['load_jquery']) ? $data['load_jquery'] : '1';
|
| 1129 |
$data['add_new_line'] = isset($data['add_new_line']) ? $data['add_new_line'] : '1';
|
| 1130 |
-
|
| 1131 |
-
|
| 1132 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1133 |
$data['translation_method'] = isset($data['translation_method']) ? $data['translation_method'] : 'onfly';
|
| 1134 |
if($data['translation_method'] == 'on_fly') $data['translation_method'] = 'redirect';
|
|
|
|
| 1135 |
$data['widget_look'] = isset($data['widget_look']) ? $data['widget_look'] : 'flags_dropdown';
|
| 1136 |
$data['flag_size'] = isset($data['flag_size']) ? $data['flag_size'] : '16';
|
| 1137 |
$data['widget_code'] = isset($data['widget_code']) ? $data['widget_code'] : '';
|
|
@@ -1431,3 +1377,55 @@ class GTranslate_Notices {
|
|
| 1431 |
}
|
| 1432 |
|
| 1433 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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.5
|
| 7 |
Author: Edvard Ananyan
|
| 8 |
Author URI: https://gtranslate.io
|
| 9 |
Text Domain: gtranslate
|
| 10 |
|
| 11 |
*/
|
| 12 |
|
| 13 |
+
/* Copyright 2010 - 2017 Edvard Ananyan (email : edo888@gmail.com)
|
| 14 |
|
| 15 |
This program is free software; you can redistribute it and/or modify
|
| 16 |
it under the terms of the GNU General Public License as published by
|
| 37 |
add_shortcode('GTranslate', array('GTranslate', 'get_widget_code'));
|
| 38 |
add_shortcode('gtranslate', array('GTranslate', 'get_widget_code'));
|
| 39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
class GTranslate extends WP_Widget {
|
| 41 |
public static function activate() {
|
| 42 |
$data = array(
|
| 120 |
echo $args['after_widget'];
|
| 121 |
}
|
| 122 |
|
| 123 |
+
public static function get_widget_code($atts) {
|
| 124 |
$data = get_option('GTranslate');
|
| 125 |
GTranslate::load_defaults($data);
|
| 126 |
|
| 163 |
|
| 164 |
$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"}';
|
| 165 |
$gt_lang_array = get_object_vars(json_decode($gt_lang_array_json));
|
| 166 |
+
include dirname(__FILE__) . '/native_names_map.php'; // defines $native_names_map array
|
| 167 |
+
//echo '<pre>' . print_r($native_names_map, true) . '</pre>';
|
| 168 |
+
$gt_lang_array_native_json = json_encode($native_names_map);
|
| 169 |
|
| 170 |
if(!empty($language_codes))
|
| 171 |
$gt_lang_codes_json = json_encode(explode(',', $language_codes));
|
| 177 |
else
|
| 178 |
$gt_lang_codes2_json = '[]';
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
$script = <<<EOT
|
| 181 |
|
| 182 |
+
var gt_lang_array_english = $gt_lang_array_json;
|
| 183 |
+
var gt_lang_array_native = $gt_lang_array_native_json;
|
| 184 |
+
var gt_lang_array = gt_lang_array_english;
|
| 185 |
var languages = [], language_codes = $gt_lang_codes_json, language_codes2 = $gt_lang_codes2_json;
|
| 186 |
|
| 187 |
//for(var key in gt_lang_array)
|
| 199 |
var new_line = "\\n";
|
| 200 |
var widget_preview = '<!-- GTranslate: https://gtranslate.io/ -->'+new_line;
|
| 201 |
var widget_code = '';
|
| 202 |
+
var translation_method = 'onfly';
|
| 203 |
var widget_look = jQuery('#widget_look').val();
|
| 204 |
var default_language = jQuery('#default_language').val();
|
| 205 |
var flag_size = jQuery('#flag_size').val();
|
| 208 |
var new_window = jQuery('#new_window:checked').length > 0 ? true : false;
|
| 209 |
var show_in_menu = jQuery('#show_in_menu').val();
|
| 210 |
var floating_language_selector = jQuery('#floating_language_selector').val();
|
| 211 |
+
var native_language_names = jQuery('#native_language_names:checked').length > 0 ? true : false;
|
| 212 |
var analytics = jQuery('#analytics:checked').length > 0 ? true : false;
|
| 213 |
|
| 214 |
if(pro_version || enterprise_version) {
|
| 253 |
jQuery('#flag_size_option').show();
|
| 254 |
}
|
| 255 |
|
| 256 |
+
if(native_language_names) {
|
| 257 |
+
gt_lang_array = gt_lang_array_native;
|
| 258 |
+
jQuery('.en_names').hide();
|
| 259 |
+
jQuery('.native_names').show();
|
| 260 |
+
} else {
|
| 261 |
+
gt_lang_array = gt_lang_array_english;
|
| 262 |
+
jQuery('.native_names').hide();
|
| 263 |
+
jQuery('.en_names').show();
|
| 264 |
+
}
|
| 265 |
+
|
| 266 |
if(pro_version && enterprise_version)
|
| 267 |
pro_version = false;
|
| 268 |
|
| 269 |
if(translation_method == 'on_fly' || translation_method == 'redirect' || translation_method == 'onfly') {
|
| 270 |
// Adding flags
|
| 271 |
+
if(widget_look == 'flags' || widget_look == 'flags_dropdown') {
|
|
|
|
| 272 |
jQuery.each(language_codes, function(i, val) {
|
| 273 |
lang = language_codes[i];
|
| 274 |
if(jQuery('#fincl_langs'+lang+':checked').length) {
|
| 295 |
}
|
| 296 |
|
| 297 |
// Adding dropdown
|
| 298 |
+
if(widget_look == 'dropdown' || widget_look == 'flags_dropdown') {
|
| 299 |
+
if((widget_look == 'flags' || widget_look == 'flags_dropdown') && jQuery('#add_new_line:checked').length)
|
|
|
|
| 300 |
widget_preview += '<br />';
|
| 301 |
else
|
| 302 |
widget_preview += ' ';
|
| 314 |
|
| 315 |
// Adding onfly html and css
|
| 316 |
if(translation_method == 'onfly') {
|
|
|
|
|
|
|
| 317 |
widget_code += '<style type="text/css">'+new_line;
|
| 318 |
widget_code += '<!--'+new_line;
|
| 319 |
widget_code += "#goog-gt-tt {display:none !important;}"+new_line;
|
| 328 |
widget_code += 'function googleTranslateElementInit2() {new google.translate.TranslateElement({pageLanguage: \'';
|
| 329 |
widget_code += default_language;
|
| 330 |
widget_code += '\',autoDisplay: false';
|
|
|
|
|
|
|
| 331 |
widget_code += "}, 'google_translate_element2');}"+new_line;
|
| 332 |
widget_code += '<\/script>';
|
| 333 |
widget_code += '<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit2"><\/script>'+new_line;
|
| 340 |
widget_preview += '<style type="text/css">'+new_line;
|
| 341 |
widget_preview += '.gglobe {background-image:url($wp_plugin_url/gtglobe.svg);opacity:0.8;border-radius:50%;height:40px;width:40px;cursor:pointer;display:block;-moz-transition: all 0.3s;-webkit-transition: all 0.3s;transition: all 0.3s;}'+new_line;
|
| 342 |
widget_preview += '.gglobe:hover {opacity:1;-moz-transform: scale(1.2);-webkit-transform: scale(1.2);transform: scale(1.2);}'+new_line;
|
|
|
|
| 343 |
widget_preview += '.gsatelite {background-color:#777777;opacity:0.95;border-radius:50%;height:24px;width:24px;cursor:pointer;position:absolute;z-index:100000;display:none;-moz-transition: all 0.3s;-webkit-transition: all 0.3s;transition: all 0.3s;}'+new_line;
|
| 344 |
widget_preview += '.gsatelite:hover {opacity:1;-moz-transform: scale(1.3);-webkit-transform: scale(1.3);transform: scale(1.3);}'+new_line;
|
| 345 |
widget_preview += '</style>'+new_line+new_line;
|
| 491 |
}
|
| 492 |
|
| 493 |
// Adding javascript
|
|
|
|
|
|
|
| 494 |
widget_code += new_line+new_line;
|
| 495 |
widget_code += '<script type="text/javascript">'+new_line;
|
| 496 |
if(pro_version && translation_method == 'redirect' && new_window) {
|
| 550 |
jQuery('#new_window').attr('checked', '$new_window'.length > 0);
|
| 551 |
jQuery('#show_in_menu').val('$show_in_menu');
|
| 552 |
jQuery('#floating_language_selector').val('$floating_language_selector');
|
| 553 |
+
jQuery('#native_language_names').attr('checked', '$native_language_names'.length > 0);
|
| 554 |
jQuery('#analytics').attr('checked', '$analytics'.length > 0);
|
|
|
|
| 555 |
jQuery('#add_new_line').attr('checked', '$add_new_line'.length > 0);
|
|
|
|
| 556 |
jQuery('#default_language').val('$default_language');
|
|
|
|
| 557 |
jQuery('#widget_look').val('$widget_look');
|
| 558 |
jQuery('#flag_size').val('$flag_size');
|
| 559 |
|
| 638 |
$script .= "jQuery('#alt_$flag').attr('checked', true);\n";
|
| 639 |
?>
|
| 640 |
|
| 641 |
+
<form id="gtranslate" name="form1" method="post" class="notranslate" action="<?php echo admin_url('options-general.php?page=gtranslate_options'); ?>">
|
| 642 |
|
| 643 |
<div class="postbox-container og_left_col">
|
| 644 |
|
| 647 |
<h3 id="settings"><?php _e('Widget options', 'gtranslate'); ?></h3>
|
| 648 |
<div class="inside">
|
| 649 |
<table style="width:100%;" cellpadding="4">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 650 |
<tr>
|
| 651 |
<td class="option_name"><?php _e('Widget look', 'gtranslate'); ?>:</td>
|
| 652 |
<td>
|
| 800 |
<option value="<?php echo $location; ?>"><?php echo $description; ?></option>
|
| 801 |
<?php endforeach; ?>
|
| 802 |
</select>
|
|
|
|
| 803 |
</td>
|
| 804 |
</tr>
|
| 805 |
<tr id="floating_option">
|
| 814 |
</select>
|
| 815 |
</td>
|
| 816 |
</tr>
|
| 817 |
+
<td class="option_name"><?php _e('Show native language names', 'gtranslate'); ?>:</td>
|
| 818 |
+
<td><input id="native_language_names" name="native_language_names" value="1" type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
|
| 819 |
+
<tr>
|
| 820 |
+
</tr>
|
|
|
|
| 821 |
<tr id="flag_size_option">
|
| 822 |
<td class="option_name"><?php _e('Flag size', 'gtranslate'); ?>:</td>
|
| 823 |
<td>
|
| 837 |
<ul style="list-style-type:none;width:25%;float:left;" class="connectedSortable1">
|
| 838 |
<?php for($j = $i * 15; $j < 15 * ($i+1); $j++): ?>
|
| 839 |
<?php if(isset($gt_lang_codes[$j])): ?>
|
| 840 |
+
<li><input type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()" id="fincl_langs<?php echo $gt_lang_codes[$j]; ?>" name="fincl_langs[]" value="<?php echo $gt_lang_codes[$j]; ?>"><label for="fincl_langs<?php echo $gt_lang_codes[$j]; ?>"><span class="en_names"><?php _e($gt_lang_array[$gt_lang_codes[$j]], 'gtranslate'); ?></span><span class="native_names" style="display:none;"><?php echo $native_names_map[$gt_lang_codes[$j]]; ?></span></label></li>
|
| 841 |
<?php endif; ?>
|
| 842 |
<?php endfor; ?>
|
| 843 |
</ul>
|
| 856 |
<td class="option_name"><?php _e('Line break after flags', 'gtranslate'); ?>:</td>
|
| 857 |
<td><input id="add_new_line" name="add_new_line" value="1" type="checkbox" checked="checked" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()"/></td>
|
| 858 |
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 859 |
<tr id="dropdown_languages_option" style="display:none;">
|
| 860 |
<td class="option_name" colspan="2"><?php _e('Languages', 'gtranslate'); ?>: <a onclick="jQuery('.connectedSortable2 input').attr('checked', true);RefreshDoWidgetCode()" style="cursor:pointer;text-decoration:underline;"><?php _e('Check All', 'gtranslate'); ?></a> | <a onclick="jQuery('.connectedSortable2 input').attr('checked', false);RefreshDoWidgetCode()" style="cursor:pointer;text-decoration:underline;"><?php _e('Uncheck All', 'gtranslate'); ?></a><br /><br />
|
| 861 |
<div>
|
| 864 |
<ul style="list-style-type:none;width:25%;float:left;" class="connectedSortable2">
|
| 865 |
<?php for($j = $i * 26; $j < 26 * ($i+1); $j++): ?>
|
| 866 |
<?php if(isset($gt_lang_codes[$j])): ?>
|
| 867 |
+
<li><input type="checkbox" onclick="RefreshDoWidgetCode()" onchange="RefreshDoWidgetCode()" id="incl_langs<?php echo $gt_lang_codes[$j]; ?>" name="incl_langs[]" value="<?php echo $gt_lang_codes[$j]; ?>"><label for="incl_langs<?php echo $gt_lang_codes[$j]; ?>"><span class="en_names"><?php _e($gt_lang_array[$gt_lang_codes[$j]], 'gtranslate'); ?></span><span class="native_names" style="display:none;"><?php echo $native_names_map[$gt_lang_codes[$j]]; ?></span></label></li>
|
| 868 |
<?php endif; ?>
|
| 869 |
<?php endfor; ?>
|
| 870 |
</ul>
|
| 1004 |
$data['new_window'] = isset($_POST['new_window']) ? intval($_POST['new_window']) : '';
|
| 1005 |
$data['show_in_menu'] = isset($_POST['show_in_menu']) ? sanitize_text_field($_POST['show_in_menu']) : '';
|
| 1006 |
$data['floating_language_selector'] = isset($_POST['floating_language_selector']) ? sanitize_text_field($_POST['floating_language_selector']) : 'no';
|
| 1007 |
+
$data['native_language_names'] = isset($_POST['native_language_names']) ? intval($_POST['native_language_names']) : '';
|
| 1008 |
$data['analytics'] = isset($_POST['analytics']) ? intval($_POST['analytics']) : '';
|
|
|
|
| 1009 |
$data['add_new_line'] = isset($_POST['add_new_line']) ? intval($_POST['add_new_line']) : '';
|
| 1010 |
$data['default_language'] = isset($_POST['default_language']) ? sanitize_text_field($_POST['default_language']) : 'en';
|
| 1011 |
$data['translation_method'] = 'onfly';
|
| 1018 |
$data['language_codes'] = (isset($_POST['language_codes']) and !empty($_POST['language_codes'])) ? sanitize_text_field($_POST['language_codes']) : 'af,sq,ar,hy,az,eu,be,bg,ca,zh-CN,zh-TW,hr,cs,da,nl,en,et,tl,fi,fr,gl,ka,de,el,ht,iw,hi,hu,is,id,ga,it,ja,ko,lv,lt,mk,ms,mt,no,fa,pl,pt,ro,ru,sr,sk,sl,es,sw,sv,th,tr,uk,ur,vi,cy,yi';
|
| 1019 |
$data['language_codes2'] = (isset($_POST['language_codes2']) and !empty($_POST['language_codes2'])) ? sanitize_text_field($_POST['language_codes2']) : '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';
|
| 1020 |
|
| 1021 |
+
echo '<p style="color:red;">' . __('Changes Saved', 'gtranslate') . '</p>';
|
| 1022 |
update_option('GTranslate', $data);
|
| 1023 |
|
| 1024 |
if($data['pro_version']) { // check if rewrite rules are in place
|
| 1032 |
$htaccess = $rewrite_rules . "\r\n\r\n" . $htaccess;
|
| 1033 |
if(!empty($htaccess)) { // going to update .htaccess
|
| 1034 |
file_put_contents($htaccess_file, $htaccess);
|
| 1035 |
+
echo '<p style="color:red;">' . __('.htaccess file updated', 'gtranslate') . '</p>';
|
| 1036 |
}
|
| 1037 |
}
|
| 1038 |
+
} else {
|
| 1039 |
+
$rewrite_rules = file_get_contents(dirname(__FILE__) . '/url_addon/rewrite.txt');
|
| 1040 |
+
$rewrite_rules = str_replace('GTRANSLATE_PLUGIN_PATH', plugins_url() . '/gtranslate', $rewrite_rules);
|
| 1041 |
+
|
| 1042 |
+
echo '<p style="color:red;">' . __('Please add the following rules to the top of your .htaccess file', 'gtranslate') . '</p>';
|
| 1043 |
+
echo '<pre style="background-color:#eaeaea;">' . $rewrite_rules . '</pre>';
|
| 1044 |
}
|
| 1045 |
|
| 1046 |
// update main_lang in config.php
|
| 1049 |
$config = file_get_contents($config_file);
|
| 1050 |
$config = preg_replace('/\$main_lang = \'[a-z-]{2,5}\'/i', '$main_lang = \''.$data['default_language'].'\'', $config);
|
| 1051 |
file_put_contents($config_file, $config);
|
| 1052 |
+
} else {
|
| 1053 |
+
echo '<p style="color:red;">' . __('Cannot update gtranslate/url_addon/config.php file. Make sure to update it manually and set correct $main_lang.', 'gtranslate') . '</p>';
|
| 1054 |
}
|
| 1055 |
|
| 1056 |
} else { // todo: remove rewrite rules
|
| 1065 |
$data['new_window'] = isset($data['new_window']) ? $data['new_window'] : '';
|
| 1066 |
$data['show_in_menu'] = isset($data['show_in_menu']) ? $data['show_in_menu'] : ((isset($data['show_in_primary_menu']) and $data['show_in_primary_menu'] == 1) ? 'primary' : '');
|
| 1067 |
$data['floating_language_selector'] = isset($data['floating_language_selector']) ? $data['floating_language_selector'] : 'no';
|
| 1068 |
+
$data['native_language_names'] = isset($data['native_language_names']) ? $data['native_language_names'] : '';
|
| 1069 |
$data['analytics'] = isset($data['analytics']) ? $data['analytics'] : '';
|
|
|
|
| 1070 |
$data['add_new_line'] = isset($data['add_new_line']) ? $data['add_new_line'] : '1';
|
| 1071 |
+
|
| 1072 |
+
if(!isset($data['default_language'])) {
|
| 1073 |
+
$locale_map = array('af'=>'af','am'=>'am','arq'=>'ar','ar'=>'ar','ary'=>'ar','az'=>'az','az_TR'=>'az','azb'=>'az','bel'=>'be','bg_BG'=>'bg','bn_BD'=>'bn','bs_BA'=>'bs','ca'=>'ca','bal'=>'ca','ceb'=>'ceb','co'=>'co','cs_CZ'=>'cs','cy'=>'cy','da_DK'=>'da','de_DE'=>'de','de_CH'=>'de','gsw'=>'de','el'=>'el','en_AU'=>'en','en_CA'=>'en','en_NZ'=>'en','en_ZA'=>'en','en_GB'=>'en','eo'=>'eo','es_AR'=>'es','es_CL'=>'es','es_CO'=>'es','es_GT'=>'es','es_MX'=>'es','es_PE'=>'es','es_PR'=>'es','es_ES'=>'es','es_VE'=>'es','et'=>'et','eu'=>'eu','fa_IR'=>'fa','fa_AF'=>'fa','fi'=>'fi','fr_BE'=>'fr','fr_CA'=>'fr','fr_FR'=>'fr','fy'=>'fy','ga'=>'ga','gd'=>'gd','gl_ES'=>'gl','gu'=>'gu','hau'=>'ha','haw_US'=>'haw','hi_IN'=>'hi','hr'=>'hr','hat'=>'ht','hu_HU'=>'hu','hy'=>'hy','id_ID'=>'id','is_IS'=>'is','it_IT'=>'it','he_IL'=>'iw','ja'=>'ja','jv_ID'=>'jw','ka_GE'=>'ka','kk'=>'kk','km'=>'km','kn'=>'kn','ko_KR'=>'ko','ckb'=>'ku','kir'=>'ky','lb_LU'=>'lb','lo'=>'lo','lt_LT'=>'lt','lv'=>'lv','mg_MG'=>'mg','mri'=>'mi','mk_MK'=>'mk','ml_IN'=>'ml','mn'=>'mn','mr'=>'mr','ms_MY'=>'ms','my_MM'=>'my','ne_NP'=>'ne','nl_NL'=>'nl','nl_BE'=>'nl','nb_NO'=>'no','nn_NO'=>'no','pa_IN'=>'pa','pl_PL'=>'pl','ps'=>'ps','pt_BR'=>'pt','pt_PT'=>'pt','ro_RO'=>'ro','ru_RU'=>'ru','snd'=>'sd','si_LK'=>'si','sk_SK'=>'sk','sl_SI'=>'sl','so_SO'=>'so','sq'=>'sq','sr_RS'=>'sr','su_ID'=>'su','sv_SE'=>'sv','sw'=>'sw','ta_IN'=>'ta','ta_LK'=>'ta','te'=>'te','tg'=>'tg','th'=>'th','tr_TR'=>'tr','uk'=>'uk','ur'=>'ur','uz_UZ'=>'uz','vi'=>'vi','xho'=>'xh','yor'=>'yo','zh_CN'=>'zh-CN','zh_HK'=>'zh-CN','zh_TW'=>'zh-TW');
|
| 1074 |
+
$locale = get_locale();
|
| 1075 |
+
$data['default_language'] = isset($locale_map[$locale]) ? $locale_map[$locale] : 'en';
|
| 1076 |
+
}
|
| 1077 |
+
|
| 1078 |
$data['translation_method'] = isset($data['translation_method']) ? $data['translation_method'] : 'onfly';
|
| 1079 |
if($data['translation_method'] == 'on_fly') $data['translation_method'] = 'redirect';
|
| 1080 |
+
|
| 1081 |
$data['widget_look'] = isset($data['widget_look']) ? $data['widget_look'] : 'flags_dropdown';
|
| 1082 |
$data['flag_size'] = isset($data['flag_size']) ? $data['flag_size'] : '16';
|
| 1083 |
$data['widget_code'] = isset($data['widget_code']) ? $data['widget_code'] : '';
|
| 1377 |
}
|
| 1378 |
|
| 1379 |
}
|
| 1380 |
+
|
| 1381 |
+
if(is_admin()) {
|
| 1382 |
+
global $pagenow;
|
| 1383 |
+
|
| 1384 |
+
if(!defined('DOING_AJAX') or !DOING_AJAX)
|
| 1385 |
+
new GTranslate_Notices();
|
| 1386 |
+
}
|
| 1387 |
+
|
| 1388 |
+
$data = get_option('GTranslate');
|
| 1389 |
+
GTranslate::load_defaults($data);
|
| 1390 |
+
|
| 1391 |
+
if(!empty($data['show_in_menu'])) {
|
| 1392 |
+
add_filter('wp_nav_menu_items', 'gtranslate_menu_item', 10, 2);
|
| 1393 |
+
function gtranslate_menu_item($items, $args) {
|
| 1394 |
+
$data = get_option('GTranslate');
|
| 1395 |
+
GTranslate::load_defaults($data);
|
| 1396 |
+
|
| 1397 |
+
if($args->theme_location == $data['show_in_menu'])
|
| 1398 |
+
$items .= '<li style="position:relative;" class="menu-item menu-item-gtranslate"><div style="position:absolute;">'.GTranslate::get_widget_code(false).'</div></li>';
|
| 1399 |
+
return $items;
|
| 1400 |
+
}
|
| 1401 |
+
}
|
| 1402 |
+
|
| 1403 |
+
if($data['floating_language_selector'] != 'no' and !is_admin()) {
|
| 1404 |
+
add_action('wp_footer', 'gtranslate_display_floating');
|
| 1405 |
+
function gtranslate_display_floating() {
|
| 1406 |
+
$data = get_option('GTranslate');
|
| 1407 |
+
GTranslate::load_defaults($data);
|
| 1408 |
+
|
| 1409 |
+
if($data['widget_look'] == 'dropdown_with_flags')
|
| 1410 |
+
$vertical_location = '0';
|
| 1411 |
+
else
|
| 1412 |
+
$vertical_location = '5%';
|
| 1413 |
+
|
| 1414 |
+
switch($data['floating_language_selector']) {
|
| 1415 |
+
case 'top_left': $html = '<div style="position:fixed;top:'.$vertical_location.';left:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 1416 |
+
case 'top_right': $html = '<div style="position:fixed;top:'.$vertical_location.';right:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 1417 |
+
case 'bottom_left': $html = '<div style="position:fixed;bottom:'.$vertical_location.';left:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 1418 |
+
case 'bottom_right': $html = '<div style="position:fixed;bottom:'.$vertical_location.';right:8%;z-index:999999;">'.GTranslate::get_widget_code(false).'</div>'; break;
|
| 1419 |
+
default: $html = ''; break;
|
| 1420 |
+
}
|
| 1421 |
+
|
| 1422 |
+
echo $html;
|
| 1423 |
+
}
|
| 1424 |
+
}
|
| 1425 |
+
|
| 1426 |
+
if($data['url_translation'] and ($data['pro_version'] or $data['enterprise_version'])) {
|
| 1427 |
+
add_action('wp_head', 'gtranslate_url_translation_meta', 1);
|
| 1428 |
+
function gtranslate_url_translation_meta() {
|
| 1429 |
+
echo '<meta name="uri-translation" content="on" />';
|
| 1430 |
+
}
|
| 1431 |
+
}
|
native_names_map.php
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
$native_names_map = array(
|
| 3 |
+
'af' => 'Afrikaans',
|
| 4 |
+
'sq' => 'Shqip',
|
| 5 |
+
'am' => 'አማርኛ',
|
| 6 |
+
'ar' => 'العربية',
|
| 7 |
+
'hy' => 'Հայերեն',
|
| 8 |
+
'az' => 'Azərbaycan dili',
|
| 9 |
+
'eu' => 'Euskara',
|
| 10 |
+
'be' => 'Беларуская мова',
|
| 11 |
+
'bn' => 'বাংলা',
|
| 12 |
+
'bs' => 'Bosanski',
|
| 13 |
+
'bg' => 'Български',
|
| 14 |
+
'ca' => 'Català',
|
| 15 |
+
'ceb' => 'Cebuano',
|
| 16 |
+
'ny' => 'Chichewa',
|
| 17 |
+
'zh-CN' => '简体中文',
|
| 18 |
+
'zh-TW' => '繁體中文',
|
| 19 |
+
'co' => 'Corsu',
|
| 20 |
+
'hr' => 'Hrvatski',
|
| 21 |
+
'cs' => 'Čeština',
|
| 22 |
+
'da' => 'Dansk',
|
| 23 |
+
'nl' => 'Nederlands',
|
| 24 |
+
'en' => 'English',
|
| 25 |
+
'eo' => 'Esperanto',
|
| 26 |
+
'et' => 'Eesti',
|
| 27 |
+
'tl' => 'Filipino',
|
| 28 |
+
'fi' => 'Suomi',
|
| 29 |
+
'fr' => 'Français',
|
| 30 |
+
'fy' => 'Frysk',
|
| 31 |
+
'gl' => 'Galego',
|
| 32 |
+
'ka' => 'ქართული',
|
| 33 |
+
'de' => 'Deutsch',
|
| 34 |
+
'el' => 'Greek',
|
| 35 |
+
'gu' => 'ગુજરાતી',
|
| 36 |
+
'ht' => 'Kreyol ayisyen',
|
| 37 |
+
'ha' => 'Harshen Hausa',
|
| 38 |
+
'haw' => 'Ōlelo Hawaiʻi',
|
| 39 |
+
'iw' => 'עִבְרִית',
|
| 40 |
+
'hi' => 'हिन्दी',
|
| 41 |
+
'hmn' => 'Hmong',
|
| 42 |
+
'hu' => 'Magyar',
|
| 43 |
+
'is' => 'Íslenska',
|
| 44 |
+
'ig' => 'Igbo',
|
| 45 |
+
'id' => 'Bahasa Indonesia',
|
| 46 |
+
'ga' => 'Gaelige',
|
| 47 |
+
'it' => 'Italiano',
|
| 48 |
+
'ja' => '日本語',
|
| 49 |
+
'jw' => 'Basa Jawa',
|
| 50 |
+
'kn' => 'ಕನ್ನಡ',
|
| 51 |
+
'kk' => 'Қазақ тілі',
|
| 52 |
+
'km' => 'ភាសាខ្មែរ',
|
| 53 |
+
'ko' => '한국어',
|
| 54 |
+
'ku' => 'كوردی',
|
| 55 |
+
'ky' => 'Кыргызча',
|
| 56 |
+
'lo' => 'ພາສາລາວ',
|
| 57 |
+
'la' => 'Latin',
|
| 58 |
+
'lv' => 'Latviešu valoda',
|
| 59 |
+
'lt' => 'Lietuvių kalba',
|
| 60 |
+
'lb' => 'Lëtzebuergesch',
|
| 61 |
+
'mk' => 'Македонски јазик',
|
| 62 |
+
'mg' => 'Malagasy',
|
| 63 |
+
'ms' => 'Bahasa Melayu',
|
| 64 |
+
'ml' => 'മലയാളം',
|
| 65 |
+
'mt' => 'Maltese',
|
| 66 |
+
'mi' => 'Te Reo Māori',
|
| 67 |
+
'mr' => 'मराठी',
|
| 68 |
+
'mn' => 'Монгол',
|
| 69 |
+
'my' => 'ဗမာစာ',
|
| 70 |
+
'ne' => 'नेपाली',
|
| 71 |
+
'no' => 'Norsk bokmål',
|
| 72 |
+
'ps' => 'پښتو',
|
| 73 |
+
'fa' => 'فارسی',
|
| 74 |
+
'pl' => 'Polski',
|
| 75 |
+
'pt' => 'Português',
|
| 76 |
+
'pa' => 'ਪੰਜਾਬੀ',
|
| 77 |
+
'ro' => 'Română',
|
| 78 |
+
'ru' => 'Русский',
|
| 79 |
+
'sm' => 'Samoan',
|
| 80 |
+
'gd' => 'Gàidhlig',
|
| 81 |
+
'sr' => 'Српски језик',
|
| 82 |
+
'st' => 'Sesotho',
|
| 83 |
+
'sn' => 'Shona',
|
| 84 |
+
'sd' => 'سنڌي',
|
| 85 |
+
'si' => 'සිංහල',
|
| 86 |
+
'sk' => 'Slovenčina',
|
| 87 |
+
'sl' => 'Slovenščina',
|
| 88 |
+
'so' => 'Afsoomaali',
|
| 89 |
+
'es' => 'Español',
|
| 90 |
+
'su' => 'Basa Sunda',
|
| 91 |
+
'sw' => 'Kiswahili',
|
| 92 |
+
'sv' => 'Svenska',
|
| 93 |
+
'tg' => 'Тоҷикӣ',
|
| 94 |
+
'ta' => 'தமிழ்',
|
| 95 |
+
'te' => 'తెలుగు',
|
| 96 |
+
'th' => 'ไทย',
|
| 97 |
+
'tr' => 'Türkçe',
|
| 98 |
+
'uk' => 'Українська',
|
| 99 |
+
'ur' => 'اردو',
|
| 100 |
+
'uz' => 'O‘zbekcha',
|
| 101 |
+
'vi' => 'Tiếng Việt',
|
| 102 |
+
'cy' => 'Cymraeg',
|
| 103 |
+
'xh' => 'isiXhosa',
|
| 104 |
+
'yi' => 'יידיש',
|
| 105 |
+
'yo' => 'Yorùbá',
|
| 106 |
+
'zu' => 'Zulu'
|
| 107 |
+
);
|
readme.txt
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
=== Translate Wordpress with GTranslate ===
|
| 2 |
Contributors: edo888
|
| 3 |
Author: Edvard Ananyan
|
| 4 |
-
Tags: translation proxy, localization, translate, translation,
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 4.7
|
| 7 |
-
Stable tag: 2.8.
|
| 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
|
|
@@ -33,7 +33,8 @@ Please check our [FAQ](https://gtranslate.io/?xyz=998#faq) to get quick answers.
|
|
| 33 |
* Google language translator widget
|
| 34 |
* Available styles Dropdown/Flags/Flags with dropdown/Nice dropdown with flags/Globe
|
| 35 |
* Floating language selector
|
| 36 |
-
*
|
|
|
|
| 37 |
* Alternative for WPML, qtranslate, transposh, loco translate and polylang
|
| 38 |
* (paid) You can manually correct translations
|
| 39 |
* (paid) You can have sub-directory (example.com/**es**/) or sub-domain (**es.**example.com) URL structure
|
|
@@ -410,6 +411,12 @@ You need to go to the language you want to edit, for instance, French: http://do
|
|
| 410 |
|
| 411 |
== Changelog ==
|
| 412 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 413 |
= 2.8.4 =
|
| 414 |
* New option to select in which menu the selector should appear
|
| 415 |
|
| 1 |
=== Translate Wordpress with GTranslate ===
|
| 2 |
Contributors: edo888
|
| 3 |
Author: Edvard Ananyan
|
| 4 |
+
Tags: translation proxy, localization, translate, translation, google translate, language, multilingual, multilanguage, bilingual, tradurre, traducir, traduire, traduzione, ubersetzung, mehrsprachig, oversette, oversatta, vertaling, vertaler, meertalig, polylang, qtranslate, transposh, wpml
|
| 5 |
Requires at least: 2.8
|
| 6 |
Tested up to: 4.7
|
| 7 |
+
Stable tag: 2.8.5
|
| 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
|
| 33 |
* Google language translator widget
|
| 34 |
* Available styles Dropdown/Flags/Flags with dropdown/Nice dropdown with flags/Globe
|
| 35 |
* Floating language selector
|
| 36 |
+
* Language bar in menu
|
| 37 |
+
* Multilanguage
|
| 38 |
* Alternative for WPML, qtranslate, transposh, loco translate and polylang
|
| 39 |
* (paid) You can manually correct translations
|
| 40 |
* (paid) You can have sub-directory (example.com/**es**/) or sub-domain (**es.**example.com) URL structure
|
| 411 |
|
| 412 |
== Changelog ==
|
| 413 |
|
| 414 |
+
= 2.8.5 =
|
| 415 |
+
* Show languages in their native names
|
| 416 |
+
* Automatically select default language based on wordpress locale
|
| 417 |
+
* Coding issue with PHP Strict Standards and Fatal Error on some PHP versions fixed
|
| 418 |
+
* Error messages more informative
|
| 419 |
+
|
| 420 |
= 2.8.4 =
|
| 421 |
* New option to select in which menu the selector should appear
|
| 422 |
|
