Skip to content

Definitions

This page is dedicated to showcasing how definitions can be easily chosen, overwritten and customized overall.

Note

This page is primarily intended for monolingual dictionary users, as the sheer amount of possible monolingual dictionaries may require specific customizations for each individual dictionary.


Dictionary Placement

This section deals with how the custom Yomichan Templates categorizes dictionaries, and how to properly customize them for your setup.

Expected Dictionary Placement

Dictionaries from Yomichan are sorted into the following fields:

  • PrimaryDefinition: A dictionary specified by the user. Bilingual by default.

    This can be changed in many different ways.

  • SecondaryDefinition: All bilingual dictionaries outside of the one in PrimaryDefinition

  • ExtraDefinitions: All monolingual dictionaries outside of the one in PrimaryDefinition

  • UtilityDictionaries: All traditionally-formatted dictionaries that do not belong in any of the above categories (in other words, does not provide the meaning of the word).

    An example is the JMdict Surface Forms dictionary

    Note

    This does not include pitch accent dictionaries, frequency lists, or kanji dictionaries, as these are not traditionally-formatted dictionaries.

The way that the dictionaries are sorted into the appropriate fields is by assigning a category to each individual dictionary.


Verifying Categories

You can check that your dictionaries are correctly categorized with the {jpmn-test-dict-type} marker. Under the Anki Templates code, replace Card field with {jpmn-test-dict-type} and press Test.

checking dictionary categories

An example output of the above (on the word 結構) is the following:

「旺文社国語辞典 第十一版」: monolingual
「明鏡国語辞典 第二版」: monolingual
「ハイブリッド新辞林」: monolingual
「新明解国語辞典 第五版」: monolingual
「デジタル大辞泉」: monolingual
「NHK日本語発音アクセント新辞典」: utility
「JMDict Surface Forms」: utility
「JMdict (English)」: bilingual
「JMdict (English)」: bilingual
「JMdict (English)」: bilingual
「JMdict (English)」: bilingual
「JMdict (English)」: bilingual
「新和英」: bilingual

If a dictionary is miscategorized, you will have to edit bilingual-dict-regex or utility-dict-regex at the top of the template code. Monolingual dictionaries are considered to be dictionaries that aren't either of the two above, so no handlebars code has to be changed if one were to use more monolingual dictionaries.

To see how to edit the regex, go to this section.


Ignoring a Dictionary

If you want to see the dictionary on Yomichan but not have it show on Anki, you can use the ignored-dict-regex option.

To see how to edit the option, see the section below.

Conversely, if you want to not see the dictionary on Yomichan but want it to show up on Anki, see here.

Note

It is recommended to not use this option, so you have as much information as possible within the note. If you wish to not see a dictionary, it might be easier to collapse the dictionary.


Editing the dictionary regex

