Looking for a bash/sh script to translate a word with Internet (no package to install
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
corp769 I don't know why. I'm just kind of pragmatic and adjusted it out and it worked. F11 is EOL anyway.
Here's the error I got:
Code:
Downloading Packages:
espeak-1.40.02-2.fc11.x86_64.rpm | 695 kB 00:11
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : espeak-1.40.02-2.fc11.x86_64 1/1
Installed:
espeak.x86_64 0:1.40.02-2.fc11
Complete!
[root@maplepark ~]# translate tomorrow EN ES
Original text: tomorrow
Converted text: maņana
Would you like the converted text spoken to you? [Yy/Nn]y
Failed to read voice 'ES+f2'
Wasn't a problem. the man said -f <text> so the code seemed OK. But just deleting it worked fine
Thanks again for the script.
I know why it didn't work.... Because you entered ES, instead of es. For espeak, the parameters and options are case sensitive, whereas google don't care. Try using "es" and "en" instead, and the code I posted will work just fine.
Sorry, I ran your script --languages first and entered the language codes as it said. It does work fine using lower case.
It might have helped better if it had shown lower case. I tried to insert a tr $3 unsuccessfully to insure lc but finally just changed the supported language section.
I'd like to note that some of the languages don't work for me: Armenian ("hy"), Georgian ("ka"), Azerbaijani ("az"), and Kannada ("kn") (and probably a few others; don't feel like going through all of them ) all return the "invalid language pair" error on Google's end.
I'd also like to note that espeak only has voices for probably about half-60% of the languages Google can translate to/from, so IMO it's a bad idea to build in the espeak call in the script. I think it would be more practical to just leave the script as a standalone translator and let the user pipe the output to espeak if it has an appropriate voice*.
How about specifying the input and output languages using options?
If you don't specify the input language, Google Translate can automatically detect it. If you don't specify the output language, it could check the environment variables to see the system's default language.
How about specifying the input and output languages using options?
If you don't specify the input language, Google Translate can automatically detect it. If you don't specify the output language, it could check the environment variables to see the system's default language.
I actually thought of something like that. I just wanted to do something simple though for now....
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.