gxlat - Desktop Google Translator redux

Word processors, spreadsheets, presentations, translation, etc.
Message
Author
User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

gxlat - Desktop Google Translator redux

#1 Post by vovchik »

Dear Puppians,

Here is a little application I banged together today to translate texts using Google's translate engine. It works from the desktop and obviates the need to load a heavy, java-script-supporting browser. It is written in bash and makes use of gtkdialog, gxmessage and bing, a tiny ping substitute I wrote because it quits after a second unlike ping if the DNS cannot be resolved (i.e. if your connection is dead). All relevant source included.

Since this is an alpha, you might have some suggestions for improvement. I have a few in mind already, but wanted to get this thing off my chest.

Have fun.

With kind regards,
vovchik
Attachments
gxlat2.jpg
(28.58 KiB) Downloaded 3030 times
gxlat.pet
(27.04 KiB) Downloaded 1756 times

User avatar
otropogo
Posts: 764
Joined: Sat 24 Oct 2009, 15:17
Location: Montreal
Contact:

#2 Post by otropogo »

Thanks vovchi.

Love your pet. It's especially handy for checking crummy GT translations (which I run into all the time). If you have a nodding acquaintance with several languages, as I do, you can quickly cycle the original through two or three translations and soon decide what the real meaning of the original is.

BTW I get a dailly abridged version by e-mail of all the posts in the Google Translate help forum (it's really a "help!" forum, because it's full of requests, and almost no help), which informs me of an amazing range of Google Translate features I've never experienced with Puppy/Seamonkey.

These include the option of viewing the pinyin phonetics for Chinese script and of listening to the audio rendition of original text submitted.

Unfortunately, the posters almost never specify how exactly they are accessing Google Translate (ie. OS and/or browser). I suspect most are using Google Chrome, but have no evidence. Many complain bitterly that Google Translate runs automatically on their browser and they want to shut it down, but con't know how!

Do you know if either of the two features above (audio or pinyin) can be accessed with Puppy 4.3.1.?
otropogo@gmail.com facebook.com/otropogo

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#3 Post by vovchik »

Dear Puppians,

I still have to do something about escaping double quotes and ampersands in the text. Any ideas? Please look at the function translate in the gxlat script.

with kind regards,
vovchik

PS. Ostropogo, thanks. I will look into the audio and other features. Perhaps somebody else on the forum knows and can enlighten us.

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#4 Post by neurino »

vovchik wrote: I still have to do something about escaping double quotes and ampersands in the text. Any ideas? Please look at the function translate in the gxlat script.
Why not simply replace ampersands and quotes with html entities?
And also < and > that can come in with copy and paste!

It should work and you can use bash string functions or sed:

Code: Select all

