bob-plugin-mdict

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 25, 2026 License: GPL-3.0

README

MDict for Bob

Current product version: 1.0.0 · local API: v2.

English | 简体中文

Look up your own local MDict dictionaries in Bob, fully offline. Pronunciation audio comes directly from the dictionary's MDD; this project never generates or uses TTS as a fallback.

This project is a reader. It ships no dictionary data. You provide and use your own .mdx and optional .mdd files lawfully.

Highlights

  • MDict v1.x/v2.x, recursive discovery, multiple dictionaries and multi-volume MDD (.mdd, .1.mdd, .2.mdd, …).
  • Completely local: no dictionary API, cloud service, telemetry or outbound request. The companion service listens on loopback only.
  • Structured entries: POS groups, senses and subsenses, bilingual definitions, examples, forms, phrases, idioms, phrasal verbs, cross-references and notes.
  • MDD-backed pronunciation only. UK, US, shared and unlabelled provenance is preserved. There is no text-to-speech fallback anywhere in the project.
  • Simple Bob setup: leave Dictionary ID empty for the first dictionary that contains the word, or set one ID to pin that service instance.

How it works

Bob plugin → http://127.0.0.1:15321 → MDX/MDD → semantic parser
                                              → EntrySet IR → Bob toDict

bob-mdict is a native Go service that owns the indexes, parsing and MDD resources. The Bob plugin is a small JavaScript client; it does not parse MDX, HTML or audio. The two components advertise a versioned local API.

Install

The plugin requires Bob 1.20.0 or later. Its /list control query relies on Bob's query.originalText; ordinary lookups continue to use the preprocessed query.text.

1. Install the service

With Homebrew:

brew install wakewon/tap/bob-mdict
brew services start bob-mdict

Without Homebrew, download bob-mdict-X.Y.Z-macos-installer.tar.gz from the latest release, extract it, and run inside the extracted directory:

./install.sh

The standalone installer places the binary in ~/.local/bin, installs a LaunchAgent and creates the default dictionary directory. To remove the service later, run ./uninstall.sh; it keeps your dictionaries.

2. Add dictionaries

Put each dictionary in its own folder under:

~/Library/Application Support/bob-mdict/dictionaries/

For example:

dictionaries/
├── My Dictionary/
│   ├── My Dictionary.mdx
│   ├── My Dictionary.mdd
│   └── My Dictionary.1.mdd
└── Another Dictionary/
    └── Another Dictionary.mdx

Subfolders are discovered recursively. MDD volumes are matched to the MDX by filename. Rescan and verify:

bob-mdict --rescan
bob-mdict --check
3. Install and add the Bob plugin

Download MDict-vX.Y.Z.bobplugin from the latest release and double-click it. In Bob, open Preferences → Translation → Services, select Text Translation, click +, choose MDict, enable it and save.

Dictionary selection

The plugin deliberately produces one dictionary result per Bob service card.

Dictionary ID empty  → first dictionary containing the queried word
Dictionary ID set    → only that dictionary

Most users should leave the field empty. To find IDs, query exactly /list with the MDict service in Bob. It returns every discovered dictionary, its ID, and unavailable diagnostics. Whitespace around /list is accepted; ordinary list remains a normal dictionary lookup.

To pin several dictionaries at once, add the MDict service to Bob several times and give each instance a different Dictionary ID. Bob controls their order and enabled state, so results remain separate and readable.

Dictionary IDs are 16-character fingerprints sampled from MDX content. Moving or renaming a folder or MDX file does not change an ID. They normally change when the dictionary edition changes. Earlier development builds used path-based IDs; if such an ID stops working, query /list once and replace it.

Lookup direction comes from the installed MDX headword index. Many English-Chinese dictionaries index only English headwords; their Chinese translations are not reverse-search keys. For Chinese-to-English lookup, install an MDX whose headword index contains Chinese entries.

Lookup prefers an exactly cased headword and uses case-insensitive matching only after an exact miss. Result titles and multi-record aliases use the actual selected MDX key: if only china exists, China and CHINA still display and navigate as china; if both China and china exist, they remain distinct.

Multiple records for one headword

Some MDict files store several independent records under the same headword. The default Separate mode shows the first complete record and adds clickable siblings under Other entries, for example wound² and wound³. You can also type wound², wound^2 or wound^{2} directly; wound¹ returns to the first record. A sibling preview ends in … when that record contains further meanings beyond the excerpt. A trailing superscript integer is reserved for this navigation syntax.

Choose Combined in the plugin settings to keep all records in one card, labelled with ¹, ², ³, and so on.

Examples are grouped directly by their displayed sense, such as Examples · verb 1 and Examples · verb 2. See also references are exposed through Bob's structured relatedWordParts representation when possible; phrases and other explanatory sections remain additions.

Plugin settings

Setting Default Meaning
Service URL http://127.0.0.1:15321 Change only when the daemon uses another port.
Dictionary ID empty Empty uses the first match; a value pins one dictionary. Query /list to discover IDs.
Duplicate entry display Separate Show one complete record with clickable Other entries; Combined keeps every ordinal-labelled record in one card.
Show examples on Show examples and bilingual translations.
Show extras on Show phrases, idioms, phrasal verbs, structured cross-references, forms and notes.
Max examples per sense 3 Limit examples independently for each sense or subsense.

