aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/grum_plugins_classes-2/google_translate.js
diff options
context:
space:
mode:
authorgrum <grum@piwigo.org>2008-08-07 21:52:45 +0000
committergrum <grum@piwigo.org>2008-08-07 21:52:45 +0000
commit526d8006a16bd8b666d94aaf152346537045a0a5 (patch)
treebe1a62befe2bdbe3d0d03a8155aa1d1b228093e5 /plugins/grum_plugins_classes-2/google_translate.js
parent5e3d71c9cab75c7796c566823df96765522c8965 (diff)
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
Diffstat (limited to '')
-rwxr-xr-xplugins/grum_plugins_classes-2/google_translate.js56
1 files changed, 55 insertions, 1 deletions
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();
+ }
+ }
}
}