Pman.GoogleTranslate.js
[Pman.Core] / Pman.GoogleTranslate.js
index dd27056..c9ceb67 100644 (file)
@@ -129,7 +129,9 @@ Pman.GoogleTranslate = function(str, src, dest, cb, force) {
         // google does not recognize HK...
         if (src  == 'zh-HK')  src = 'zh-TW';
         if (dest == 'zh-HK') dest = 'zh-TW';
-     
+        
+        var ret = '';
+        
         new Pman.Request({
             url : baseURL + '/Core/GoogleTranslate.php',
             method :'POST',
@@ -142,17 +144,25 @@ Pman.GoogleTranslate = function(str, src, dest, cb, force) {
             },
             success: function(o)
             {
-                if (!o.data) {
+                if (!o) {
                     return o;
                 }
+                if(typeof(o.data.error) != 'undefined'){
+                    Roo.get(document.body).unmask();
+                    Roo.MessageBox.alert("Failure ", o.data.error.message);
+                    return;
+                }
 //                Roo.MessageBox.alert("Success", "We logged in OK")
-                return o.data.translations[0].translatedText;
+                return o.translatedText;
             },
             failure: function (res) {
                 Roo.log(res);
-                Roo.MessageBox.alert("Failure", "Failed?")
+                Roo.MessageBox.alert("Failure ", res.data.error.message);
             }
         });
+        
+//        return ret;
+        
 //        
 //        x.load(
 //            {