pluginValidate checks service identity and API version, the presence of a healthy dictionary, and a configured Dictionary ID before the first lookup.

Command line

bob-mdict --version
bob-mdict --check
bob-mdict --list-dictionaries
bob-mdict --rescan
bob-mdict --debug-lookup WORD

The local HTTP API is documented in docs/API.md.

Troubleshooting

Cannot connect to the local service
brew services start bob-mdict
curl http://127.0.0.1:15321/v2/status

Confirm that the plugin's Service URL uses the daemon's actual port. The status response identifies the running process with serviceVersion, buildCommit and apiVersion; building another binary does not update that process.

No dictionaries were found
open ~/Library/Application\ Support/bob-mdict/dictionaries/
bob-mdict --rescan
bob-mdict --list-dictionaries

Every dictionary needs an MDX. MDD is optional and supplies resources such as recordings.

The configured ID is invalid or unavailable

Query /list in Bob, copy the current ID, and update that MDict service instance. An unavailable entry includes its diagnostic; other dictionaries continue to work.

A word has no audio button

Audio appears only when the entry references a real recording that resolves in the matching MDD. No MDD, missing resource, or absent recording means no audio button. The project never substitutes TTS.

Some MDD audio is missing

Older dictionaries may store Ogg-Speex (.spx) recordings. Install a decoder:

brew install speex

Decoded WAV files are cached locally. On startup, entries older than 30 days are removed and the cache is capped at 256 MiB.

Plugin and service versions are incompatible
brew upgrade bob-mdict

Then update the Bob plugin from the release page.

Privacy and security

  • Lookups and resources stay on your Mac; there is no analytics or telemetry.
  • The service binds only to 127.0.0.1/::1 and rejects non-loopback origins.
  • MDD resources use opaque, per-process tokens; no filesystem path is exposed.
  • No endpoint accepts an arbitrary path and the service makes no outbound network request.

This repository, its binaries and its plugin packages contain no dictionary content. MDX/MDD files remain the property of their publishers; users are responsible for obtaining and using them lawfully.

Tracked parser fixtures are minimal synthetic documents built specifically for tests. They contain invented words, definitions, translations, examples and resource paths; only the few selectors/classes and DOM relationships required for compatibility tests are retained.

The project is licensed under GPL-3.0-or-later. See LICENSE and THIRD_PARTY_NOTICES.md.

Development

gofmt -w .
go vet ./...
go test ./...
go test -race ./...
node --test plugin/main.test.js
./scripts/release.sh doctor
./scripts/release.sh dev
./scripts/release.sh build

release.sh build is pure: it writes only ignored release artifacts and proves that tracked source is unchanged. The development command labels dirty builds explicitly, safely updates the standalone LaunchAgent, and refuses to replace a Homebrew- or otherwise-managed daemon. Release operations are documented in docs/RELEASE.md.

Real-dictionary integration tests never write entry content into tracked snapshots. Point them at a lawful local library:

BOB_MDICT_TEST_DICTIONARIES=/path/to/dictionaries go test ./internal/service -v

More detail: Architecture · Parser · HTTP API

Directories

Path Synopsis
cmd
bob-mdict command
Command bob-mdict is the local companion service for the MDict Bob plugin.
Command bob-mdict is the local companion service for the MDict Bob plugin.
internal
bobadapter
Package bobadapter renders the dictionary-neutral Entry IR into Bob's documented toDict structure.
Package bobadapter renders the dictionary-neutral Entry IR into Bob's documented toDict structure.
config
Package config resolves the on-disk locations and runtime settings used by the bob-mdict service.
Package config resolves the on-disk locations and runtime settings used by the bob-mdict service.
entryir
Package entryir defines the dictionary-neutral intermediate representation that every parser produces and every output adapter consumes.
Package entryir defines the dictionary-neutral intermediate representation that every parser produces and every output adapter consumes.
httpapi
Package httpapi exposes the service over loopback HTTP.
Package httpapi exposes the service over loopback HTTP.
mdict
Package mdict wraps the low-level MDX/MDD engine with the behaviour this project needs: recursive discovery, stable dictionary IDs, correct @@@LINK redirection, normalized lookup, and O(1) MDD resource resolution.
Package mdict wraps the low-level MDX/MDD engine with the behaviour this project needs: recursive discovery, stable dictionary IDs, correct @@@LINK redirection, normalized lookup, and O(1) MDD resource resolution.
parser
Package parser turns heterogeneous dictionary HTML into the Entry IR.
Package parser turns heterogeneous dictionary HTML into the Entry IR.
profiles
Package profiles embeds the declarative dictionary profiles and selects the best match for a dictionary.
Package profiles embeds the declarative dictionary profiles and selects the best match for a dictionary.
resource
Package resource turns MDD references into opaque, tamper-proof URL tokens and serves the bytes behind them.
Package resource turns MDD references into opaque, tamper-proof URL tokens and serves the bytes behind them.
service
Package service is the application core: it owns the dictionary registry, picks parser profiles, resolves lookups and mints resource URLs.
Package service is the application core: it owns the dictionary registry, picks parser profiles, resolves lookups and mints resource URLs.
testmdx
Package testmdx writes tiny, from-scratch MDX fixtures for integration tests.
Package testmdx writes tiny, from-scratch MDX fixtures for integration tests.
version
Package version carries build-time identity for the bob-mdict service.
Package version carries build-time identity for the bob-mdict service.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL