Version Description
- New feature: auto switch language based on browser language settigns
- Minor fixes: Greek name in native alphabet, Flag size option for Globe Widget look, vertical position in pixels
Download this release
Release Info
Developer | edo888 |
Plugin | Translate WordPress with GTranslate |
Version | 2.8.32 |
Comparing to | |
See all releases |
Code changes from version 2.8.34 to 2.8.32
- 24/Morocco.png +0 -0
- {globe_flags_24 → 24}/af.png +0 -0
- {globe_flags_24 → 24}/am.png +0 -0
- {globe_flags_24 → 24}/ar.png +0 -0
- {globe_flags_24 → 24}/az.png +0 -0
- {globe_flags_24 → 24}/be.png +0 -0
- {globe_flags_24 → 24}/bg.png +0 -0
- {globe_flags_24 → 24}/bn.png +0 -0
- {globe_flags_24 → 24}/bs.png +0 -0
- {globe_flags_24 → 24}/ca.png +0 -0
- {globe_flags_24 → 24}/ceb.png +0 -0
- {globe_flags_24 → 24}/co.png +0 -0
- {globe_flags_24 → 24}/cs.png +0 -0
- {globe_flags_24 → 24}/cy.png +0 -0
- {globe_flags_24 → 24}/da.png +0 -0
- {globe_flags_24 → 24}/de.png +0 -0
- {globe_flags_24 → 24}/el.png +0 -0
- {globe_flags_24 → 24}/en-us.png +0 -0
- {globe_flags_24 → 24}/en.png +0 -0
- {globe_flags_24 → 24}/eo.png +0 -0
- {globe_flags_24 → 24}/es-mx.png +0 -0
- {globe_flags_24 → 24}/es.png +0 -0
- {globe_flags_24 → 24}/et.png +0 -0
- {globe_flags_24 → 24}/eu.png +0 -0
- {globe_flags_24 → 24}/fa.png +0 -0
- {globe_flags_24 → 24}/fi.png +0 -0
- {globe_flags_24 → 24}/fr.png +0 -0
- {globe_flags_24 → 24}/fy.png +0 -0
- {globe_flags_24 → 24}/ga.png +0 -0
- {globe_flags_24 → 24}/gd.png +0 -0
- {globe_flags_24 → 24}/gl.png +0 -0
- {globe_flags_24 → 24}/gu.png +0 -0
- {globe_flags_24 → 24}/ha.png +0 -0
- {globe_flags_24 → 24}/haw.png +0 -0
- {globe_flags_24 → 24}/hi.png +0 -0
- {globe_flags_24 → 24}/hmn.png +0 -0
- {globe_flags_24 → 24}/hr.png +0 -0
- {globe_flags_24 → 24}/ht.png +0 -0
- {globe_flags_24 → 24}/hu.png +0 -0
- {globe_flags_24 → 24}/hy.png +0 -0
- {globe_flags_24 → 24}/id.png +0 -0
- {globe_flags_24 → 24}/ig.png +0 -0
- {globe_flags_24 → 24}/is.png +0 -0
- {globe_flags_24 → 24}/it.png +0 -0
- {globe_flags_24 → 24}/iw.png +0 -0
- {globe_flags_24 → 24}/ja.png +0 -0
- {globe_flags_24 → 24}/jw.png +0 -0
- {globe_flags_24 → 24}/ka.png +0 -0
- {globe_flags_24 → 24}/kk.png +0 -0
- {globe_flags_24 → 24}/km.png +0 -0
- {globe_flags_24 → 24}/kn.png +0 -0
- {globe_flags_24 → 24}/ko.png +0 -0
- {globe_flags_24 → 24}/ku.png +0 -0
- {globe_flags_24 → 24}/ky.png +0 -0
- {globe_flags_24 → 24}/la.png +0 -0
- {globe_flags_24 → 24}/lb.png +0 -0
- {globe_flags_24 → 24}/lo.png +0 -0
- {globe_flags_24 → 24}/lt.png +0 -0
- {globe_flags_24 → 24}/lv.png +0 -0
- {globe_flags_24 → 24}/mg.png +0 -0
- {globe_flags_24 → 24}/mi.png +0 -0
- {globe_flags_24 → 24}/mk.png +0 -0
- {globe_flags_24 → 24}/ml.png +0 -0
- {globe_flags_24 → 24}/mn.png +0 -0
- {globe_flags_24 → 24}/mr.png +0 -0
- {globe_flags_24 → 24}/ms.png +0 -0
- {globe_flags_24 → 24}/mt.png +0 -0
- {globe_flags_24 → 24}/my.png +0 -0
- {globe_flags_24 → 24}/ne.png +0 -0
- {globe_flags_24 → 24}/nl.png +0 -0
- {globe_flags_24 → 24}/no.png +0 -0
- {globe_flags_24 → 24}/ny.png +0 -0
- {globe_flags_24 → 24}/pa.png +0 -0
- {globe_flags_24 → 24}/pl.png +0 -0
- {globe_flags_24 → 24}/ps.png +0 -0
- {globe_flags_24 → 24}/pt-br.png +0 -0
- {globe_flags_24 → 24}/pt.png +0 -0
- {globe_flags_24 → 24}/ro.png +0 -0
- {globe_flags_24 → 24}/ru.png +0 -0
- {globe_flags_24 → 24}/sd.png +0 -0
- {globe_flags_24 → 24}/si.png +0 -0
- {globe_flags_24 → 24}/sk.png +0 -0
- {globe_flags_24 → 24}/sl.png +0 -0
- {globe_flags_24 → 24}/sm.png +0 -0
- {globe_flags_24 → 24}/sn.png +0 -0
- {globe_flags_24 → 24}/so.png +0 -0
- {globe_flags_24 → 24}/sq.png +0 -0
- {globe_flags_24 → 24}/sr.png +0 -0
- {globe_flags_24 → 24}/st.png +0 -0
- {globe_flags_24 → 24}/su.png +0 -0
- {globe_flags_24 → 24}/sv.png +0 -0
- {globe_flags_24 → 24}/sw.png +0 -0
- {globe_flags_24 → 24}/ta.png +0 -0
- {globe_flags_24 → 24}/te.png +0 -0
- {globe_flags_24 → 24}/tg.png +0 -0
- {globe_flags_24 → 24}/th.png +0 -0
- {globe_flags_24 → 24}/tl.png +0 -0
- {globe_flags_24 → 24}/tr.png +0 -0
- {globe_flags_24 → 24}/uk.png +0 -0
- {globe_flags_24 → 24}/ur.png +0 -0
- {globe_flags_24 → 24}/uz.png +0 -0
- {globe_flags_24 → 24}/vi.png +0 -0
- {globe_flags_24 → 24}/xh.png +0 -0
- {globe_flags_24 → 24}/yi.png +0 -0
- {globe_flags_24 → 24}/yo.png +0 -0
- {globe_flags_24 → 24}/zh-CN.png +0 -0
- {globe_flags_24 → 24}/zh-TW.png +0 -0
- {globe_flags_24 → 24}/zu.png +0 -0
- gtranslate.php +6 -6
- readme.txt +1 -8
- url_addon/gtranslate.php +222 -232
24/Morocco.png
ADDED
Binary file
|
{globe_flags_24 → 24}/af.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/am.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ar.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/az.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/be.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/bg.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/bn.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/bs.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ca.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ceb.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/co.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/cs.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/cy.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/da.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/de.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/el.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/en-us.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/en.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/eo.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/es-mx.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/es.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/et.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/eu.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/fa.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/fi.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/fr.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/fy.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ga.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/gd.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/gl.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/gu.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ha.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/haw.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/hi.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/hmn.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/hr.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ht.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/hu.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/hy.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/id.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ig.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/is.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/it.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/iw.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ja.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/jw.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ka.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/kk.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/km.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/kn.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ko.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ku.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ky.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/la.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/lb.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/lo.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/lt.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/lv.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/mg.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/mi.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/mk.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ml.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/mn.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/mr.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ms.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/mt.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/my.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ne.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/nl.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/no.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ny.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/pa.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/pl.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ps.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/pt-br.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/pt.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ro.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ru.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sd.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/si.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sk.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sl.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sm.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sn.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/so.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sq.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sr.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/st.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/su.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sv.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/sw.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ta.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/te.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/tg.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/th.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/tl.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/tr.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/uk.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/ur.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/uz.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/vi.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/xh.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/yi.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/yo.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/zh-CN.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/zh-TW.png
RENAMED
File without changes
|
{globe_flags_24 → 24}/zu.png
RENAMED
File without changes
|
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.
|
7 |
Author: Translate AI Multilingual Solutions
|
8 |
Author URI: https://gtranslate.io
|
9 |
Text Domain: gtranslate
|
@@ -492,7 +492,7 @@ function RefreshDoWidgetCode() {
|
|
492 |
widget_preview += 'var x, y, angle;'+new_line;
|
493 |
widget_preview += 'do {if (j + 1 > Math.round(2 * r0 * Math.PI / d) * (nc + 1) * (nc + 2) / 2) {nc++;r = r + r0;cntpc = Math.floor(2 * Math.PI * r / d);}angle = j * 2 * Math.PI / cntpc + Math.PI / 4;x = centerPosition.left + Math.cos(angle) * r;y = centerPosition.top + Math.sin(angle) * r;'+new_line;
|
494 |
widget_preview += "var positionGSatelites = ($('.gsatelites').parent().css('position') == 'fixed' ? $('.gsatelites').parent().position() : $('.gsatelites').offset()),vpHeight = $(window).height(),vpWidth = $(window).width(),tpViz = positionGSatelites.top + y >= 0 && positionGSatelites.top + y < vpHeight,btViz = positionGSatelites.top + y + 24 > 0 && positionGSatelites.top + y + 24 <= vpHeight,ltViz = positionGSatelites.left + x >= 0 && positionGSatelites.left + x < vpWidth,rtViz = positionGSatelites.left + x + 24 > 0 && positionGSatelites.left + x + 24 <= vpWidth,vVisible = tpViz && btViz,hVisible = ltViz && rtViz;if (vVisible && hVisible) {break;} else {j++;}} while (j - i < 10 * count);"+new_line;
|
495 |
-
widget_preview += "$('.gsatelites').append('<span class=\"gsatelite gs' + (i + 1) + ' glang_' + language_codes2[i] + '\" onclick=\"doGTranslate("+"\\\\'"+default_language+"|'+language_codes2[i]+'"+"\\\\'"+")\" title=\"' + languages[i] + '\" style=\"background-image:url($wp_plugin_url/
|
496 |
widget_preview += "$('.gs' + (i + 1)).delay((i + 1) * 10).fadeIn('fast');"+new_line;
|
497 |
widget_preview += '}}'+new_line;
|
498 |
widget_preview += "function hideGSatelites($) { $('.gsatelite').each(function(i) { $(this).delay(($('.gsatelite').length - i - 1) * 10).fadeOut('fast');});}"+new_line;
|
@@ -727,14 +727,14 @@ function RefreshDoWidgetCode() {
|
|
727 |
} else if(enterprise_version && translation_method == 'redirect' && new_window) {
|
728 |
widget_code += "function openTab(url) {var form=document.createElement('form');form.method='post';form.action=url;form.target='_blank';document.body.appendChild(form);form.submit();}"+new_line;
|
729 |
if(analytics)
|
730 |
-
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.hostname+location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '
|
731 |
else
|
732 |
-
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '
|
733 |
} else if(enterprise_version && translation_method == 'redirect') {
|
734 |
if(analytics)
|
735 |
-
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.hostname+location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';location.href=location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '
|
736 |
else
|
737 |
-
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';location.href=location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '
|
738 |
} else if(translation_method == 'onfly') {
|
739 |
widget_code += "function GTranslateGetCurrentLang() {var keyValue = document['cookie'].match('(^|;) ?googtrans=([^;]*)(;|$)');return keyValue ? keyValue[2].split('/')[2] : null;}"+new_line;
|
740 |
widget_code += "function GTranslateFireEvent(element,event){try{if(document.createEventObject){var evt=document.createEventObject();element.fireEvent('on'+event,evt)}else{var evt=document.createEvent('HTMLEvents');evt.initEvent(event,true,true);element.dispatchEvent(evt)}}catch(e){}}"+new_line;
|
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.32
|
7 |
Author: Translate AI Multilingual Solutions
|
8 |
Author URI: https://gtranslate.io
|
9 |
Text Domain: gtranslate
|
492 |
widget_preview += 'var x, y, angle;'+new_line;
|
493 |
widget_preview += 'do {if (j + 1 > Math.round(2 * r0 * Math.PI / d) * (nc + 1) * (nc + 2) / 2) {nc++;r = r + r0;cntpc = Math.floor(2 * Math.PI * r / d);}angle = j * 2 * Math.PI / cntpc + Math.PI / 4;x = centerPosition.left + Math.cos(angle) * r;y = centerPosition.top + Math.sin(angle) * r;'+new_line;
|
494 |
widget_preview += "var positionGSatelites = ($('.gsatelites').parent().css('position') == 'fixed' ? $('.gsatelites').parent().position() : $('.gsatelites').offset()),vpHeight = $(window).height(),vpWidth = $(window).width(),tpViz = positionGSatelites.top + y >= 0 && positionGSatelites.top + y < vpHeight,btViz = positionGSatelites.top + y + 24 > 0 && positionGSatelites.top + y + 24 <= vpHeight,ltViz = positionGSatelites.left + x >= 0 && positionGSatelites.left + x < vpWidth,rtViz = positionGSatelites.left + x + 24 > 0 && positionGSatelites.left + x + 24 <= vpWidth,vVisible = tpViz && btViz,hVisible = ltViz && rtViz;if (vVisible && hVisible) {break;} else {j++;}} while (j - i < 10 * count);"+new_line;
|
495 |
+
widget_preview += "$('.gsatelites').append('<span class=\"gsatelite gs' + (i + 1) + ' glang_' + language_codes2[i] + '\" onclick=\"doGTranslate("+"\\\\'"+default_language+"|'+language_codes2[i]+'"+"\\\\'"+")\" title=\"' + languages[i] + '\" style=\"background-image:url($wp_plugin_url/24/' + (function(l){if(l == 'en' && us_flag)return 'en-us';if(l == 'pt' && br_flag)return 'pt-br';if(l == 'es' && mx_flag)return 'es-mx';return l;})(language_codes2[i]) + '.png);left:' + x + 'px;top:' + y + 'px;\"></span>');"+new_line;
|
496 |
widget_preview += "$('.gs' + (i + 1)).delay((i + 1) * 10).fadeIn('fast');"+new_line;
|
497 |
widget_preview += '}}'+new_line;
|
498 |
widget_preview += "function hideGSatelites($) { $('.gsatelite').each(function(i) { $(this).delay(($('.gsatelite').length - i - 1) * 10).fadeOut('fast');});}"+new_line;
|
727 |
} else if(enterprise_version && translation_method == 'redirect' && new_window) {
|
728 |
widget_code += "function openTab(url) {var form=document.createElement('form');form.method='post';form.action=url;form.target='_blank';document.body.appendChild(form);form.submit();}"+new_line;
|
729 |
if(analytics)
|
730 |
+
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.hostname+location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '\\\\\\\\.'), '')+gt_request_uri);}"+new_line;
|
731 |
else
|
732 |
+
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';openTab(location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '\\\\\\\\.'), '')+gt_request_uri);}"+new_line;
|
733 |
} else if(enterprise_version && translation_method == 'redirect') {
|
734 |
if(analytics)
|
735 |
+
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];if(typeof _gaq!='undefined'){_gaq.push(['_trackEvent', 'GTranslate', lang, location.hostname+location.pathname+location.search]);}else {if(typeof ga!='undefined')ga('send', 'event', 'GTranslate', lang, location.hostname+location.pathname+location.search);}var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';location.href=location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '\\\\\\\\.'), '')+gt_request_uri;}"+new_line;
|
736 |
else
|
737 |
+
widget_code += "function doGTranslate(lang_pair) {if(lang_pair.value)lang_pair=lang_pair.value;if(lang_pair=='')return;var lang=lang_pair.split('|')[1];var plang=location.hostname.split('.')[0];if(plang.length !=2 && plang.toLowerCase() != 'zh-cn' && plang.toLowerCase() != 'zh-tw' && plang != 'hmn' && plang != 'haw' && plang != 'ceb')plang='"+default_language+"';location.href=location.protocol+'//'+(lang == '"+default_language+"' ? '' : lang+'.')+location.hostname.replace('www.', '').replace(RegExp('^' + plang + '\\\\\\\\.'), '')+gt_request_uri;}"+new_line;
|
738 |
} else if(translation_method == 'onfly') {
|
739 |
widget_code += "function GTranslateGetCurrentLang() {var keyValue = document['cookie'].match('(^|;) ?googtrans=([^;]*)(;|$)');return keyValue ? keyValue[2].split('/')[2] : null;}"+new_line;
|
740 |
widget_code += "function GTranslateFireEvent(element,event){try{if(document.createEventObject){var evt=document.createEventObject();element.fireEvent('on'+event,evt)}else{var evt=document.createEvent('HTMLEvents');evt.initEvent(event,true,true);element.dispatchEvent(evt)}}catch(e){}}"+new_line;
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Author: Translate AI Multilingual Solutions
|
|
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.9
|
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
|
@@ -219,13 +219,6 @@ You need to go to the language you want to edit, for instance, French: http://do
|
|
219 |
|
220 |
== Changelog ==
|
221 |
|
222 |
-
= 2.8.34 =
|
223 |
-
* Fixed update issue related to bug in new WP 4.9 flatten_dirlist function. Important: If you are using Globe widget look, make sure to open GTranslate settings page, click "Reset Code to Default" under Widget Code section and Save.
|
224 |
-
|
225 |
-
= 2.8.33 =
|
226 |
-
* Fixed issue related to new version of Contact Form 7
|
227 |
-
* Ready for WordPress 4.9
|
228 |
-
|
229 |
= 2.8.32 =
|
230 |
* New feature: auto switch language based on browser language settigns
|
231 |
* Minor fixes: Greek name in native alphabet, Flag size option for Globe Widget look, vertical position in pixels
|
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.9
|
7 |
+
Stable tag: 2.8.32
|
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
|
219 |
|
220 |
== Changelog ==
|
221 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
= 2.8.32 =
|
223 |
* New feature: auto switch language based on browser language settigns
|
224 |
* Minor fixes: Greek name in native alphabet, Flag size option for Globe Widget look, vertical position in pixels
|
url_addon/gtranslate.php
CHANGED
@@ -1,232 +1,222 @@
|
|
1 |
-
<?php
|
2 |
-
error_reporting(0);
|
3 |
-
|
4 |
-
include 'config.php';
|
5 |
-
|
6 |
-
if(!isset($_GET['glang']) or !isset($_GET['gurl']))
|
7 |
-
exit;
|
8 |
-
|
9 |
-
$glang = $_GET['glang'];
|
10 |
-
|
11 |
-
// pick a server based on hostname
|
12 |
-
$server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
|
13 |
-
$server = $servers[$server_id];
|
14 |
-
|
15 |
-
$page_url = '/'.$_GET['gurl'];
|
16 |
-
|
17 |
-
$page_url_segments = explode('/', $page_url);
|
18 |
-
foreach($page_url_segments as $i => $segment) {
|
19 |
-
$page_url_segments[$i] = rawurlencode($segment);
|
20 |
-
}
|
21 |
-
$page_url = implode('/', $page_url_segments);
|
22 |
-
|
23 |
-
$get_params = $_GET;
|
24 |
-
if(isset($get_params['glang']))
|
25 |
-
unset($get_params['glang']);
|
26 |
-
if(isset($get_params['gurl']))
|
27 |
-
unset($get_params['gurl']);
|
28 |
-
|
29 |
-
if(count($get_params)) {
|
30 |
-
$page_url .= '?' . http_build_query($get_params);
|
31 |
-
}
|
32 |
-
|
33 |
-
$main_lang = isset($data['default_language']) ? $data['default_language'] : $main_lang;
|
34 |
-
|
35 |
-
if($glang == $main_lang) {
|
36 |
-
$page_url = preg_replace('/^[\/]+/', '/', $page_url);
|
37 |
-
|
38 |
-
header('Location: ' . $page_url, true, 301);
|
39 |
-
exit;
|
40 |
-
}
|
41 |
-
|
42 |
-
$page_url = $server.'.tdn.gtranslate.net' . $page_url;
|
43 |
-
|
44 |
-
$protocol = ((isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS'] == 'on' or $_SERVER['HTTPS'] == 1)) or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http';
|
45 |
-
$page_url = $protocol . '://' . $page_url;
|
46 |
-
|
47 |
-
if(!in_array(strtolower($glang), array('en','ar','bg','zh-cn','zh-tw','hr','cs','da','nl','fi','fr','de','el','hi','it','ja','ko','no','pl','pt','ro','ru','es','sv','ca','tl','iw','id','lv','lt','sr','sk','sl','uk','vi','sq','et','gl','hu','mt','th','tr','fa','af','ms','sw','ga','cy','be','is','mk','yi','hy','az','eu','ka','ht','ur','bn','bs','ceb','eo','gu','ha','hmn','ig','jw','kn','km','lo','la','mi','mr','mn','ne','pa','so','ta','te','yo','zu','my','ny','kk','mg','ml','si','st','su','tg','uz','am','co','haw','ku','ky','lb','ps','sm','gd','sn','sd','fy','xh')))
|
48 |
-
exit;
|
49 |
-
|
50 |
-
if(!function_exists("getallheaders")) {
|
51 |
-
//Adapted from http://www.php.net/manual/en/function.getallheaders.php#99814
|
52 |
-
function getallheaders() {
|
53 |
-
$result = array();
|
54 |
-
foreach($_SERVER as $key => $value) {
|
55 |
-
if (substr($key, 0, 5) == "HTTP_") {
|
56 |
-
$key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
|
57 |
-
$result[$key] = $value;
|
58 |
-
} else if ($key == "CONTENT_TYPE") {
|
59 |
-
$result["Content-Type"] = $value;
|
60 |
-
}
|
61 |
-
}
|
62 |
-
return $result;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
|
66 |
-
$request_headers = getallheaders();
|
67 |
-
|
68 |
-
if(isset($request_headers['X-GT-Lang']) or isset($request_headers['X-Gt-Lang']) or isset($request_headers['x-gt-lang'])) {
|
69 |
-
echo 'Please remove DNS cname records for GTranslate!';
|
70 |
-
exit;
|
71 |
-
}
|
72 |
-
|
73 |
-
$host = $glang . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
|
74 |
-
$request_headers['Host'] = $host;
|
75 |
-
if(isset($request_headers['HOST'])) unset($request_headers['HOST']);
|
76 |
-
if(isset($request_headers['host'])) unset($request_headers['host']);
|
77 |
-
|
78 |
-
if(!function_exists('gzdecode'))
|
79 |
-
$request_headers['Accept-Encoding'] = '';
|
80 |
-
else
|
81 |
-
$request_headers['Accept-Encoding'] = 'gzip';
|
82 |
-
|
83 |
-
if(isset($request_headers['accept-encoding'])) unset($request_headers['accept-encoding']);
|
84 |
-
|
85 |
-
if(isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
|
86 |
-
$request_headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
|
87 |
-
if(isset($request_headers['authorization'])) unset($request_headers['authorization']);
|
88 |
-
}
|
89 |
-
//print_r($request_headers);
|
90 |
-
//exit;
|
91 |
-
|
92 |
-
if(isset($request_headers['
|
93 |
-
$request_headers['Content-Type'] =
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
$ch
|
119 |
-
|
120 |
-
|
121 |
-
curl_setopt($ch,
|
122 |
-
|
123 |
-
curl_setopt($ch,
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
case '
|
128 |
-
curl_setopt($ch,
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
$
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
$
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
$
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
$html
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
$html =
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
}
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
foreach($arrays AS $key => $value) {
|
225 |
-
$k = isset($prefix) ? $prefix . '[' . $key . ']' : $key;
|
226 |
-
if(is_array($value) or is_object($value)) {
|
227 |
-
http_build_query_for_curl($value, $new, $k);
|
228 |
-
} else {
|
229 |
-
$new[$k] = $value;
|
230 |
-
}
|
231 |
-
}
|
232 |
-
}
|
1 |
+
<?php
|
2 |
+
error_reporting(0);
|
3 |
+
|
4 |
+
include 'config.php';
|
5 |
+
|
6 |
+
if(!isset($_GET['glang']) or !isset($_GET['gurl']))
|
7 |
+
exit;
|
8 |
+
|
9 |
+
$glang = $_GET['glang'];
|
10 |
+
|
11 |
+
// pick a server based on hostname
|
12 |
+
$server_id = intval(substr(md5(preg_replace('/^www\./', '', $_SERVER['HTTP_HOST'])), 0, 5), 16) % count($servers);
|
13 |
+
$server = $servers[$server_id];
|
14 |
+
|
15 |
+
$page_url = '/'.$_GET['gurl'];
|
16 |
+
|
17 |
+
$page_url_segments = explode('/', $page_url);
|
18 |
+
foreach($page_url_segments as $i => $segment) {
|
19 |
+
$page_url_segments[$i] = rawurlencode($segment);
|
20 |
+
}
|
21 |
+
$page_url = implode('/', $page_url_segments);
|
22 |
+
|
23 |
+
$get_params = $_GET;
|
24 |
+
if(isset($get_params['glang']))
|
25 |
+
unset($get_params['glang']);
|
26 |
+
if(isset($get_params['gurl']))
|
27 |
+
unset($get_params['gurl']);
|
28 |
+
|
29 |
+
if(count($get_params)) {
|
30 |
+
$page_url .= '?' . http_build_query($get_params);
|
31 |
+
}
|
32 |
+
|
33 |
+
$main_lang = isset($data['default_language']) ? $data['default_language'] : $main_lang;
|
34 |
+
|
35 |
+
if($glang == $main_lang) {
|
36 |
+
$page_url = preg_replace('/^[\/]+/', '/', $page_url);
|
37 |
+
|
38 |
+
header('Location: ' . $page_url, true, 301);
|
39 |
+
exit;
|
40 |
+
}
|
41 |
+
|
42 |
+
$page_url = $server.'.tdn.gtranslate.net' . $page_url;
|
43 |
+
|
44 |
+
$protocol = ((isset($_SERVER['HTTPS']) and ($_SERVER['HTTPS'] == 'on' or $_SERVER['HTTPS'] == 1)) or (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https' : 'http';
|
45 |
+
$page_url = $protocol . '://' . $page_url;
|
46 |
+
|
47 |
+
if(!in_array(strtolower($glang), array('en','ar','bg','zh-cn','zh-tw','hr','cs','da','nl','fi','fr','de','el','hi','it','ja','ko','no','pl','pt','ro','ru','es','sv','ca','tl','iw','id','lv','lt','sr','sk','sl','uk','vi','sq','et','gl','hu','mt','th','tr','fa','af','ms','sw','ga','cy','be','is','mk','yi','hy','az','eu','ka','ht','ur','bn','bs','ceb','eo','gu','ha','hmn','ig','jw','kn','km','lo','la','mi','mr','mn','ne','pa','so','ta','te','yo','zu','my','ny','kk','mg','ml','si','st','su','tg','uz','am','co','haw','ku','ky','lb','ps','sm','gd','sn','sd','fy','xh')))
|
48 |
+
exit;
|
49 |
+
|
50 |
+
if(!function_exists("getallheaders")) {
|
51 |
+
//Adapted from http://www.php.net/manual/en/function.getallheaders.php#99814
|
52 |
+
function getallheaders() {
|
53 |
+
$result = array();
|
54 |
+
foreach($_SERVER as $key => $value) {
|
55 |
+
if (substr($key, 0, 5) == "HTTP_") {
|
56 |
+
$key = str_replace(" ", "-", ucwords(strtolower(str_replace("_", " ", substr($key, 5)))));
|
57 |
+
$result[$key] = $value;
|
58 |
+
} else if ($key == "CONTENT_TYPE") {
|
59 |
+
$result["Content-Type"] = $value;
|
60 |
+
}
|
61 |
+
}
|
62 |
+
return $result;
|
63 |
+
}
|
64 |
+
}
|
65 |
+
|
66 |
+
$request_headers = getallheaders();
|
67 |
+
|
68 |
+
if(isset($request_headers['X-GT-Lang']) or isset($request_headers['X-Gt-Lang']) or isset($request_headers['x-gt-lang'])) {
|
69 |
+
echo 'Please remove DNS cname records for GTranslate!';
|
70 |
+
exit;
|
71 |
+
}
|
72 |
+
|
73 |
+
$host = $glang . '.' . preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
|
74 |
+
$request_headers['Host'] = $host;
|
75 |
+
if(isset($request_headers['HOST'])) unset($request_headers['HOST']);
|
76 |
+
if(isset($request_headers['host'])) unset($request_headers['host']);
|
77 |
+
|
78 |
+
if(!function_exists('gzdecode'))
|
79 |
+
$request_headers['Accept-Encoding'] = '';
|
80 |
+
else
|
81 |
+
$request_headers['Accept-Encoding'] = 'gzip';
|
82 |
+
|
83 |
+
if(isset($request_headers['accept-encoding'])) unset($request_headers['accept-encoding']);
|
84 |
+
|
85 |
+
if(isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
|
86 |
+
$request_headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
|
87 |
+
if(isset($request_headers['authorization'])) unset($request_headers['authorization']);
|
88 |
+
}
|
89 |
+
//print_r($request_headers);
|
90 |
+
//exit;
|
91 |
+
|
92 |
+
if(isset($request_headers['Content-Type']) and strpos($request_headers['Content-Type'], 'multipart/form-data;') !== false)
|
93 |
+
$request_headers['Content-Type'] = 'multipart/form-data'; // remove boundary
|
94 |
+
|
95 |
+
$headers = array();
|
96 |
+
foreach($request_headers as $key => $val) {
|
97 |
+
// remove cloudflare CF headers: CF-IPCountry, CF-Ray, etc...
|
98 |
+
if(preg_match('/^CF-/i', $key))
|
99 |
+
continue;
|
100 |
+
else
|
101 |
+
$headers[] = $key . ': ' . $val;
|
102 |
+
}
|
103 |
+
|
104 |
+
//print_r($headers);
|
105 |
+
//exit;
|
106 |
+
|
107 |
+
// proxy request
|
108 |
+
$ch = curl_init();
|
109 |
+
curl_setopt($ch, CURLOPT_URL, $page_url);
|
110 |
+
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
111 |
+
curl_setopt($ch, CURLOPT_HEADER, true);
|
112 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
113 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
114 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
115 |
+
|
116 |
+
switch($_SERVER['REQUEST_METHOD']) {
|
117 |
+
case 'POST': {
|
118 |
+
curl_setopt($ch, CURLOPT_POST, true);
|
119 |
+
if(isset($request_headers['Content-Type']) and strpos($request_headers['Content-Type'], 'multipart/form-data') !== false) {
|
120 |
+
http_build_query_for_curl($_POST, $new_post);
|
121 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $new_post); // todo: think about $_FILES: http://php.net/manual/en/class.curlfile.php
|
122 |
+
} else {
|
123 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents('php://input'));
|
124 |
+
}
|
125 |
+
}; break;
|
126 |
+
|
127 |
+
case 'PUT': {
|
128 |
+
curl_setopt($ch, CURLOPT_PUT, true);
|
129 |
+
curl_setopt($ch, CURLOPT_INFILE, fopen('php://input', 'r'));
|
130 |
+
}; break;
|
131 |
+
}
|
132 |
+
|
133 |
+
// Debug
|
134 |
+
if($debug or isset($_GET['enable_debug'])) {
|
135 |
+
$fh = fopen('debug.txt', 'a');
|
136 |
+
curl_setopt($ch, CURLOPT_VERBOSE, true);
|
137 |
+
curl_setopt($ch, CURLOPT_STDERR, $fh);
|
138 |
+
}
|
139 |
+
|
140 |
+
$response = curl_exec($ch);
|
141 |
+
$response_info = curl_getinfo($ch);
|
142 |
+
curl_close($ch);
|
143 |
+
|
144 |
+
//print_r($response_info);
|
145 |
+
|
146 |
+
$header_size = $response_info['header_size'];
|
147 |
+
$header = substr($response, 0, $header_size);
|
148 |
+
$html = substr($response, $header_size);
|
149 |
+
|
150 |
+
if(function_exists('gzdecode')) {
|
151 |
+
$return_gz = false;
|
152 |
+
$html_gunzip = @gzdecode($html);
|
153 |
+
|
154 |
+
if($html_gunzip !== false) {
|
155 |
+
$html = $html_gunzip;
|
156 |
+
unset($html_gunzip);
|
157 |
+
|
158 |
+
if(strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false) {
|
159 |
+
$return_gz = true;
|
160 |
+
header('Content-Encoding: gzip');
|
161 |
+
header('Vary: Accept-Encoding');
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
$response_headers = explode(PHP_EOL, $header);
|
167 |
+
//print_r($response_headers);
|
168 |
+
$headers_sent = '';
|
169 |
+
foreach($response_headers as $header) {
|
170 |
+
if(!empty($header) and !preg_match('/Content\-Length|Transfer\-Encoding|Content\-Encoding|Link/i', $header)) {
|
171 |
+
|
172 |
+
if(preg_match('/^Location:/i', $header)) {
|
173 |
+
$header = str_ireplace($host, $_SERVER['HTTP_HOST'] . '/' . $glang, $header);
|
174 |
+
$header = str_ireplace('Location: /', 'Location: /' . $glang . '/', $header);
|
175 |
+
}
|
176 |
+
|
177 |
+
$headers_sent .= $header;
|
178 |
+
header($header, false);
|
179 |
+
}
|
180 |
+
}
|
181 |
+
//echo $headers_sent;
|
182 |
+
|
183 |
+
// TODO: modify URLs
|
184 |
+
$html = str_ireplace($host, $_SERVER['HTTP_HOST'] . '/' . $glang, $html);
|
185 |
+
$html = str_ireplace('href="/', 'href="/' . $glang . '/', $html);
|
186 |
+
$html = preg_replace('/href=\"\/' . $glang . '\/(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)\//i', 'href="/$1/', $html); // fix double language code
|
187 |
+
$html = str_ireplace('href="/' . $glang . '//', 'href="//', $html);
|
188 |
+
$html = str_ireplace('action="/', 'action="/' . $glang . '/', $html);
|
189 |
+
$html = str_ireplace('action="/' . $glang . '//', 'action="//', $html);
|
190 |
+
$html = str_ireplace('action="//' . $_SERVER['HTTP_HOST'], 'action="//' . $_SERVER['HTTP_HOST'] . '/' . $glang, $html);
|
191 |
+
|
192 |
+
// woocommerce specific changes
|
193 |
+
$html = str_ireplace(
|
194 |
+
array('"wc_ajax_url":"\\/', '"checkout_url":"\\/', 'var wc_country_select_params', 'var wc_address_i18n_params' ),
|
195 |
+
array('"wc_ajax_url":"\\/'.$glang.'\\/', '"checkout_url":"\\/'.$glang.'\\/', 'var wc_country_select_params2', 'var wc_address_i18n_params2'),
|
196 |
+
$html
|
197 |
+
);
|
198 |
+
|
199 |
+
if(isset($_GET['language_edit'])) {
|
200 |
+
$html = str_replace('/tdn-static/', $protocol . '://tdns.gtranslate.net/tdn-static/', $html);
|
201 |
+
$html = str_replace('/tdn-bin/', $protocol . '://' . $_SERVER['HTTP_HOST'] . '/' . $glang . '/tdn-bin/', $html);
|
202 |
+
}
|
203 |
+
|
204 |
+
if(function_exists('gzencode') and isset($return_gz) and $return_gz and zlib_get_coding_type() == false)
|
205 |
+
echo gzencode($html);
|
206 |
+
else
|
207 |
+
echo $html;
|
208 |
+
|
209 |
+
function http_build_query_for_curl($arrays, &$new = array(), $prefix = null) { // flatten multidimentional array for post
|
210 |
+
if(is_object($arrays)) {
|
211 |
+
$arrays = get_object_vars($arrays);
|
212 |
+
}
|
213 |
+
|
214 |
+
foreach($arrays AS $key => $value) {
|
215 |
+
$k = isset($prefix) ? $prefix . '[' . $key . ']' : $key;
|
216 |
+
if(is_array($value) or is_object($value)) {
|
217 |
+
http_build_query_for_curl($value, $new, $k);
|
218 |
+
} else {
|
219 |
+
$new[$k] = $value;
|
220 |
+
}
|
221 |
+
}
|
222 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|