From 526d8006a16bd8b666d94aaf152346537045a0a5 Mon Sep 17 00:00:00 2001 From: grum Date: Thu, 7 Aug 2008 21:52:45 +0000 Subject: updating files for the Menu class (test_menu) + add functionnalities updating files for the AMenuManager plugin + fixes some bugs + add functionnalities updating common classes grum_plugins_classes-2 (needed for the AMenuManager plugin) + add functionalities for google_translator use git-svn-id: http://piwigo.org/svn/trunk@2468 68402e56-0260-453c-a942-63ccdbb3a9ee --- plugins/grum_plugins_classes-2/google_translate.js | 56 +++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'plugins/grum_plugins_classes-2/google_translate.js') diff --git a/plugins/grum_plugins_classes-2/google_translate.js b/plugins/grum_plugins_classes-2/google_translate.js index 2798150e2..98b5507f5 100755 --- a/plugins/grum_plugins_classes-2/google_translate.js +++ b/plugins/grum_plugins_classes-2/google_translate.js @@ -12,7 +12,8 @@ ------------------------------------------------------------------------------ HISTORY VERSION - v2.0.0 + + v2.0.0 + adapted for piwigo + + add of a 5th&6th parameters for the google_translate function -------------------------------------------------------------------------- */ @@ -21,15 +22,57 @@ var global_google_translate_plugin_objdest; var global_google_translate_plugin_objproperty; + var global_google_translate_plugin_objcallback; + var global_google_translate_plugin_objcallback_param; function google_translate(text, pfrom, pto, objdest, objproperty) { + /* + ** args needed ** + 1st arg : text to translate + 2nd arg : translate from lang ("en", "fr", "es", ...) + 3rd arg : translate to lang ("en", "fr", "es", ...) + 4th arg : target of result (id) + 5th arg : affected propertie ('value' or 'innerHTML') + ** facultative args ** + 6th arg : pointer on a function definition (callback is made when + translation is done ; notice that translation is made asynchronous) + 7th arg : arg for the callback (or array of arg if callbakc need more than + one parameter) + */ + if(arguments.length>=6) + { + global_google_translate_plugin_objcallback=arguments[5]; + } + else + { + global_google_translate_plugin_objcallback=null; + } + + if(arguments.length>=7) + { + if(arguments[6].pop) + { + global_google_translate_plugin_objcallback_param=arguments[6]; + } + else + { + global_google_translate_plugin_objcallback_param=new Array(arguments[6]); + } + } + else + { + global_google_translate_plugin_objcallback_param=null; + } + + global_google_translate_plugin_objdest = objdest; global_google_translate_plugin_objproperty = objproperty; google.language.translate(text, pfrom, pto, google_translate_do); } + function google_translate_do(result) { if (!result.error) @@ -42,6 +85,17 @@ { global_google_translate_plugin_objdest.innerHTML = result.translation; } + if(global_google_translate_plugin_objcallback!=null) + { + if(global_google_translate_plugin_objcallback_param!=null) + { + global_google_translate_plugin_objcallback.apply(null, global_google_translate_plugin_objcallback_param); + } + else + { + global_google_translate_plugin_objcallback(); + } + } } } -- cgit v1.2.3