Apple Dictionary
The built-in macOS dictionary offers excellent lookup functionality activated by force touch (or tapping with three fingers); sadly, this feature is not supported on all applications. Therefore, I want to integrate the lookup feature from Apple Dictionary into Easydict, providing a swift and convenient word search using the system dictionary.
Easydict supports built-in dictionaries within Dictionary.app, including dictionaries like the Oxford English-Chinese Dictionary (Simplified Chinese-English) and the Modern Chinese Standard Dictionary (Simplified Chinese). To utilize these dictionaries, simply activate them within Dictionary.app.
Furthermore, Apple Dictionary also supports custom import dictionaries. This means that we can add third-party dictionaries like the Concise English-Chinese Dictionary or the Longman Dictionary of Contemporary Advanced English by importing them in the .dictionary format.
Adding third-party dictionaries
⚠️ To alleviate concerns related to copyright, acquire your paperback copy or app.
The easiest way to add a dictionary to macOS is to find a converted .dictionary file, drag it into the Dictionary folder of Apple Dictionary, and then restart the Dicionary.app to ensure the new dictionary appears in the Settings.
Attention: Each time a new dictionary is added, Easydict needs to be restarted to see the changes in effect. Also, modifying the dictionary application settings may cause Easydict to crash; this is an expected behaviour.
For your convenience, I've created several .dictionary files and put them on Google Drive, so you can directly download and use them.
Longman, Collins, and Oxford are three substantial yet outstanding dictionaries. However, due to the extensive content in their entries, they may impact the loading speed of Easydict queries. Therefore, it is advisable to select only one of your favourites.
Concise English-Chinese dictionary
Youdao Words Analysis
Great Cictionary
Longman Dictionary of Contemporary Advanced English
Collins Advanced English-Chinese Dictionary
Oxford Advanced Learner's English-Chinese Dictionary (8th Edition)
Oxford Advanced Learner's English-Chinese Dictionary (8)
I can't remember the source of this dictionary, but the point is that the css of this dictionary was tuned by myself when I was learning how to make dictionaries, and the internal DefaultStyle.css
file has detailed annotations, so beginners who want to try to customize the interface of the dictionary can start from this css.
How to make a .dictionary dictionary
Attention: This part of the doc is aimed at advanced users, who need a bit of programming knowledge and love to spend time on this.
Below is an introduction to how to use the open-source project pyglossary to convert Mdict dictionaries into .dictionary files. This doc is based on pyglossary apple.
Preparations
- Install Python library
sudo pip3 install lxml beautifulsoup4 html5lib
Install Command Line Tools for Xcode
Install Dictionary Development Kit
Dictionary Development Kit is part of Additional Tools for Xcode, after downloading, you need to move
Dictionary Development Kit
to/Applications/Utilities/Dictionary Development Kit
.Download pyglossary
Please move the downloaded pyglossary library to a fixed directory, you will need it every time you convert a dictionary.
Assuming that pyglossary-master is located at
~/Downloads/pyglossary-master
Mdict dictionary resources are available from the following website:
Now let's begin.
Steps of conversion
Suppose the dictionary file in Mdict format is located in ~/Downloads/oald8/oald8.mdx
, and the picture and speech file oald8.mdd
are also in the same folder.
cd ~/Downloads/oald8/
python3 ~/Downloads/pyglossary-master/main.py --write-format=AppleDict oald8.mdx oald8-apple
cd oald8-apple
sed -i "" 's:src="/:src=":g' oald8-apple.xml
make
If all goes well, you will end up with an objects
file in that directory, with oald8-apple.dictionary
in it, which is the converted Apple dictionary, which you can drag into the Dictionary folder.
Note that the dictionary generated above has a very simple interface, and usually Mdicts circulating on the web will come with a copy of beautified css, such as oald8.css
. Since pyglossary does not handle css automatically, we need to do it manually by copying the contents of oald8.css
and appending it to the DefaultStyle.css
inside the oald8-apple.dictionary
file. If you want to customize the css, you also modify this file.
The name of the dictionary can be changed via Info.plist
, where the Bundle name
is the name of the dictionary to be displayed in the application interface, and the Bundle display name
is the name of the dictionary to be displayed in the settings page. For convenience, it is recommended that both be set to the same value.
END.