ninja33 / ODH

A chrome extension to show online dictionary content.
MIT License
1.4k stars 240 forks source link

How to test script and are offline dictionaries possible? #313

Closed Georgebuk closed 11 months ago

Georgebuk commented 12 months ago

Hello, apologies if this isn't the right place to post a question.

Firstly, how does one actually test a script they have made? I made a very simple test script for the Collins En -> Japanese dictionary and wanted to try it. However, I'm unsure of how to test it. The 'Script Options' section of the settings has a 'User Defined Scripts' section, but I'm not quite sure how to actually add my file. Do I need to host the script externally somewhere and then add the URL to the extension? If so, how would one do this?

Secondly, does this app have the function to, or intend to have the function of using offline dictionaries? I found an open-source English -> Japanese dictionary I'd like to use here: https://github.com/gunyarakun/kantan-ej-dictionary

I prefer the use of an offline dictionary as the load time for lookups is a lot quicker than scraping the data from an online dictionary like Collins for each lookup. If there's a specific format you'd like the above dictionary to be in, I'm more than happy to convert it.

Thanks.

ninja33 commented 12 months ago

For your first question, you can host your script at online code sharing site, for example. I have some online scripts on gist for testing purpose, it is at https://gist.github.com/ninja33 you can select one script by clicking it's name, then click "Raw" on right-top of the script code. the browser url text field will show your the real script address. copy & paste it in ODH option -> 'User Defined Scripts' section, load or save option again.

For secondary question, ODH doesn't provide offline dictionaries function itself, because, usually, offline dictionaries are in different format. ODH can't cover all of them. You can try to convert the offline dictionary and provide an online (local host) interface by yourself, and then write a specified user script to read this local hosted 'online' dictionary, I also have a sample here https://github.com/ninja33/mdx-server which uses python code to convert mdx/mdd offline dictionary to a http local server.

Georgebuk commented 12 months ago

Thanks for your assistance. I've managed to create an EN -> JP dictionary script which I have now made a pull request for. I'll look into creating an offline dictionary soon but in the meantime, the online dictionary is an excellent alternative.

By the way, which Anki deck format do you use for your flashcards? I was going to create my own, but the deck type you use in your example screenshots looks very good.

Georgebuk commented 11 months ago

Apologies for the dumb question. I found your anki templates here: https://github.com/ninja33/anki-templates

I'll close the issue now. Thank you.