Jump to content

Google Translate (Languages Configurable)


Recommended Posts

Note: the original version of this workflow utilized an unofficial API that Google Translate exposed. Unfortunately, the Google has shut down the API. There is an alternative workflow that uses the official (paid) Google Translate API that you can find here: http://www.packal.org/workflow/translate-api. It's actually pretty cheap. 

 

Here's a little ditty that interfaces with Google Translate. The upside of this one is that it gives you access to all of Google Translate's languages (or at least about 80 of them). You can enable/disable languages from inside the workflow.

 

Find it on Packal.

 

Demo:

 

translate.gif

 

 

Current Languages:

  1. Afrikaans
  2. Albanian
  3. Arabic
  4. Armenian
  5. Azerbaljani
  6. Basque
  7. Belarusian
  8. Bengali
  9. Bosnian
  10. Brazilian Portuguese
  11. Bulgarian
  12. Catalan
  13. Cebuano
  14. Chinese
  15. Croatian
  16. Czech
  17. Danish
  18. Dutch
  19. English
  20. Esperanto
  21. Estonian
  22. Filipino
  23. Finnish
  24. French
  25. Galician
  26. Georgian
  27. German
  28. Greek
  29. Gujarati
  30. Hatian Creole
  31. Hausa
  32. Hebrew
  33. Hindi
  34. Hmong
  35. Hungarian
  36. Icelandic
  37. Igbo
  38. Indonesian
  39. Irish
  40. Italian
  41. Japanese
  42. Javanese
  43. Kannada
  44. Khmer
  45. Korean
  46. Lao
  47. Latin
  48. Latvian
  49. Lithuanian
  50. Macedonian
  51. Malay
  52. Maltese
  53. Maori
  54. Marathi
  55. Mongolian
  56. Nepali
  57. Norwegian
  58. Persian
  59. Polish
  60. Portuguese
  61. Punjabi
  62. Romanian
  63. Russian
  64. Serbian
  65. Slovak
  66. Slovenian
  67. Somali
  68. Spanish
  69. Swahili
  70. Swedish
  71. Tamil
  72. Telugu
  73. Thai
  74. Turkish
  75. Ukranian
  76. Urdu
  77. Vietnamese
  78. Welsh
  79. Yiddish
  80. Yoruba
  81. Zulu
Edited by Shawn Rice
Link to comment

How can I add an option for Brazilian Portuguese? There are slight differences. The Google code for Brazil is pt-BR, whereas for Portugal it is pt-PT.

 

do I just add another line in languageCodes.php?

'pt-BR' => 'Portuguese-BR',

EDIT: That did it, now I just need a slick icon with the Brazilian flag.

 

EDIT2: pt-BR.png

Edited by DrLulz
Link to comment

How can I add an option for Brazilian Portuguese? There are slight differences. The Google code for Brazil is pt-BR, whereas for Portugal it is pt-PT.

 

do I just add another line in languageCodes.php?

'pt-BR' => 'Portuguese-BR',

EDIT: That did it, now I just need a slick icon with the Brazilian flag.

 

EDIT2: pt-BR.png

 

Yep. That's exactly how you would do it. I made the same changes (mostly) and uploaded a new version onto Packal.

 

Where did you find that language code? It wasn't in the list that I found, which makes me think that there may be more out there that I can add in.

Link to comment

This is so great! My wife is Brazilian, and when her family comes around this will come in handy. I know quite a bit of Portuguese, but this will make it easier to learn. Thanks a bunch. :)

 

It's worth bearing in mind that Google Translate often produces what can be best described as complete bollocks.

 

It's no substitute for a proper dictionary.

 

You might put a bird feeder in your garden to encourage visits from the great tits currently nesting in the area. Google Translate will, like as not, produce some sentence about large breasts…

Link to comment

I'll give you them all. Even "Bork." Now I just have to figure out how the hell I'm going to do icons for all these things.

 

Dean, pretty soon you'll have an easy way to translate everything you write into hacker.

 

:D I don't trust Google Translate in the slightest. Translating is my day job, and I have developed a very healthy, professional distrust of Google Translate.

 

In some situations, it does an exceptionally good job, but in others it's so wide of the mark, it's ridiculous.

 

This particular bug has now been fixed, but it used to translate Wien (Vienna) with Dublin…

Link to comment

Sadly, it looks like those are the web interface codes and not the translation codes. Klingon, Hacker, Elmer Fudd, and a bunch of other ones there aren't actually supported via Google Translate. I'll pare down the list to what is available.

Link to comment

