Jump to content

Recommended Posts

I coded a little workflow for translation that is powered by dict.cc. I saw this workflow over here http://www.alfredforum.com/topic/8286-dictcc-translate-english-to-german/ and there was some demand for another one that works offline. So here it is:

 

Features:

 
  • Offline translation with dictionaries powered by dict.cc
  • Highly flexible, integrate as many language packs as you want
  • Easy to setup
 
A little bit hidden features:
 
  • Copy the translated word to the clipboard by actioning it
  • Copy the word in the origin language to the clipboard by actioning it with cmd as modifier

 

7kwcDCu.png

 

I tried to make the setup progress as simple as possible. Unfortunately you are not allowed to distribute the offline files, which are provided by dict.cc. But some of them are also very huge, so it is unexpedient too.
 
You can see here how to configure this workflow:
 
You can download the workflow from the Github Releases page or from packal.org:
 
Here it is in action: 
Edited by PhilippN

Share this post


Link to post

Ah yes, great idea. I hate databases, so they were out of my mind :D

 

Anyway, I pushed a new release which uses a SQLite database. Depending on the query search is faster now. But even if it is slower sometimes, I think the database solution is much better.

Share this post


Link to post

Ah yes, great idea. I hate databases, so they were out of my mind :D

 

Anyway, I pushed a new release which uses a SQLite database. Depending on the query search is faster now. But even if it is slower sometimes, I think the database solution is much better.

 

 

I had a quick glance at the code. The slowness is mostly down to the use of sqlalchemy, which is big. It's an industrial strength library, not ideally suited to small scripts meant to run fast.
 
I did a little bit of benchmarking, and it takes ~0.2s for sqlalchemy just to import on my machine (old but has an SSD). With Alfred-Workflow, you're looking at a minimum of ~0.1s before your code starts running (0.05s for Python to start up plus 0.05s till Workflow.run() calls your main() function).
 
That means it takes over 0.3 seconds before workflowScript.py even does anything, which is a noticeable delay.
 

 

To speed it up, I'd consider using peewee instead of sqlalchemy. It's much smaller, so will probably load noticeably faster.

Share this post


Link to post

Hey there, 

 

I am in urgent need of an alternative to the Leo dictionary workflow, so I found this. 

 

Wanted to do the last step and finally parse that stuff, but I got the following error:

 

python "/Users/David/Dropbox/Alfred Sync Folder/Alfred.alfredpreferences/workflows/user.workflow.9B955379-60E9-4C05-A5BD-D89026DF606C/parseDictsData.py" "/Users/David/Library/Application Support/Alfred 3/Workflow Data/de.nieting.DictCC"
Traceback (most recent call last):
  File "/Users/David/Dropbox/Alfred Sync Folder/Alfred.alfredpreferences/workflows/user.workflow.9B955379-60E9-4C05-A5BD-D89026DF606C/parseDictsData.py", line 299, in <module>
    main()
  File "/Users/David/Dropbox/Alfred Sync Folder/Alfred.alfredpreferences/workflows/user.workflow.9B955379-60E9-4C05-A5BD-D89026DF606C/parseDictsData.py", line 124, in main
    settings = ujson.loads(open(os.path.join(dirName, "dictccSettings.json")).read())
ValueError: Expected object or value

 

 

Can you please update that workflow? I also had to run the fixum workflow to even start using the dict.cc workflow. Is there anything that can be done? 

I really need a reliable german-english translator workflow. I used Leo every day. 

 

 

 

 

Share this post


Link to post
14 hours ago, deanishe said:

 

Looks like you broke the JSON file.

 

my dictaSettings.json file looks like this:

 

[{
    "downloadedDictionaryFile": "/Users/David/Library/Application Support/Alfred 3/Workflow Data/de.nieting.DictCC/cmkdkkkgmm-8718512140-eiiiie.txt",
    "languageOrderInDictionaryFile": [{
        "identifier":"de",
        "completeName":"German",
        "icon":"icons/icon.png"
    },{
        "identifier":"en",
        "completeName":"English",
        "icon":"icons/icon.png"
    }],
    "supportedDirection":"both"
},{
    ** second translation configuration goes here (same keys as before) **
}]

 

Share this post


Link to post
40 minutes ago, deanishe said:

Paste the whole file in here:

 

https://jsonlint.com/

 

Thank you, I had to remove the following part:

 

,{
    ** second translation configuration goes here (same keys as before) **
}

 

 

 

Now, is there a way to use both directions in this workflow without having to choose the direction first? For instance I would like to type in "hello" and "Hallo" and the workflow would detect the language and translate it? Or it would simply display both translations?

 

 

Share this post


Link to post

Oh, right. That was the whole file.

 

I have no idea how the workflow works. I don’t have it.

 

”supportedDirection”: “both” would indicate it works in both directions. 

 

Share this post


Link to post

Hi all, 

 

…since the Leo Workflow stopped working (due to timeout) and reading that they asked the workflow to not be published furthermore (see https://github.com/psistorm/alfredapp) I am also looking for an alternative and this works really good. I have a question though: Is there any way to reverse the display within the results list? Looking at the following screenshot, from a UX perspective, I find it irritating that the term I already know (water in this case) is shown large - since the translation "Nass" is really what I'm after. Does anyone have a hint how this would be possible, if at all? Any hint is highly appreciated.

 

 

dic-en-de-water.thumb.jpg.d0b70b7b6b01463699c71c7091591866.jpg

 

 

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