Home

Awesome

PyGlossary

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.

Screenshots

<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/44-gtk-txt-stardict-aryanpur-dark.png" width="50%" height="50%"/>

Linux - Gtk3-based interface


<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/40b-tk-bgl-epub-es-en-2.png" width="50%" height="50%"/>

Windows - Tkinter-based interface


<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/32-cmd-freedict-mids-de-ru.png" width="50%" height="50%"/>

Linux - command-line interface


<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/40-cmdi-termux-zim-slob-en-med.jpg" width="50%" height="50%"/>

Android Termux - interactive command-line interface


<img src="https://raw.githubusercontent.com/wiki/ilius/pyglossary/screenshots/50-web-wiktextract-ifo-ar.png" width="50%" height="50%"/>

Web interface

Supported formats

FormatExtensionReadWrite
Aard 2 (slob)🔢.slob
ABBYY Lingvo DSL📝.dsl
Almaany.com (SQLite3, Arabic)🔢.db
AppleDict Binary📁.dictionary
AppleDict Source📁
Babylon BGL🔢.bgl
cc-kedict (Korean)📝
CSV📝.csv
Dict.cc (SQLite3, German)🔢.db
DICT.org / Dictd server📁(📝.index)
DICT.org / dictfmt source📝(.dtxt)
dictunformat output file📝(.dictunformat)
DictionaryForMIDs📁(📁.mids)
DigitalNK (SQLite3, N-Korean)🔢.db
DIKT JSON📝(.json)
EDICT2 (CEDICT) (Chinese)📝(.u8)
EDLIN📁.edlin
EPUB-2 E-Book📦.epub
FreeDict📝.tei
Gettext Source📝.po
HTML Directory (by file size)📁
JMDict (Japanese)📝
JSON📝.json
Kobo E-Reader Dictionary📦.kobo.zip
Kobo E-Reader Dictfile📝.df
Lingoes Source📝.ldf
Mobipocket E-Book🔢.mobi
Octopus MDict🔢.mdx
QuickDic version 6📁.quickdic
SQL📝.sql
StarDict📁(📝.ifo)
StarDict Textual File📝(.xml)
Tabfile📝.txt, .tab
Wiktextract📝.jsonl
Wordset.org📁
XDXF📝.xdxf
Yomichan📦(.zip)
Zim (Kiwix)🔢.zim

Legend:

Note: SQLite-based formats are not detected by extension (.db); So you need to select the format (with UI or --read-format flag). Also don't confuse SQLite-based formats with SQLite mode.

Requirements

PyGlossary requires Python 3.10 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 screenshots, there are multiple User Interface types (multiple ways to use the program).

UI (User Interface) selection

When you run PyGlossary without any command-line arguments or options/flags, PyGlossary will try to run the first available interface in this order:

But you can explicitly select user interface type using --ui

Installation on Windows

Feature-specific requirements

Some formats have additional requirements. If you have trouble with any format, please check the link given for that format to see its documentations.

Using Termux on Android? See doc/termux.md

Configuration

See doc/config.rst.

Direct and indirect modes

Indirect mode means that input glossary is completely read and loaded into RAM, then converted into output format. This was the only method available in old versions (before 3.0.0).

Direct mode means entries are one-at-a-time read, processed and written into output glossary.

Direct mode was added to limit memory usage for large glossaries; But it may reduce the conversion time for most cases as well.

Converting glossaries into these formats requires sorting entries:

That's why direct mode will not work for these formats, and PyGlossary has to switch to indirect mode (or it previously had to, see SQLite mode).

For other formats, direct mode will be default. You may override this by --indirect flag.

SQLite mode

As mentioned above, converting glossaries to some specific formats will need them to loaded into RAM.

This can be problematic if the glossary is too big to fit into RAM. That's when you should try adding --sqlite flag to your command. Then it uses SQLite3 as intermediate storage for storing, sorting and then fetching entries. This fixes the memory issue, and may even reduce running time of conversion (depending on your home directory storage).

The temporary SQLite file is stored in cache directory then deleted after conversion (unless you pass --no-cleanup flag).

SQLite mode is automatically enabled for writing these formats if auto_sqlite config parameter is true (which is default). This also applies to when you pass --sort flag for any format. You may use --no-sqlite to override this and switch to indirect mode.

Currently you can not disable alternates in SQLite mode (--no-alts is ignored).

Sorting

There are two things than can activate sorting entries:

In the case of passing --sort, you can also pass:

Cache directory

Cache directory is used for storing temporary files which are either moved or deleted after conversion. You can pass --no-cleanup flag in order to keep them.

The path for cache directory:

User plugins

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:

Linux packaging status

Packaging status

Using PyGlossary as a library

See doc/lib-usage.md for how to use PyGlossary as a Python library.

Internals

See doc/internals.md for information about internal glossary structure and entry filters.