It looks like I could do it (Klingon at least) if I supported the bing translation API, but that seems like a hassle, and it needs an API key, and it limits you to 2 million characters a month for the free tier, so I'm not into that possibility of using my API key as a universal and for the script to, possibly, stop working, and I'm not into requiring others to get an API key, all for Klingon (and maybe a few others). Oh well.

Link to comment
Here's a list of the language codes supported by Google's translate API from https://www.googleapis.com/language/translate/v2/languages (I  have an API key):
 
af
ar
az
be
bg
bn
bs
ca
ceb
cs
cy
da
de
el
en
eo
es
et
eu
fa
fi
fr
ga
gl
gu
ha
hi
hmn
hr
ht
hu
hy
id
ig
is
it
iw
ja
jw
ka
km
kn
ko
la
lo
lt
lv
mi
mk
mn
mr
ms
mt
ne
nl
no
pa
pl
pt
ro
ru
sk
sl
so
sq
sr
sv
sw
ta
te
th
tl
tr
uk
ur
vi
yi
yo
zh
zh-TW
zu

 

Edited by deanishe
Link to comment
  • 1 month later...

Thank you for the workflow. I have some questions:

1) I would like to use the union jack instead of the usa flag for the english language. How can I do it without creating troubles?

2) Russian results are in cyrillic, is there a way to show them in our alphabet?

3) Welsh language uses union jack, I think it should use the welsh one.

Link to comment

Thank you for the workflow. I have some questions:

1) I would like to use the union jack instead of the usa flag for the english language. How can I do it without creating troubles?

2) Russian results are in cyrillic, is there a way to show them in our alphabet?

3) Welsh language uses union jack, I think it should use the welsh one.

 

  1. A splendid idea. Open up the workflow, go into the "icons" directory and overwrite the "en.png" icon with a copy of the "cy.png" one.
  2. Dunno.
  3. Now that's just wrong -_-. Unfortunately, there isn't a Welsh flag included in the workflow. Shawn will have to have a look in the icon set he used to see if there is one.
Link to comment

1. I allow for my American biases. Dean's method works.

 

2. There is always a way, but there isn't one in the workflow, and I'm not going to code support for it. The workflow simply queries Google translate and grabs the results. GT returns Russian results in the appropriate charset (as it does for Arabic, Gujarati, Greek, etc...). If you want to extend the functionality, then you'll need to intercept the results before they are displayed and transliterate them. There are a lot of libraries that exist that can do this sort of thing for you, so your best bet would be to implement one of those.

 

3. I don't think that there was a Welsh flag in the set. This is what I used: http://www.nordicfactory.com/creative/illustrations/download-free-flag-set-in-png/comment-page-1/. While the icons are pretty (hence my desire to use them), I had to spend hours mapping the results to the icons because I needed to look up most of them. If you find one in the set, then let me know.

Link to comment

I did it, thank you! I also changed the icon for latin (reminds me of denmark) with vh.png (vatican).

As for russian, I read what I should do twice and disabled it.

 

Is it possible (in a human way) to show "loading", "..." or just show the flags until results are ready? right now it seems to show the first letter if the query is short and cut in half the phrase if it is long. 

 

One more thing: any chance to have a workflow like this one but for currency conversion? I tried many (one is yours deanishe!) but I would like to type "convert 50" and see enabled currencies instead of "convert x eur to usd" and the like.

Link to comment

I did it, thank you! I also changed the icon for latin (reminds me of denmark) with vh.png (vatican).

As for russian, I read what I should do twice and disabled it.

 

Is it possible (in a human way) to show "loading", "..." or just show the flags until results are ready? right now it seems to show the first letter if the query is short and cut in half the phrase if it is long.

Not really, no. You could make it so the workflow doesn't try to translate unless the query is at least, say, 3 characters, but it's the nature of a workflow that gets its results directly from a webservice that there will be a noticeable delay between your entering the query and the corresponding results being shown.

 

One more thing: any chance to have a workflow like this one but for currency conversion? I tried many (one is yours deanishe!) but I would like to type "convert 50" and see enabled currencies instead of "convert x eur to usd" and the like.

There's this one. Otherwise, it wouldn't be too hard to make one.

If you fancied giving it a try, you could start with my workflow and pull out the irrelevant bits.

Edited by deanishe
Link to comment

Not really, no. You could make it so the workflow doesn't try to translate unless the query is at least, say, 3 characters, but it's the nature of a workflow that gets its results directly from a webservice that there will be a noticeable delay between your entering the query and the corresponding results being shown.

I had that minimum in there, but, apparently, I took that out for some reason. It was a good reason at the time.

 

As Dean said, there is no way to do this (because of how Alfred executes workflows). If you do want to get just want you want, then just copy the word(s) that you want to translate and paste them as the argument.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...