Jump to content

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
Link to comment

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.

Link to comment

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
Link to comment
  • 4 weeks later...

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.

Link to comment

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.

Link to comment
  • 2 months later...

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
Link to comment

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
Link to comment
  • 2 months later...

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 

Link to comment

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?

Link to comment
  • 4 years later...

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