Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 23 Nov 2014, 21:13
All times are UTC - 4
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Documents
gxlat - Desktop Google Translator redux
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 3 [45 Posts]   Goto page: 1, 2, 3 Next
Author Message
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Thu 17 Jun 2010, 15:52    Post subject:  gxlat - Desktop Google Translator redux
Subject description: gui - no browser needed
 

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
gxlat2.jpg
 Description   
 Filesize   28.58 KB
 Viewed   2040 Time(s)

gxlat2.jpg

gxlat.pet
Description 
pet

 Download 
Filename  gxlat.pet 
Filesize  27.04 KB 
Downloaded  891 Time(s) 
Back to top
View user's profile Send private message 
otropogo


Joined: 24 Oct 2009
Posts: 702
Location: Southern Rocky Mt. Trench

PostPosted: Thu 17 Jun 2010, 16:18    Post subject:  

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
Back to top
View user's profile Send private message Visit poster's website 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Fri 18 Jun 2010, 04:46    Post subject:  

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.
Back to top
View user's profile Send private message 
neurino


Joined: 15 Oct 2009
Posts: 360

PostPosted: Sat 04 Sep 2010, 09:38    Post subject:  

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:

#bash way
FROM_TEXT=${FROM_TEXT//&/&amp;}
FROM_TEXT=${FROM_TEXT//"/&quot;}
FROM_TEXT=${FROM_TEXT//</&lt;}
FROM_TEXT=${FROM_TEXT//>/&gt;}

#sed way
#(always thanks potong for enlighting me on sed power)
FROM_TEXT=$(sed -r '
    s/&/&amp;/
    s/"/&quot;/
    s/</&lt;/
    s/>/&gt;/
' <<< $FROM_TEXT)


Get entities here, you can try also decimal values `& 68 ;` etc...

Haven't tested it though...

Greetings
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Sat 04 Sep 2010, 13:34    Post subject:  

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
Back to top
View user's profile Send private message 
neurino


Joined: 15 Oct 2009
Posts: 360

PostPosted: Sat 04 Sep 2010, 14:40    Post subject:  

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 Rolling Eyes Wink )
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Sat 04 Sep 2010, 15:05    Post subject: Daemonization  

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
daemonize-1.5.2.pet
Description 
pet

 Download 
Filename  daemonize-1.5.2.pet 
Filesize  14.11 KB 
Downloaded  657 Time(s) 
Back to top
View user's profile Send private message 
neurino


Joined: 15 Oct 2009
Posts: 360

PostPosted: Sat 04 Sep 2010, 15:29    Post subject:  

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! Very Happy
Back to top
View user's profile Send private message 
aragon

Joined: 15 Oct 2007
Posts: 1698
Location: Germany

PostPosted: Fri 24 Sep 2010, 09:06    Post subject:  

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

_________________
PUPPY SEARCH: http://wellminded.com/puppy/pupsearch.html
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Fri 24 Sep 2010, 16:03    Post subject: gxlat update  

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
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Thu 07 Apr 2011, 04:47    Post subject: new version - 0.1b  

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. Smile

With kind regards,
vovchik
gxlat.jpg
 Description   
 Filesize   76.3 KB
 Viewed   721 Time(s)

gxlat.jpg

gxlat-0.1b.pet
Description 
pet

 Download 
Filename  gxlat-0.1b.pet 
Filesize  44.36 KB 
Downloaded  699 Time(s) 
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1471
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Thu 07 Apr 2011, 05:57    Post subject:  

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.
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1287
Location: Ukraine

PostPosted: Thu 07 Apr 2011, 06:27    Post subject:  

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:
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
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1471
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Thu 07 Apr 2011, 06:29    Post subject: Re: new version - 0.1b  

Quote:
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.
Back to top
View user's profile Send private message 
Geoffrey


Joined: 30 May 2010
Posts: 1471
Location: Queensland Australia ɹǝpu∩uʍop

PostPosted: Thu 07 Apr 2011, 07:37    Post subject:  

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.
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 3 [45 Posts]   Goto page: 1, 2, 3 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Advanced Topics » Additional Software (PETs, n' stuff) » Documents
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0981s ][ Queries: 12 (0.0161s) ][ GZIP on ]