Translate Macro (Q&A)
Posted by: jsnj
Date: August 08, 2005 07:16AM

Post any comments or questions you may have pertaining to the Translate macro script in this thread.

Re: Translate Macro (Q&A)
Posted by: jsnj
Date: August 08, 2005 07:19AM
Re: Translate Macro (Q&A)
Posted by: AmboyGuy
Date: August 21, 2005 01:56AM

@jsnj

I tried using it yesterday on selected text and got an 2 errors ( expecting 3 arguments found 1 & missing left parentheses)

Select some text (any, it won't work anyway)
right click > selected text > translate from > Spanish to english.

I did a straight copy from the wiki to Macros.cfg & the correct spots in Menu.cfg.

PS: the Google address string $trgoog 216.239.37.104/translate_c?u=";
It gets this Google error:

Sorry, this URL is invalid

http:?lp=es_en

Please choose from the following:

* Back to Language Tools

Re: Translate Macro (Q&A)
Posted by: AmboyGuy
Date: August 21, 2005 02:09AM

I did notice this in TrEng

$xul=$tralta.$trpref."?lp=".$lang.$tr.$trsuf.$add;
_______________________________^^^

Is undefined as far as I can tell. (AFAICT).

Re: Translate Macro (Q&A)
Posted by: AmboyGuy
Date: August 21, 2005 02:25AM

Great the text lines don't line up.
$trsuf is what I was pointing to.

Re: Translate Macro (Q&A)
Posted by: jsnj
Date: August 23, 2005 01:08AM

I can't reproduce your errors. I just tested again to be sure.

1. I opened KM 0.9 official and created a new profile.

2. Went to the macro page and copy & pasted & restarted.

3. Went to: es.yahoo.com

4. Selected the word: Contrata and used the translate macro Spanish. Worked fine with the translation opening in babelfish.

5. Then went back to the layer with Yahoo and used the translate macro when text was not selected. Worked fine with the resulting Google translated page being: 216.239.37.104/translate_c?u=http://es.yahoo.com/



Is undefined as far as I can tell.

$trsuf is defined in the macros TrSel and TrURL which are called from the Translate macro which is referenced from the specific language macros.


What KM version are you using?

Re: Translate Macro (Q&A)
Posted by: AmboyGuy
Date: August 23, 2005 04:00AM

It appears that the Umlatts Macro was a problem. I just built a new macros.cfg and am testing it now. I read your response and tried again.
The Translations Macro is working just fine.

In the macros.cfg file that came with Hao's CCFb4 version had ' ? ' marks instead of the accented characters. It took me a couple of tries to get them to download & display properly.

Umlautts Macro was:
$word=gsub("?","%C3%A4",$word); $word=gsub("?","%C3%B6",$word); etc.

Instead of
$word=gsub("ä","%C3%A4",$word); $word=gsub("ö","%C3%B6",$word); etc.

All the accented characters were missing, being relaced by an ASCII ' ? ' (%3F)

I have finally locked down the character encoding and font display in k-meleon & my Programming Editor. I suspect that the file was edited and the system didn't support the accented characters (replacing with them with question marks) and then saved and never noticed again.

The parentheses error was caused by me saving the file as an UTF-8 encoded file which generates some characters at the begining of the file and causes km to error message and not load any macros. When saved as an ASCII file and the leading characters deleted there were no errors generated.

I'm just now testing my new version of macros.cfg and everything appears to work correctly. I'm weeding out things I don't use and adding those I do from different versions of k-m.
I notice that in Hao's code he commented out OpenSearch w/ Umlautts. He must have had the same problem and just did the search without Umlatts.

Now I'm going to adjust my menus.cfg & toolbars.cfg to reflect macros.cfg changes and my personal tastes.

I noticed that when k-m encounters a bad line it gives no line number or even the offending line as an error message. That would sure help narrowing down what's wrong.
An 'include' directive to the Macro language would be nice. That way you could break out macros to small files and just " &include Search_Macros.cfg " or " &include Translate_Macro.cfg "
Then if an error occurs parsing the file, printout the file name & line number so you know where the problem is at.

Wishlist for K-Meleon v1.0 : Better error handling & an INCLUDE directive in the Macro Language.

On the user.js file if it encounters an error it just aborts reading in the file, no indication of an error at all. ( It's a Mozilla GRE function so don't expect any fix ).
I had one line with a mispelled user_pref ( user_perf ) and couldn't understand why none of the 30 or so preferences I was changing were taking effect. It took a couple of days to find that error.

Re: Translate Macro (Q&A)
Posted by: jsnj
Date: August 23, 2005 04:48AM

The Translations Macro is working just fine.

Glad to hear :-) As stated on the macro page, it's modeled after the FF extension which uses only Google & AltaVista BabelFish, so not all translation languages listed in menus are available for users' selected languages if it's not English. In FF, the extension is able to adjust the menus to display only the functioning translations that work with the users selected language, but of course that's not possible in KM. What I'd like to do if/when I play with that script again is to incorporate other engines that may be able to offer more choices for users whose selected language isn't english. But lately I've been working on a multiple proxy script that allows adding, switching to, and editing an unlimited amount of proxies without requiring the user to edit macros & menus each time a new proxy needs to be added.

I noticed that when k-m encounters a bad line it gives no line number or even the offending line as an error message. That would sure help narrowing down what's wrong.
An 'include' directive to the Macro language would be nice. That way you could break out macros to small files and just " &include Search_Macros.cfg " or " &include Translate_Macro.cfg "
Then if an error occurs parsing the file, printout the file name & line number so you know where the problem is at.

Wishlist for K-Meleon v1.0 : Better error handling & an INCLUDE directive in the Macro Language.


I wouldn't hold my breath for that to happen, but yeah, it'd be helpful.

K-Meleon forum is powered by Phorum.