/g,'').replace(/<\/code>/g,'').replace(/>/g,'>').replace(/</g,'<');
+ $('a.suggest').click(function(e){
+ e.preventDefault();
+ var a = $(this);
+ var str = a.html();
+ var orig = $('.original .message', a.parents('tr')).html();
+ var trans=$('textarea',a.parent());
+ var sourceLang = '{{ MESSAGES_SOURCE_LANGUAGE_CODE }}';
+ var destLang = '{{ rosetta_i18n_lang_code }}';
+ var app_id = '{{ BING_APP_ID }}';
+ var apiUrl = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate";
+
+ orig = unescape(orig).replace(/
/g,'\n').replace(//,'').replace(/<\/code>/g,'').replace(/>/g,'>').replace(/</g,'<');
a.attr('class','suggesting').html('...');
window.onTranslationComplete = function(resp) {
trans.val(unescape(resp).replace(/'/g,'\'').replace(/"/g,'"').replace(/%\s+(\([^\)]+\))\s*s/g,' %$1s '));
a.hide();
-
};
- var s = document.createElement("script");
- s.src = "http://api.microsofttranslator.com/V2/Ajax.svc/Translate?oncomplete=onTranslationComplete&appId="+app_id +"&from=" + sourceLang + "&to=" + destLang + "&text=" + orig;
- document.getElementsByTagName("head")[0].appendChild(s);
-
- /*
- google.language.translate(orig, , function(result) {
- if (!result.error) {
- trans.val(unescape(result.translation).replace(/'/g,'\'').replace(/"/g,'"').replace(/%\s+(\([^\)]+\))\s*s/g,' %$1s '));
- a.hide();
- } else {
- a.hide().before($(''+result.error.message+''));
- }
- });
- */
- return false;
+ window.onTranslationError = function(response){
+ a.text(response);
+ };
+ var apiData = {
+ onerror: 'onTranslationError',
+ appid: app_id,
+ from: sourceLang,
+ to: destLang,
+ oncomplete: "onTranslationComplete",
+ text: orig
+ };
+ $.ajax({
+ url: apiUrl,
+ data: apiData,
+ dataType: 'jsonp'});
});
-
-
- $('#translate-all').submit(function() {
- $('a.suggest').click();
- return false;
- });
- $('.checkall').click(function(){
- $('td.c input').attr('checked', '');
- $('td.c input').attr('value', '0');
- });
-
-
-
{% endif %}
+
$('td.plural').each(function(i) {
var td = $(this), trY = parseInt(td.closest('tr').offset().top);
$('textarea', $(this).closest('tr')).each(function(j) {
diff --git a/rosetta/templates/rosetta/pofile.html b/rosetta/templates/rosetta/pofile.html
index b7f9edc..5e8405d 100644
--- a/rosetta/templates/rosetta/pofile.html
+++ b/rosetta/templates/rosetta/pofile.html
@@ -49,7 +49,7 @@