DataObjects/Core_watch.php
[Pman.Core] / Pman.GoogleTranslate.js
index 6b7e203..1978ccd 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,12 +123,13 @@ 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';
+     
          
         
         x.load(
@@ -137,10 +143,12 @@ Pman.GoogleTranslate = function(str, src, dest, cb, force) {
             }, // end params.
             { // reader
                 readRecords : function (o) {
-                    if (!o.responseData) {
+                    Roo.log(o);
+                    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) {