1 | /* ----------------------------------------------------------------------------- |
---|
2 | file: google_translate.js |
---|
3 | file version: 2.0.0 |
---|
4 | date: 2008-05-25 |
---|
5 | ------------------------------------------------------------------------------ |
---|
6 | author: grum at grum.dnsalias.com |
---|
7 | << May the Little SpaceFrog be with you >> |
---|
8 | ------------------------------------------------------------------------------ |
---|
9 | |
---|
10 | this classes provides base functions to use Google Translate AJAX API |
---|
11 | >> http://code.google.com/apis/ajaxlanguage/ |
---|
12 | |
---|
13 | ------------------------------------------------------------------------------ |
---|
14 | HISTORY VERSION |
---|
15 | v2.0.0 + |
---|
16 | |
---|
17 | -------------------------------------------------------------------------- */ |
---|
18 | |
---|
19 | google.load("language", "1"); |
---|
20 | |
---|
21 | |
---|
22 | var global_google_translate_plugin_objdest; |
---|
23 | var global_google_translate_plugin_objproperty; |
---|
24 | |
---|
25 | |
---|
26 | function google_translate(text, pfrom, pto, objdest, objproperty) |
---|
27 | { |
---|
28 | global_google_translate_plugin_objdest = objdest; |
---|
29 | global_google_translate_plugin_objproperty = objproperty; |
---|
30 | google.language.translate(text, pfrom, pto, google_translate_do); |
---|
31 | } |
---|
32 | |
---|
33 | function google_translate_do(result) |
---|
34 | { |
---|
35 | if (!result.error) |
---|
36 | { |
---|
37 | if(global_google_translate_plugin_objproperty=='value') |
---|
38 | { |
---|
39 | global_google_translate_plugin_objdest.value = result.translation; |
---|
40 | } |
---|
41 | else if(global_google_translate_plugin_objproperty=='innerHTML') |
---|
42 | { |
---|
43 | global_google_translate_plugin_objdest.innerHTML = result.translation; |
---|
44 | } |
---|
45 | } |
---|
46 | } |
---|
47 | |
---|