Jump to content
deanishe

Multilingual translation dictionary with Glosbe.com

Recommended Posts

Translate between hundreds of languages with Glosbe.com.

 

screenshot2.png

By default, the workflow is set up to translate between German and English:

  • .ende English query — show German translations of English query.
  • .deen German query — show English translations of German query.
    • ENTER — copy selected translation to the clipboard.
    • CMD+ENTER — open translation in browser.
  • glosbehelp — open the included help file in your browser.
  • glosbelang [query] — view and search supported languages.
To use other language pairs, you will have to edit the workflow, either changing the included English <-> German Script Filters or adding your own using them as a template.

 

For more information and to download the workflow, see the Packal page or grab it from GitHub.

Edited by deanishe

Share this post


Link to post

This is great, thanks. Especially since the WordReference workflow won't work for those of us who didn't get an API.

 

I added another script filter to let me just type in the three-letter language codes myself, if I want, with keyword ".trans" and script:

python translate.py {query} 

So I can just type ".trans eng fra word" and get an output.

Share this post


Link to post

Yeah, I was upset I didn't get an API key for WordReference  :(

 

That's a good idea, but be aware it won't work if your query has more than one word. You can also use "en" and "fr" for English and French. Save you a couple of characters …

Share this post


Link to post

Thanks, deanishe. Would multiple word queries work in my script filter with some kind of quoting? I can't seem to get multiple words to work with your built-in workflow, either though. Can you give an example?

Share this post


Link to post

For example, balance sheet (as distinct from balance) works fine in the workflow as supplied.

 

You can enter multi-word queries as-is if you enclose the actual query in single-quotes:

 

keyword en de 'balance sheet'

 

Or deselect Double Quotes in the Script Filter's Escaping options, then you can use double quotes to include apostrophes in your query:

 

keyword en de "Fuller's earth"

Edited by deanishe

Share this post


Link to post

Hey, great workflow! One feature request though :)

Since I'm from Denmark i'd need to use weird letters like æ ø å in my queries some times. The workflow doesn't support this. Can this be fixed? :)

Share this post


Link to post

Hey guys

 

I love the script. It is such a time saver.

 

As I am using it for german-serbian, I prefer to open the glosbe URL and looking up all possible translations in full sentences.

 

Therefore my question: How do I change the script so that e.g. after the search ".desrp kindergarten" and pressing ENTER button the URL http://de.glosbe.com/de/sr/kindergarten is opened?

 

I tried the Open URL trigger, but it uses the given translation instead of the original query.

Share this post


Link to post

