Pman.GoogleTranslate.js
[Pman.Core] / Pman.GoogleTranslate.js
index 9d3c5ac..98834e1 100644 (file)
@@ -28,6 +28,11 @@ Pman.GoogleTranslate = function(str, src, dest, cb, force) {
                     
                     Pman.GoogleTranslate(str, src, dest, cb, force);
                     
+                },
+                failure : function() {
+                    Roo.log("Google key fetch failed");
+                    // do not display error message...
+                    return true;
                 }
                 
                 
@@ -118,13 +123,33 @@ Pman.GoogleTranslate = function(str, src, dest, cb, force) {
             
             
         });
-        /// fix some of the languages..
-        //switch (dest) {
-        //        case 'zh-CN' : dest = 'zh-CN'; break;
-         //       case 'zh-HK' : dest = 'zh-TW'; break;
-         //           
-        //}
-         
+        
+        src = src.replace('_','-');
+        dest = dest.replace('_','-');
+        // google does not recognize HK...
+        if (src  == 'zh-HK')  src = 'zh-TW';
+        if (dest == 'zh-HK') dest = 'zh-TW';
+     
+        new Pman.Request({
+            url : baseURL + '/Roo/GoogleTranslate.php',
+            method :'POST',
+            mask : 'Translating',
+            maskEl : document.body,
+            params : {
+                text : str,
+                src  : src,
+                dest : dest,
+            },
+            success: function()
+            {
+                Roo.MessageBox.alert("Success", "We logged in OK")
+
+            },
+            failure: function (res) {
+                Roo.log(res);
+                Roo.MessageBox.alert("Failure", "Failed?")
+            }
+        });
         
         x.load(
             {
@@ -138,10 +163,11 @@ Pman.GoogleTranslate = function(str, src, dest, cb, force) {
             { // reader
                 readRecords : function (o) {
                     Roo.log(o);
-                    if (!o.responseData) {
+                    if (!o.data) {
                         return o;
                     }
-                    return escapeDecode(o.responseData.translations[0].translatedText);
+                    return o.data.translations[0].translatedText;
+                    //return escapeDecode(o.data.translations[0].translatedText);
                 }
             }, 
             function (result) {