Changeset 670
- Timestamp:
- 11/22/2011 01:15:23 AM (6 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/js/transposhedit.js
r667 r670 83 83 prefix = t_jp.prefix, 84 84 idprefix = "#" + prefix, 85 localeloaded = false, 85 86 previcon = 'prev', 86 87 nexticon = 'next', … … 154 155 tr0: translation 155 156 }, 156 // TODO: This probably needs a revision!157 157 error: function (req) { 158 fix_page_human(token, '', 1); // Will turn things back, almost 158 159 alert("Problem saving translation, contact support.\n\nServer's message: " + req.statusText); 159 160 } … … 184 185 $(idprefix + "translation").val($("<div>" + $.trim(result.data.translations[0].translatedText) + "</div>").text()) 185 186 .keyup(); 186 } );187 }, t_jp.lang); 187 188 } 188 189 } … … 194 195 $(idprefix + "translation").val($("<div>" + $.trim(result[0].TranslatedText) + "</div>").text()) 195 196 .keyup(); 196 }); 197 } 198 199 // perform apertium translate of single phrase via jsonp 200 function apertium_trans(to_trans, callback) { 201 $.ajax({ 202 url: 'http://api.apertium.org/json/translate?q=' + encodeURIComponent(to_trans) + '&langpair=en%7C' + t_jp.lang, // || &key=YOURAPIKEY&markUnknown=yes 203 dataType: "jsonp", 204 success: callback 205 }); 197 }, t_jp.binglang); 206 198 } 207 199 … … 209 201 function getat() 210 202 { 211 apertium_trans($(idprefix + "original").val(), function (result) {203 t_jp.dat($(idprefix + "original").val(), function (result) { 212 204 $(idprefix + "translation").val($("<div>" + $.trim(result.responseData.translatedText) + "</div>").text()) 213 205 .keyup(); 214 } );206 }, t_jp.lang); 215 207 } 216 208 … … 753 745 $(this).after('<span id="' + prefix + 'img_' + translated_id + '" class="tr-icon" title="' + $(this).attr('data-orig') + '"></span>'); 754 746 img = $(idprefix + 'img_' + translated_id); 747 // internal function used to load locale in two needed cases (where we load jQueryui and not...) 748 var loadlocaleandrundialog = function() { 749 if (t_jp.locale && !localeloaded) { 750 $.getScript(t_jp.plugin_url + '/js/l/'+t_jp.lang+'.js', function () { 751 localeloaded = true; 752 translate_dialog(translated_id); 753 }); 754 } else { 755 translate_dialog(translated_id); 756 } 757 } 755 758 img.click(function () { 756 759 // if we detect that $.ui is missing (TODO - check tabs - etal) we load it first, the added or solves a jquery tools conflict !!!!!!!!!!! … … 763 766 js: t_jp.jQueryUI + 'jquery-ui.min.js', 764 767 css: t_jp.jQueryUI + 'themes/'+ t_jp.theme + '/jquery-ui.css', 765 success: function () { 766 // Load locale - todo - better... 767 if (t_jp.locale) { 768 $.xLazyLoader({ 769 js: [t_jp.plugin_url + '/js/l/'+t_jp.lang+'.js'], 770 success: function () { 771 translate_dialog(translated_id); 772 } 773 }); 774 } else { 775 translate_dialog(translated_id); 776 } 777 } 768 success: loadlocaleandrundialog 778 769 }); 779 770 }); 780 771 } else { 781 if (t_jp.locale) { 782 $.xLazyLoader({ 783 js: [t_jp.plugin_url + '/js/l/'+t_jp.lang+'.js'], 784 success: function () { 785 translate_dialog(translated_id); 786 } 787 }); 788 } else { 789 translate_dialog(translated_id); 790 } 772 loadlocaleandrundialog(); 791 773 } 792 774 return false;
Note: See TracChangeset
for help on using the changeset viewer.