It's not as straightforward as that, I'm afraid :(

I've updated the workflow with the ability to open the translations in your browser. If you grab the new version from Packal, hitting ⌘+↩ on a result will open the webpage.

I'm afraid you'll have to set up your own keywords again, though, as it will replace them on install. That's probably easier than trying to update the workflow in place by hand.

Share this post


Link to post

It's not as straightforward as that, I'm afraid :(

I've updated the workflow with the ability to open the translations in your browser. If you grab the new version from Packal, hitting ⌘+↩ on a result will open the webpage.

I'm afraid you'll have to set up your own keywords again, though, as it will replace them on install. That's probably easier than trying to update the workflow in place by hand.

 

Wow thx

 

1. Another quick request:

 

When there are no translations for a query, it't not possible to go to the glosbe.com website by using cmd+enter

 

Any chance you can implement it to open the URL in case it shows "No translations for '...'"

 

2. How is the chance to display glosbe examples within alfred results?

Edited by mrgreen

Share this post


Link to post

I've updated the workflow so you can ⌘+↩ on the "No translations…" error to go to the website.

I've also changed it to always show definitions regardless of language (previously, they had to match the destination language).

Regarding examples: no, it's not possible to show them in Alfred, as the Glosbe API does not provide examples.

Edited by deanishe

Share this post


Link to post

Hi, I am having some trouble with another workflow and was wondering if it is possible to use just one command to start the translation. At the moment I need to hit "en" for an translation into German and "de" for a translation into english. However, it would be great if I could just write "de" and get a translation depending of the word I am writing, regardless of the language. The workflow would need to automatically identify which language the word is and give me the output accordingly. 

 

Is this possible? 

 

Cheers 

Share this post


Link to post

Unfortunately, guessing the language of a word is tricky and error prone. It works well when you have several words or sentences to work with, but not with just one word, which is the main use case of this workflow (it's a dictionary rather than a machine translation service).

 

I mean, if I enter die, after, trainee, prise, rat, shooting or kindergarten, are those English or German words?

Share this post


Link to post

I use and like Glosbe workflow a lot,

 

but it has has suddenly stopped working

 

the workflow outputs 'error contacting glosbe.com'

 

here the debug:

 

Starting debug for 'Glosbe Translation'

 

[2019-02-27 11:10:41][ERROR: input.scriptfilter] Code 1: 11:10:41 translate.py:133 DEBUG    script args : [u'eng', u'ita', u'c']

11:10:41 translate.py:135 DEBUG    docopt args : {u'--help': False,

 u'--langs': False,

 u'--openhelp': False,

 u'--text': False,

 u'<dest>': u'ita',

 u'<query>': u'c',

 u'<source>': u'eng'}

11:10:41 translate.py:60 DEBUG    Calling http://glosbe.com/gapi_v0_1/translate with args : {u'dest': u'ita', u'phrase': u'c', u'from': u'eng', u'pretty': u'true', u'format': u'json'}

11:10:41 workflow.py:1894 DEBUG    Cached data saved at : /Users/juliomacr/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/net.deanishe.alfred-glosbe/4f19be0f2b1109e6fcec4edfc976b244.cpickle

11:10:41 workflow.py:2243 ERROR    object of type 'int' has no len()

Traceback (most recent call last):

  File "/Users/juliomacr/Dropbox/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F9FF7FEC-7E02-4F79-8A95-EFE9A465638C/workflow/workflow.py", line 2236, in run

    func(self)

  File "translate.py", line 180, in main

    if not len(results):

TypeError: object of type 'int' has no len()

11:10:41 workflow.py:2267 DEBUG    Workflow finished in 0.270 seconds.

[2019-02-27 11:10:41][WARNING: input.scriptfilter] XML Parse Error 'The operation couldn’t be completed. (NSXMLParserErrorDomain error 64.)'. Row 2, Col 195: 'XML declaration allowed only at the start of the document' in XML:

<?xml version="1.0" encoding="utf-8"?>

<items><item valid="no"><title>Error contacting Glosbe.com</title><subtitle /><icon>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns</icon></item></items><?xml version="1.0" encoding="utf-8"?>

<items><item valid="no"><title>Error in workflow 'net.deanishe.alfred-glosbe'</title><subtitle>object of type 'int' has no len()</subtitle><icon>/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns</icon></item></items>

[2019-02-27 11:10:42][ERROR: input.scriptfilter] Code 1: 11:10:41 translate.py:133 DEBUG    script args : [u'eng', u'ita', u'chai']

11:10:41 translate.py:135 DEBUG    docopt args : {u'--help': False,

 u'--langs': False,

 u'--openhelp': False,

 u'--text': False,

 u'<dest>': u'ita',

 u'<query>': u'chai',

 u'<source>': u'eng'}

11:10:41 translate.py:60 DEBUG    Calling http://glosbe.com/gapi_v0_1/translate with args : {u'dest': u'ita', u'phrase': u'chai', u'from': u'eng', u'pretty': u'true', u'format': u'json'}

11:10:41 workflow.py:1894 DEBUG    Cached data saved at : /Users/juliomacr/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/net.deanishe.alfred-glosbe/61142e8582e6d754836e7b7c06eba7bd.cpickle

11:10:41 workflow.py:2243 ERROR    object of type 'int' has no len()

Traceback (most recent call last):

  File "/Users/juliomacr/Dropbox/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F9FF7FEC-7E02-4F79-8A95-EFE9A465638C/workflow/workflow.py", line 2236, in run

    func(self)

  File "translate.py", line 180, in main

    if not len(results):

TypeError: object of type 'int' has no len()

11:10:41 workflow.py:2267 DEBUG    Workflow finished in 0.307 seconds.

[2019-02-27 11:10:43][ERROR: input.scriptfilter] Code 1: 11:10:42 translate.py:133 DEBUG    script args : [u'eng', u'ita', u'chair']

11:10:42 translate.py:135 DEBUG    docopt args : {u'--help': False,

 u'--langs': False,

 u'--openhelp': False,

 u'--text': False,

 u'<dest>': u'ita',

 u'<query>': u'chair',

 u'<source>': u'eng'}

11:10:42 translate.py:60 DEBUG    Calling http://glosbe.com/gapi_v0_1/translate with args : {u'dest': u'ita', u'phrase': u'chair', u'from': u'eng', u'pretty': u'true', u'format': u'json'}

11:10:43 workflow.py:1894 DEBUG    Cached data saved at : /Users/juliomacr/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Data/net.deanishe.alfred-glosbe/315b3bffae742b7bebdf80c9dfcc2f75.cpickle

11:10:43 workflow.py:2243 ERROR    object of type 'int' has no len()

Traceback (most recent call last):

  File "/Users/juliomacr/Dropbox/Alfred/Alfred.alfredpreferences/workflows/user.workflow.F9FF7FEC-7E02-4F79-8A95-EFE9A465638C/workflow/workflow.py", line 2236, in run

    func(self)

  File "translate.py", line 180, in main

    if not len(results):

TypeError: object of type 'int' has no len()

11:10:43 workflow.py:2267 DEBUG    Workflow finished in 0.438 seconds.

Edited by juliosecco

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...