Update google-translate.js.
Thursday, 15. May 2008, 13:01:13
Sample of menu: menu_bbcode_english.ini.
Button: Translate to English
Go to Page,"javascript:ujs_google_translate('auto|en')",,,"Window Mail Compose Icon"
* Google now supports automatic language detection. Therefore you can use universal button or hotkey for translation from any language to English.
* First start more fast.
* Works in Opera 8-10
About installation UserJS written here.


1 2 Next »
invagrante # 6. June 2008, 12:50
EDIT: OK, so I'm probably going about it completely the wrong way, but here's what I have so far:
However, for some reason the Google frame still appears, even though the link generated appears to be identical to the one Google generates for removing the frame. Perhaps it's a referrer thing? The Firefox translator extension doesn't display the frame when translating, so I'm not sure. I actually only went looking for a translator button because I found this extension while using the work computers, which run Firefox, and decided I wanted a similar functionality. I think I've almost got it, just need a bit more help.
EDIT2: Never mind, I've figured it out! Here's the code if anyone else is interested in my pointless downgrade of your version:
Or as a button: Autotranslate
It was simply a matter of changing translate_c to translate_p. Google redirects it to translate_c anyway, but the frame's not there, so whatever, I'm not complaining. Anyway, in short, this version uses the Panel Notes icon (which might look weird if you use Notes, I have that panel removed though, so the icon is free), shows the translation in the same tab, and removes the translation frame. As you might guess, I eventually started from scratch with simpler JS, thanks to my inexperience, but all credit for inspiration goes to you. Thank you.
Anonymous # 16. June 2008, 12:42
Thanks pal, worked in 9.5 and really useful.
But EDIT2 buttton is not working on 9.5
Also can we make translate window bigger, it's very small I think.
Lex1 # 16. June 2008, 13:13
What's it?
A size depends on the amount of text. You can change it.
{h = 15; w = 20; if(txtLen > 2000){h = 50; w = 66}else if(txtLen > 250){h = 25; w = 33};h - height in percent from Opera window.
w - width in percent from Opera window.
txtLen - number of symbols in translation.
seemille # 17. June 2008, 03:11
Thanks very much.
nizamx # 17. June 2008, 10:15
I mean this button in 9.5 opens a page with an error:
Autotranslate
Lex1 # 17. June 2008, 10:44
Paranoiacs work in my.opera.com team
nizamx # 17. June 2008, 19:56
Translation from English into English is not supported.
Also in 9.5 can't add custom icon from http://nontroppo.org/tools/buttonmaker/ in fact icon appears fine on that site but on Opera it always notes icon.
Lex1 # 18. June 2008, 12:16
Where? Google translates majority, but not all of pages.
Works for me.
adas # 18. June 2008, 14:27
Translate to French
Translate to Polish
Translate to Deutsch
...
nizamx # 18. June 2008, 17:15
Lex1 # 18. June 2008, 17:49
Yes, Vague_Rant was needed exactly it. If you needed translations of selected text, use my button.
adas
«javascript:google_translate('auto|de')», etc.
adas # 18. June 2008, 17:54
leoalassia # 19. June 2008, 19:01
Lex1 # 20. June 2008, 07:49
leoalassia # 20. June 2008, 21:35
Anonymous # 24. June 2008, 18:24
Thank you for making this great update. I love being able to translate little snippets of text with the click of a button. The button works as a charm and can be easily modified to translate to any language other than English.
I was able to create a keyboard shortcut to transalte to English (Alt + E) and to translate to Spanish (Alt + S). Again, thank you very much for this update.
leoalassia # 24. June 2008, 20:39
Anonymous # 26. June 2008, 01:20
leoalassia,
I'm sure you know how to create your own keyboard shortcuts already but if not, simply follow these instructions http://my.opera.com/Tamil/blog/add-modify-keyboard-shortcut
Once you're there, assign a key and as an action, enter the following (which is the same as the button):
Go to page, "javascript:if(typeof google_translate=='function'){google_translate('auto|en')}else{void(window.open('http://translate.google.com/translate'+(document.selection.createRange().text?'_t?text='+document.selection.createRange().text:'?u='+escape(location.href))+'&hl=en&langpair=auto|en&tbb=1'+(document.characterSet?'&ie='+document.characterSet:'')));}"
If you would like translate to some other language such as spanish, then just change anything that says "en" to "es". Then to use it, simply highlight the text you want translated and press the shortcut key you assigned to it.
leoalassia # 26. June 2008, 12:16
thanks for your help!
nizamx # 19. August 2008, 20:28
leoalassia # 22. August 2008, 03:45
Lex1 # 22. August 2008, 08:27
[Link Selection Popup Menu]
leoalassia # 26. August 2008, 18:12
Lex1 # 26. August 2008, 20:51
Yes, it well known problem for any js-buttons. You can use allow-ini-variables.js and button:
Button, "Translate to English"="Go to Page,"javascript:void(inivar='%t')",,,"Window Mail Compose Icon" & Go to Page,"javascript:ujs_google_translate('auto|en')" "leoalassia # 27. August 2008, 04:21
I've analized your code because the function's name in my google-translate.js is not ujs_google_translate (it's just google_translate), but I fixed it with your last update, so I don't know where I'm wrong
Lex1 # 27. August 2008, 16:15
leoalassia # 27. August 2008, 18:15
line 87:
else if(t && location.hostname != 'translate.google.com' && document.body instanceof HTMLFrameSetElement){
...
...
document.frames[1].document.documentElement.appendChild(f);
}
so it works fine, but as you can see I'm getting the frame[1] because I know that this frame is what I want...
Lex1 # 28. August 2008, 14:22
leoalassia # 7. September 2008, 00:38
I am using "javascript:inivar='%t';ujs_google_translate('auto|es')"
so it seems that %t is not escaped
Lex1 # 7. September 2008, 09:42
Yes. allow-ini-variables.js exists for correction of problem with quotes ('") and backslash (\) in Opera variables.
Lex1 # 7. September 2008, 09:52
Go to Page,"javascript:void(inivar='%t')",,, "l_english" & Go to Page,"javascript:ujs_google_translate('auto|en')""leoalassia # 7. September 2008, 15:59
arnyq # 19. October 2008, 17:29
Lex1 # 19. October 2008, 18:17
arnyq # 19. October 2008, 22:49
Lex1 # 20. October 2008, 09:09
Install UserJS
arnyq # 21. October 2008, 20:28
Also, can you consider adding a couple of options to your UserJS and Button:
- make dropdown Button to select a translation service:
A) PROMT
a) Translate (RU) to EN
b) Translate (EN) to RU
B) Google
a) Translate to EN
b) Translate to RU
Google returns a lot of translation and language detection errors.
Also, how to add this upgrade to Menu? Will a separate PROMT JS do better - they slow browser performance a lot. PROMT might be slow at times, but it's the best for RU.
PROMT offers several lexicon dictionaries. "General" is default, so I wonder, how to add Lexicon Choice to the Button in a compact way?
I'd expect Google to autoselect the right language & lexicon based on the source page content, if it's address sent to Google with selected text. I doubt, they offer it via website UI, but is there a way to add this via query?
Lex1 # 22. October 2008, 12:57
This «small window» can be dragged
Last version (1.6.18) of the script supports PROMT.
From my extended menu
nizamx # 22. October 2008, 14:19
arnyq # 22. October 2008, 16:26
It doesn't answer my question. I keep dragging it all the time.
Thanks for adding Promt support!
How about the rest of my questions:
- Lexicon choice in Promt
- dropdown Button for Google / Promt
- adding "selected text" site's address to Google Translate query for translation accuracy.
Lex1 # 23. October 2008, 09:54
In folder \profile\menu (see path in Help->About) and select menu in Opera preferences.
It menu in Russian, English version will later.
arnyq
Screenshot please.
«Button9, "Translate"="Show hidden popup menu, "JS Translate Menu"»
arnyq # 23. October 2008, 16:03
Lex1 # 23. October 2008, 17:10
English version my extended menu.
arnyq
It is absolute normally. Position of window depends on position last click of mouse. You can do a window lower, with replacing
on
Not supported with used version of online translator.
Afaik, Google don't support it.
arnyq # 23. October 2008, 17:21
Also, the window should jump above the selected text, if there is insufficient space to show it below the text without overlapping it. Now it doesn't always happen.
Lexicon Choice in Promt.
Lex1 # 23. October 2008, 19:34
Replace
on
I use wap.translate.ru. It work more fast.
nizamx # 23. October 2008, 20:27
nizamx # 31. October 2008, 16:22
Lex1 # 31. October 2008, 21:10
Or you use other name for the section in menu, or yours the button maker not good
nizamx # 1. November 2008, 12:53
By the way is it possible to create context menu or button for Babylon?
invagrante # 10. November 2008, 12:56
Autotranslate
EDIT: Although it looks like the comment field is stripping out my javascript, so the name won't appear as Autotranslate. It should still work, however.