A tool for converting dictionary files aka glossaries.
The primary purpose is to be able to use our offline glossaries in any Open Source dictionary we like on any OS/device.
There are countless formats, and my time is limited, so I implement formats that seem more useful for myself, or for Open Source community. Also diversity of languages is taken into account. Pull requests are welcome.
Linux - Gtk3-based interface
Windows - Tkinter-based interface
Linux - command line interface
|Aard 2 (slob)||.slob|
|ABBYY Lingvo DSL||.dsl|
|Dict.cc (SQLite3, German)|
|DICT.org / Dictd server||(
|DICT.org / dictfmt source file||(.dtxt)|
|dictunformat output file||(.dictunformat)|
|DigitalNK (SQLite3, N-Korean)|
|HTML Directory (by file size)|
|Kobo E-Reader Dictionary||.kobo.zip|
|Kobo E-Reader Dictfile||.df|
📁Directory 📝Text file 📦Package/archive file 🔢Binary file ✔Supported ❌Will not be supported
PyGlossary requires Python 3.6 or higher, and works in practically all modern operating systems. While primarily designed for GNU/Linux, it works on Windows, Mac OS X and other Unix-based operating systems as well.
As shown in the screenshots, there are multiple User Interface types (multiple ways to use the program).
Gtk3-based interface, uses PyGI (Python Gobject Introspection) You can install it on:
apt install python3-gi python3-gi-cairo gir1.2-gtk-3.0
zypper install python3-gobject gtk3
dnf install pygobject3 python3-gobject gtk3
pacman -S python-gobject gtk3
- Mac OS X:
brew install pygobject3 gtk+3
- Nix / NixOS:
nix-shell -p gnome3.gobjectIntrospection python37Packages.pygobject3 python37Packages.pycairo
Tkinter-based interface, works in the lack of Gtk. Specially on Windows where Tkinter library is installed with the Python itself. You can also install it on:
apt-get install python3-tk tix
zypper install python3-tk tix
yum install python3-tkinter tix
- Mac OS X: read https://www.python.org/download/mac/tcltk/
- Nix / NixOS:
nix-shell -p python37Packages.tkinter tix
Command-line interface, works in all operating systems without any specific requirements, just type:
python3 main.py --help
When you run the program without any command line arguments or options, PyGlossary tries to find PyGI, if it's installed, opens the Gtk3-based interface, if it's not, tries to find Tkinter and open the Tkinter-based interface. And exits with an error if neither are installed.
But you can explicitly determine the user interface type using
python3 main.py --ui=gtk
python3 main.py --ui=tk
sudo pip3 install lxml beautifulsoup4
Reading from FreeDict, XDXF or JMDict
sudo pip3 install lxml
Reading from cc-kedict
sudo pip3 install lxml PyYAML
Reading from Babylon BGL: Python 3.6 to 3.7 is recommended
Reading or writing Aard 2 (.slob) files
sudo pip3 install PyICU
Writing to Kobo E-Reader Dictionary
sudo pip3 install marisa-trie
Reading from Zim (see #228)
sudo pip3 install libzim
Reading from CC-CEDICT
sudo pip3 install jinja2
Reading from Octopus MDict (MDX)
python-lzois required for some MDX glossaries. First try converting your MDX file, if failed (
AssertionErrorprobably), then try to install LZO library and Python binding.
Using Termux on Android? See doc/termux.md
If you want to add your own plugin without adding it to source code directory, or you want to use a plugin that has been removed from repository, you can place it in this directory:
See doc/apple.md for AppleDict requirements and instructions.
Internal Glossary Structure
A glossary contains a number of entries.
Each entry contains:
- Headword (title or main phrase for query)
- Alternates (some alternative phrases for query)
In PyGlossary, headword and alternates together are accessible as a single Python list
entry.defi is the definition as a Python Unicode
entry.b_defi is definition in UTF-8 byte array.
entry.defiFormat is definition format. If definition is plaintext (not rich text), the value is
m. And if it's in HTML (contains any html tag), then
m. The value
x is also allowed for XFXF, but XDXF is not widely supported in dictionary applications.
There is another type of
Entry which is called Data Entry, and generally contains image files, TTL or other audio files, or any file that was included in input glossary. For data entries:
entry.s_wordis file name (and
l_wordis still a list containing this string),
entry.datagives the content of file in