To modify a regex string:

  1. Determine the exact tag your dictionary has. To see this, take a word that has a definition in the desired dictionary, and test {jpmn-test-dict-type} like above. The string inside the quotes 「」 is exactly the tag of the dictionary.

  2. Add the dictionary tag to the string, by replacing ADD_x_DICTIONARIES_HERE. For example, if your bilingual dictionary tag is Amazing Dictionary, change ADD_BILINGUAL_DICTIONARIES_HERE to Amazing Dictionary.

    If you want to add more than one dictionary, they have to be joined with the | character. For example, if you want to add the bilingual dictionaries Amazing Dictionary and Somewhat-Okay-Dictionary, change ADD_BILINGUAL_DICTIONARIES_HERE to Amazing Dictionary|Somewhat-Okay-Dictionary.

    For completeness, here is the modified line for the second example:

    {{~#set "bilingual-dict-regex"~}} ^(([Jj][Mm][Dd]ict)(?! Surface Forms)(.*)|新和英.*|日本語文法辞典.*|Amazing Dictionary|Somewhat-Okay-Dictionary)$ {{~/set~}}
    


Primary Definition Selection

Automatic Selection (Bilingual or Monolingual)

The dictionary for the primary definition is the first bilingual dictionary (that appears on Yomichan) by default.

This can be changed to the first monolingual dictionary by changing the following Yomichan template option to monolingual:

{{~! valid values: "bilingual", "monolingual" ~}}
{{~#set "opt-first-definition-type" "monolingual"}}{{/set~}}

Manual Selection

Sometimes, you may want to override the primary definition, or highlight the definition that makes sense with the context.

By default, selecting (highlighting) the text will do nothing, to prevent any unexpected errors from happening. However, the user can set the following Yomichan template option to allow selecting text to override the automatic dictionary selection behavior:

{{~! options related to selected text ~}}
{{set "opt-selection-text-enabled" true}}

Setting this option will enable the following behavior:

  1. If nothing is selected, then the first dictionary is chosen just like normal.

  2. If a dictionary is selected, then that dictionary will replace the first definition.

    To disable this, set opt-selection-text-dictionary to false.

  3. If a section of text is selected, then that dictionary will replace the first definition. Additionally, that section of text will be highlighted (bolded).

    To disable this, set opt-selection-text-glossary to false.

    Additionally, if you do not want to use the entire dictionary, and prefer that only the selected text is shown in the first definition, then set opt-selection-text-glossary-attempt-bold to false.

    Where automatic bolding can fail (click here)

    Automatic bolding may not always work: if the highlighted text could not be automatically detected from the custom template code, then it will fallback to simply using the highlighted text (as if you used the {selection-text} marker).

    This is most likely to fail if you select formatted parts of text, such as (but not limited to):

    • line breaks
    • furigana
    • across multiple items in a list (common with JMdict)
    Where dictionary selection can fail (click here)

    This may occasionally select the wrong dictionary, but this only happens if the selected text also appears in a dictionary above the selected text.

    For example, suppose you have two bilingual dictionaries. and for the word タコ, you highlight the word "octopus" and create the card. Both bilingual dictionaries will list "octopus", so even if you highlight the word "octopus" in the second bilingual dictionary, only the first bilingual dictionary will be chosen.

    This is usually not a problem even if the same text appears in a dictionary above because it's the same definition regardless. Additionally, monolingual dictionaries almost never have the exact same definition for the same word. However, if you still want a specific dictionary, highlight the dictionary tag as shown above.


UI Options

Hiding the first line of a definition

See also: How to remove the numbers in the definition

The first line of the definition has various elements that can be hidden with CSS.

  • Nothing is hidden. This is the default behavior.

  • This hides all the text to the right of the dictionary tag.
CSS to hide extra text (click here)

New in version 0.11.0.0 (latest version: 0.11.0.4)

The following CSS only affects only the dictionary with the tag 「旺文社国語辞典 第十一版」. To use this on more than one dictionary, copy/paste the CSS multiple times, and replace the dictionary tag.

  1. Under extra/style.scss, add the following code:

    /* hide the text after the 「旺文社国語辞典 第十一版」 dictionary tag */
    .glossary-text ol li[data-details="明鏡国語辞典 第二版"] .dict-group__glossary--first-line {
      display: none;
    }
    
  2. (Optional) Under extra/field.scss, add the following code:

    /* greys out the text after the 「旺文社国語辞典 第十一版」 dictionary tag */
    anki-editable ol li[data-details="明鏡国語辞典 第二版"] .dict-group__glossary--first-line {
      color: var(--text-color--3);
    }
    

  • Removes only the dictionary tag. This doesn't look very good on most dictionaries.
CSS to hide dictionary tag(s) (click here)

The following CSS only affects only the dictionary with the tag 「旺文社国語辞典 第十一版」. To use this on more than one dictionary, copy/paste the CSS multiple times, and replace the dictionary tag.

  1. Under extra/style.scss, add the following code:

    /* hide the 「旺文社国語辞典 第十一版」 dictionary */
    ol li[data-details="旺文社国語辞典 第十一版"] .dict-group__tag-list {
      display: none;
    }
    

  2. (Optional) Under extra/field.scss, add the following code:

    /* greys out the 「旺文社国語辞典 第十一版」 dictionary */
    anki-editable ol li[data-details="旺文社国語辞典 第十一版"] .dict-group__tag-list {
      color: var(--text-color--3);
    }
    

CSS to hide JMdict's dictionary tag (click here)

If you are on a modern version of JMdict, the dictionary will contain additional tags to the right of the dictionary tag by default, such as (n), (vs), etc. The instructions above will remove all of these tags.

You may want to only remove the dictionary tag without removing the other information tags. If your JMdict dictionary tag is exactly JMdict (English), then this is already the default behavior. However, if your dictionary tag is different, do the following (you may have to replace JMdict with your exact JMdict dictionary tag):

  1. Under extra/style.scss, add the following code:

    /* removes the dictionary entry for jmdict */
    .glossary-text ol li[data-details="JMdict"] .dict-group__tag-list .dict-group__tag--dict {
      display: none;
    }
    /* Makes JMDict italic */
    .glossary-text ol li[data-details="JMdict"] .dict-group__tag-list {
      font-style: italic;
    }
    

  2. (Optional) Under extra/field.scss, add the following code:

    /* greys out dictionary entry for jmdict */
    anki-editable ol li[data-details="JMdict"] .dict-group__tag-list .dict-group__tag--dict {
      color: var(--text-color--3);
    }
    /* Makes JMDict italic */
    anki-editable ol li[data-details="JMdict"] .dict-group__tag-list {
      font-style: italic;
    }
    

  • Hides the entire first line. This is a combination of the last two, meaning it hides the dictionary tag and the text to the right.
CSS to hide the entire first line (click here)

New in version 0.11.0.0 (latest version: 0.11.0.4)

The following SCSS only affects only the dictionary with the tag 「旺文社国語辞典 第十一版」. To use this on more than one dictionary, copy/paste the SCSS multiple times, and replace the dictionary tag.

  1. Under extra/style.scss, add the following code:

    /* hide the first line for the 「旺文社国語辞典 第十一版」 dictionary */
    .glossary-text ol li[data-details="明鏡国語辞典 第二版"] {
      .dict-group__tag-list, .dict-group__glossary--first-line, .dict-group__glossary--first-line-break {
        display: none;
      }
    }
    
  2. (Optional) Under extra/field.scss, add the following code:

    anki-editable ol li[data-details="明鏡国語辞典 第二版"] {
      .dict-group__tag-list, .dict-group__glossary--first-line, .dict-group__glossary--first-line-break {
        display: none;
      }
    }
    

Note

The above examples are SCSS, and not CSS. If you are using CSS, do not flatten the classes after the first line.

Example Raw CSS:

.glossary-text ol li[data-details="明鏡国語辞典 第二版"] .dict-group__tag-list {
  display: none;
}
.glossary-text ol li[data-details="明鏡国語辞典 第二版"] .dict-group__glossary--first-line {
  display: none;
}
.glossary-text ol li[data-details="明鏡国語辞典 第二版"] .dict-group__glossary--first-line-break {
  display: none;
}

Removing the numbers in the primary definition

Currently, I am not aware of an easy way to only remove the numbers if there is only one item (and having them remain for multple definitions) with only CSS.

The following CSS completely nukes the numbers regardless of how many items there are in the list.

Instructions (click here)
  1. Under extra/style.scss, add the following code:

    .glossary-text--primary-definition ol {
      list-style: none;
      padding-left: 0em;
    }
    

Collapsing dictionaries

Warning

New as of version 0.11.1.0. This version is currently bleeding edge, so this feature cannot be used unless you compile the templates from the dev branch.

This allows you collapse dictionaries within the Secondary Definition or Extra Definitions section.

TODO gif

Instructions (click here)
{
  "modules": {
    "collapse-dictionaries": {
      "enabled": true,
      // ...
    }
  }
}

Note

There are many options for the above the above module, such as overriding what dictionaries should be collapsed or not. These will not be documented here, but will be documented in the runtime options file.



Last update: December 5, 2022