mdict-go-web

command module
v0.0.0-...-8c8ee7e Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: LGPL-2.1 Imports: 25 Imported by: 0

README

MDict go web dictionary

Fast, zero-dependency MDict dictionary that runs in your browser (all-in-one-client-server) on http://localhost:8808.

Download

Get the version for your OS from releases - save the binary; chmod +x mdict-go-web and then run it in the terminal. For help use mdict-go-web -h.

Configuration

Configuration parameters can be set in config.toml or via env vars (which take prescedemce over config.toml); if neither are set then default values are used.

Param CLI flag Env var or config.toml key Default
dict dir --dict-dir DICT_DIR ~/Dictionaries
asset dir --asset-dir MDICT_TEMP_ASSETS_DIR ~/.mdict/res
default dict --default-dict DEFAULT_DICT (none, rel. to dict-dir)
server IP --ip SERVER_IP 127.0.0.1
server port --port SERVER_PORT 8808
speexdec path --speexdec SPEEXDEC /usr/bin/speexdec
no browser --no-browser NO_BROWSER=1 (open browser)
config file --config CONFIG_PATH (auto-detect)

Build from source

With golang environment installed use the following command to build and run the mdict-go-web binary:

make

Run

Run pre-compiled dictionary server:

./mdict-go-web

Pass custom configuration parameters via env vars:

DICT_DIR="~/path/to/custom/dictionaries" SERVER_PORT=8888 ./mdict-go-web

Open in browser:

Help

mdict-go-web --help                               
mdict-go-web — MDict (.mdx/.mdd) HTTP dictionary server

USAGE
  mdict-go-web [flags]

FLAGS
  --config       <path>   Path to config.toml (overrides auto-detect)
                          env: CONFIG_PATH

  --dict-dir     <path>   Directory with .mdx/.mdd dictionary files
                          env: DICT_DIR              toml: DICT_DIR
                          default: ~/Dictionaries

  --asset-dir    <path>   Cache dir for extracted .mdd resources
                          env: MDICT_TEMP_ASSETS_DIR  toml: MDICT_TEMP_ASSETS_DIR
                          default: ~/.mdict/res

  --default-dict <rel>    Default dictionary, relative to dict-dir
                          e.g. "en/Oxford.mdx"
                          env: DEFAULT_DICT           toml: DEFAULT_DICT

  --ip           <addr>   Listen IP address
                          env: SERVER_IP              toml: SERVER_IP
                          default: 127.0.0.1

  --port         <port>   Listen port
                          env: SERVER_PORT            toml: SERVER_PORT
                          default: 8808

  --speexdec     <path>   Path to speexdec binary (Speex audio decoding)
                          env: SPEEXDEC               toml: SPEEXDEC
                          default: /usr/local/bin/speexdec

  --no-browser            Do not open a browser tab on startup
                          env/toml: NO_BROWSER=1

  -h, --help              Show this help and exit

CONFIG FILE SEARCH ORDER
  1. --config flag / CONFIG_PATH env var
  2. <executable-dir>/config.toml
  3. ~/.mdict/config.toml
  4. /etc/mdict/config.toml
  5. ./config.toml

PRIORITY (highest → lowest)
  CLI flag  >  environment variable  >  config.toml  >  built-in default

EXAMPLE config.toml
  DICT_DIR              = "/data/dicts"
  MDICT_TEMP_ASSETS_DIR = "/tmp/mdict-res"
  DEFAULT_DICT          = "en/Oxford.mdx"
  SERVER_IP             = "0.0.0.0"
  SERVER_PORT           = "9000"
  SPEEXDEC              = "/usr/bin/speexdec"
  NO_BROWSER            = "1"

EXAMPLES
  mdict-go-web
  mdict-go-web --dict-dir ~/Books/Dicts --port 9090 --no-browser
  mdict-go-web --config /etc/mdict/config.toml --default-dict "en/Oxford.mdx"
  SERVER_PORT=9000 mdict-go-web

Documentation

Overview

MDict dictionary self-contained HTTP server.

A single binary serves the search page, handles ?q / ?path / ?max queries, and serves .mdd resources extracted on demand into assetRoot.

Configuration priority (highest → lowest):

CLI flag  >  environment variable  >  config.toml  >  built-in default

Config file search order:

--config / CONFIG_PATH  →  <exe-dir>/config.toml  →  ~/.mdict/config.toml
→  /etc/mdict/config.toml  →  ./config.toml

Param CLI flag Env var TOML key Default ───────────────────────────────────────────────────────────────────────────────────── dict dir --dict-dir DICT_DIR DICT_DIR ~/Dictionaries asset dir --asset-dir MDICT_TEMP_ASSETS_DIR MDICT_TEMP_ASSETS_DIR ~/.mdict/res default dict --default-dict DEFAULT_DICT DEFAULT_DICT (none, rel. to dict-dir) server IP --ip SERVER_IP SERVER_IP 127.0.0.1 server port --port SERVER_PORT SERVER_PORT 8808 speexdec path --speexdec SPEEXDEC SPEEXDEC /usr/bin/speexdec no browser --no-browser NO_BROWSER=1 NO_BROWSER=1 (open browser) config file --config CONFIG_PATH — (auto-detect)

Package main: mdict-go-web dictionary server

reader.go exact/prefix/accent-fold lookup with @@@LINK following, HTML definition fix-ups (internal links, audio, sound://, file://, server-absolute refs, spx->wav), stylesheet substitution, and CSS-transitive extraction of .mdd resources into ASSET_ROOT. The raw MDict v1/v2/v3 block parsing is delegated to the vendored go-mdict package.

Directories

Path Synopsis
internal
mdict-go module

Jump to

Keyboard shortcuts

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