#bash way
FROM_TEXT=${FROM_TEXT//&/&}
FROM_TEXT=${FROM_TEXT//"/"}
FROM_TEXT=${FROM_TEXT//</<}
FROM_TEXT=${FROM_TEXT//>/>}

#sed way
#(always thanks potong for enlighting me on sed power)
FROM_TEXT=$(sed -r '
    s/&/&/
    s/"/"/
    s/</</
    s/>/>/
' <<< $FROM_TEXT)
Get entities here, you can try also decimal values `& 68 ;` etc...

Haven't tested it though...

Greetings

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#5 Post by vovchik »

Dear neurino,

Many thanks. I am now playing with the filters....

I am not great with sed, but I have written some rather complex filters in the past (that, surprisingly, worked!). Gxlat really needs that filtering for oddball chars. I wrote gxlat initially because I saw a similar implementation in java - which meant, to me, heaps of unnecessary overhead and bulk. The java version also loaded very slowly. I think the only real defect now is the lack of proper filtering and, perhaps, a not up-to-date list of languages (easy to fix).

It may also be time to include clear and clipboard copy/paste buttons.

If you want to give it ago, please do.

With kind regards,
vovchik

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#6 Post by neurino »

vovchik wrote: If you want to give it ago, please do.
I'm thinking to a tiny trayicon frontend for shell-fm since I'm a Last FM addicted so I think I'll be devoted to this in the near future (and I still don't have idea how to manage a deamon :roll: :wink: )

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

Daemonization

#7 Post by vovchik »

Dear neurino,

I like the idea of a tray front end to Last FM. Please do it. Here is something you might want to use (daemonize). The latest source (1.6) is here: http://github.com/bmc/daemonize/downloads. I have attached 1.5.2.

With kind regards,
vovchik
Attachments
daemonize-1.5.2.pet
(14.11 KiB) Downloaded 1418 times

User avatar
neurino
Posts: 362
Joined: Thu 15 Oct 2009, 13:08

#8 Post by neurino »

Thank you, shell-fm already can run as a deamon (-d option) but maybe it's not enough to have it under full control so this may come in handy.

As I said it's all new stuff to me so your pet and link are a nice point to start! :D

aragon
Posts: 1698
Joined: Mon 15 Oct 2007, 12:18
Location: Germany

#9 Post by aragon »

hi vovchik, very nice app.

3 notes / requests:

1. It would be nice, if you would give the user the opportunity to save his/hers "regular" translation languages and the load this settings on future startups.

2. a button to switch the 'translation-direction' would also be nice.

3. cosmetics: please use the close button and not the cancel button. we don't have to cancel as your app runs fine ...

aragon

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

gxlat update

#10 Post by vovchik »

Dear aragon,

Thanks for the suggestions. I will include them in the next release. I have also improved the parsing for special chars, so the next release will be better.

With kind regards,
vovchik

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

new version - 0.1b

#11 Post by vovchik »

Dear Puppians,

I finally got around to posting a new pet of gxlat. I implemented Aragon's useful suggestion for remembering languages and have made some attempt (half-hearted, though) at html filtering. The "Swap" function is NOT yet implemented, although the button is there. If anybody has a clever way of doing it, please post.

The reason I posted the revised version of gxlat today is that Geoffrey posted a pet of Goot today, which looks OK but is terribly slow and big. It requires java (let's say 9 MB) and is itself 1.5 MB unpacked. This pet is roughly 45k in its packed state. :)

With kind regards,
vovchik
Attachments
gxlat.jpg
(76.3 KiB) Downloaded 1694 times
gxlat-0.1b.pet
(44.36 KiB) Downloaded 1464 times

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#12 Post by Geoffrey »

vovchik,
I've tried this before and this version does the same thing, when first run I get an error that the network connection is down and it closes, but if I run it a second time it works, it looks to me that it times out to quickly before a connection can be made, I'm using quirky 1.2.0 NOP but I don't think that would have much to do with it.
Other than that small problem it's a good app that I would use.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#13 Post by vovchik »

Dear Geoffrey,

Thanks for telling me - I think I should adjust the timeout for "bing", which I wrote some time ago. There source is there in the /usr/local/gxlat.src dir, I think. I'll look at it.

Is your inet connection generally slow? I am working on a fast connection at the moment and, even with my usual relatively slow connection, I never get the timeout if the connection is really alive. It is set for 2 second checks in Bing, so I will experiment with a longer value. It could be that your ISP's DNS server is slow at resolving, not the connection itself. If that is the case, you could try adding the following DNS servers to /etc/resolv.conf:

Code: Select all

nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 208.67.222.222
nameserver 208.67.220.220
The first two are Google's public DNS servers and the last two OpenDNS.

With kind regards,
vovchik

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

Re: new version - 0.1b

#14 Post by Geoffrey »

The reason I posted the revised version of gxlat today is that Geoffrey posted a pet of Goot today, which looks OK but is terribly slow and big. It requires java (let's say 9 MB) and is itself 1.5 MB unpacked.
I've done a comparison of Goot and gxlat and found that Goot is about twice as fast at getting a translation and the app startup times is about the same, I know it's quite large though I do have a number of other java apps so the size is of no consequence to me, I would say it all l depends on the hardware being used.

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#15 Post by Geoffrey »

vovchik,
my internet connection is 2.5Mbps, I never get any time outs, but it can be slow at getting a connection anywhere up 5 seconds depending on the time of day.

User avatar
Bernie_by_the_Sea
Posts: 328
Joined: Wed 09 Feb 2011, 18:14

Re: new version - 0.1b

#16 Post by Bernie_by_the_Sea »

Geoffrey wrote: I've done a comparison of Goot and gxlat and found that Goot is about twice as fast at getting a translation and the app startup times is about the same, I know it's quite large though I do have a number of other java apps so the size is of no consequence to me, I would say it all l depends on the hardware being used.

I also have other java apps. I've been using the Firefox/SeaMonkey addon, Quick Translator. Any idea how it compares with these two? I dislike Google almost as much as Microsoft.
https://addons.mozilla.org/en-US/firefo ... ranslator/

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

Re: new version - 0.1b

#17 Post by Geoffrey »

Bernie_by_the_Sea wrote:
Geoffrey wrote: I've done a comparison of Goot and gxlat and found that Goot is about twice as fast at getting a translation and the app startup times is about the same, I know it's quite large though I do have a number of other java apps so the size is of no consequence to me, I would say it all l depends on the hardware being used.

I also have other java apps. I've been using the Firefox/SeaMonkey addon, Quick Translator. Any idea how it compares with these two? I dislike Google almost as much as Microsoft.
https://addons.mozilla.org/en-US/firefo ... ranslator/
I had a look at Quick Translator looks ok if you want to translate web pages into you own language, couldn't see anywhere to convert english into another language which is what I want to use translate for, I find the stand alone translator more versatile for my needs and so far Goot seems to be the quickest on my hardware, I did some more testing and in most cases Goot is up to 7 times faster at getting a translation than gxlat, maybe someone else can test them and see what results they get.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#18 Post by vovchik »

Dear Geoffrey,

As for the speed of Goot, I can only say the gxlat, if you look at the code, posts the query to google's translation engine and displays the results instantaneously. The only delay is the server's response. If Goot uses Google, there response has, by definition, have to be slower, since they have to go through java layers for presentation, whereas gxlat uses straight gtk as rendered by C. If, however, they use another translation engine, therein lies the difference.

With kind regards,
vovchik

PS. I translated the original java APIs found on the Google site :)

User avatar
Geoffrey
Posts: 2355
Joined: Sun 30 May 2010, 08:42
Location: Queensland

#19 Post by Geoffrey »

vovchik,
I can only go on how it runs for me, every test I've done shows that Goot is faster, I just made a short flv of gxlat and Goot in action, this is in real time or very close to it and shows a considerable difference in speed, in some cases Goot is instantaneous.

regards, Geoffrey

mcewanw
Posts: 3169
Joined: Thu 16 Aug 2007, 10:48
Contact:

#20 Post by mcewanw »

vovchik wrote: I still have to do something about escaping double quotes and ampersands in the text. Any ideas? Please look at the function translate in the gxlat script.
Thanks for this dotpet vovchik. It is proving very useful in my multi-lingual household...

You seem to have fixed the issue you had with quotes etc., but I'll take a look in case there is anything I can help suggest further there. I had a lot of such issues to deal with when creating my recent app, Pcreole (my first bit of programming for a few years...) so my mind is fresh on the matter.
github mcewanw

Post Reply