Immersive currently supports two dictionary formats: Yomichan and Migaku. Both need to be configured slightly differently.
The first time a dictionary is accessed, it is imported, which can take some
time. After that it is loaded into memory until the active mpv instance is
closed. New instances of Immersive can load a cached version of the dictionary
from disk which will take less time. By default, dictionaries are only loaded
once they are used, however setting the script config
option preload_dictionaries
to yes
/true
will load all dictionaries every
time mpv is started. This will cause Immersive (but not mpv) to be
unresponsive for several seconds on startup.
Every dictionary has its own config section. Each one also has an exporter,
which is responsible for turning its data into a format that is usable by
Anki. Options that configure the exporter must be prefixed with export:
in
the config file, e.g. export:template
. Exporters make heavy use of
templates.
If desired, dictionaries can be divided into multiple groups (by giving each
section a group
entry) in order to limit which dictionaries are directly
accessible during definition selection. The active dictionary group can be
changed in the target/dictionary menu (Ctrl
+A
) at any time.
type
: The type of the dictionary. Allowed values areyomichan
andmigaku
.location
: The location of the dictionary files. This needs to be an absolute path, so one starting with/
on Unix orC:\
/D:\
/etc. on Windows.group
: Which group the dictionary belongs to. The default value isdefault
.preload
: If set toyes
/true
, always preload this dictionary, regardless of the script settingpreload_dictionaries
. If set tono
/false
, never preload this dictionary. If unset (default), use the aforementioned script setting.exporter
: The exporter used for generating the field template variable{{definitions}}
. Currently onlydefault
is available for either dictionary type, which is also used ifexporter
is not set.quick_def_template
: template used for rendering the definitions shown in mpvexport:<exporter option>
: config entries used by the exporter.transformations
: Transformations to apply to the selected text when invoking lookup withCtrl
+⏎
.
See here for more details.
Yomichan dictionaries need to be unzipped into a directory first, which is
then used as the value of location
. For example, if you downloaded
jmdict_english.zip
from the Yomichan website and extracted it to a folder in
your home directory, the location entry should look something like this:
location=/home/<user name>/jmdict_english
(Unix) or location=C:\Users\<user name>\jmdict_english
(Windows), with jmdict_english
being the folder that
contains the file index.json
and the term/tag banks of the dictionary.
The dictionary config entry insert_cjk_breaks
inserts a soft line break
after each of the following fullwidth characters before rendering the
definition that is shown inside mpv: 。、,!?;:
. This can be useful for
monolingual Japanese dictionaries that have definitions which otherwise
wouldn't fit on the screen.
quick_def_template
for Yomichan has the following template variables:
Variable | Type | Description |
---|---|---|
quick_def_template |
||
readings |
list |
all readings of the dictionary entry |
variants |
list |
all variants of writing the word |
definitions |
list |
all definitions of the entry |
Its default value is:
{{readings:::・}}{{variants:【:】:・}}: {{definitions:::; }}
The default Yomichan exporter can be configured with the following options:
digits
: Replacement digits for the definition number. The value should contain exactly ten characters. For example set this to0123456789
if you want to use fullwidth digits. Unset by default, in which case regular ASCII numerals (0123456789
) are used.reading_template
: Template used for displaying each reading and its variants. Default:
{{reading}}{{variants:【:】:・}}
definition_template
: Template for each separate definition in an entry.
{{tags:<span style="font-size\: 0.8em">:</span><br>:, }}{{num}}. {{keywords:::; }}
template
: Template for the final exported entry.
{{readings[1]}}:{{readings[2:] (:): }}<br>{{definitions:::<br>}}
use_single_template
: If set toyes
/true
, usesingle_template
for rendering entries that only have a single definition. Enabled by default.single_template
: Default:
{{readings[1]}}:{{readings[2:] (:): }} {{keywords:::; }}
All defaults are set so that entries of the Yomichan version of JMdict are exported in a format somewhat similar to Jisho.org.
The Yomichan exporter works as follows:
-
Group all variants of the word by reading. These will be rendered using
reading_template
. -
Go through the definitions of the dictionary entry one by one. If the tags for the definition are different from those of the previous one, insert them into the template data. Render the definition using
definition_template
, with the tags (if present), the keywords and the number. If it is set, the digits of the number are taken fromdigits
. -
Render
template
using the readings and definitions from steps 1. and 2. Alternatively, ifuse_single_template
istrue
, rendersingle_template
using the readings and the keywords from the only definition. The result of either of these is what will be exported to Anki.
Template overview:
Variable | Type | Description |
---|---|---|
reading_template |
||
reading |
single |
the reading itself; usually hiragana but sometimes katakana |
variants |
list |
all variants of writing the word with this reading |
definition_template |
||
tags |
list |
all tags for the dictionary entry |
num |
single |
the number of the definition, with the digits taken from digits |
keywords |
list |
the keywords for the definition |
template |
||
readings |
list |
all readings as generated from reading_template |
definitions |
list |
all definitions as generated from definition_template |
single_template |
||
readings |
list |
same as for template |
keywords |
list |
keywords of the single definition |
For Migaku dictionaries location
is simply the path of the dictionary's JSON
file, so something like this: location=/home/<user name>/Migaku_Dictionary.json
(Unix) or location=C:\Users\<user name>\Migaku_Dictionary.json
(Windows).
quick_def_template
for Migaku has the following template variables:
Variable | Type | Description |
---|---|---|
quick_def_template |
||
terms |
list |
all terms associated with the definition |
altterms |
list |
alternative versions of the above terms |
definitions |
list |
all definitions of the entry |
Its default value is:
{{definitions}}
The Migaku format is much simpler than Yomichan's, and so is its exporter. It
uses the template provided in the config option export:template
directly on
the dictionary data.
Variable | Type | Description |
---|---|---|
template |
||
terms |
list |
terms associated with the definition |
altterms |
list |
alternative versions of the above terms |
definition |
single |
the definition itself; it should already be in an Anki-friendly format |
pronunciations |
list |
pronunciations associated with the definition |
positions |
list |
parts of speech associated with the definition |
examples |
list |
example sentences |
All list entries aside from terms
(and possibly altterms
) will most likely
only contain a single item.
The default value of export:template
is:
{{terms[1]}}{{terms[2:] (:):, }}:<br>
{{altterms::<br>:, }}{{pronunciations::<br>:, }}{{positions::<br>:, }}
{{definition}}
{{examples:::, }}