# Discourse Dictionary Plugin 🆎

**URL:** https://meta.discourse.org/t/discourse-dictionary-plugin/214484
**Category:** Plugin
**Created:** [January 11, 2022, 6:06am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484 "2022-01-11T06:06:07Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [January 11, 2022, 6:06am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/1 "2022-01-11T06:06:07Z")

</div>

**Summary** : The Discourse Dictionary plugin allows a user to add the dictionary meaning of a word to the first post of a topic. Here’s a short video to demonstrate the working.

🔗 **GitHub** : [GitHub - fzngagan/discourse-dictionary: A discourse plugin to add meanings of a given word to the post · GitHub](https://github.com/fzngagan/discourse-dictionary)  
➡ **Install** : Follow the [plugin installation guide](https://meta.discourse.org/t/install-a-plugin/19157).

### Features

- Allows a user (default to TL2) to select a dictionary meaning of a word via the composer. The selected word when hovered, will display a tooltip showing the selected meaning.
- Currently supports Oxford Dictionary API.
- Currently supports singular form of words i.e. `fungi` won’t work you’ll have to use `fungus`.
- The meanings are cached to the db for quick loads in the future and to avoid exhausting the API thresholds.
- You can tweak the values once they’re loaded in the composer.

### Configuration

- Get your API credentials from [https://developer.oxforddictionaries.com/](https://developer.oxforddictionaries.com/)
- Use the `app id` for the site setting `discourse dictionary oxford app id`
- Use the `api key` for the site setting `discourse dictionary oxford api key`
- You can set the minimum trust level of user’s who can access this feature using `discourse dictionary min trust level`

### TODO

- Support plural forms of words
- Support other Dictionary APIs
- Include tests

### Credits

Thanks a lot @sam

- I’ve drawn insipiration from the tooltip code in the `discourse-footnote` plugin.
- The markdown docs on meta were indispensable for writing this plugin.

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [January 13, 2022, 8:52pm UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/3 "2022-01-13T20:52:53Z")

</div>

Thank you so much for this @fzngagan! If the guides can be improved in any way don’t hesitate to let us know! 🎉

---

<div class="post-metadata">

### Author: ![jimkleiber](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimkleiber/32/121814_2.png) [@jimkleiber](https://meta.discourse.org/u/jimkleiber)
#### Post date: [February 16, 2022, 2:18am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/4 "2022-02-16T02:18:00Z")

</div>

I’m quite excited to try this plugin. Not sure how yet, but will probably figure out a way to work it in.

One thing that came to mind was how helpful this may be for language learning. I went to the Oxford Dictionary documentation and saw that it seems possible to look up words in some other languages as well: [https://developer.oxforddictionaries.com/documentation/languages](https://developer.oxforddictionaries.com/documentation/languages)

I don’t know too much about Ruby programming, but from what I can see, it looks like it may be easy for me to tweak the plugin to use Spanish or Swahili by just changing the `dataset: 'en-us'` line to `es` or `sw` in this code block:

```plaintext
    def self.fetch_from_api(word)
      response = client().entry(
        word: word,
        dataset: 'en-us',
        params: { fields: 'definitions' }
      )

```

1. Do you think that’s all I’d have to change?
2. Have you thought about adding the option to use other languages?

Thank you for making this!

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [February 16, 2022, 5:46am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/5 "2022-02-16T05:46:53Z")

</div>

> [@jimkleiber](#):
>
> Do you think that’s all I’d have to change?

I think so. 🙂

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [February 16, 2022, 5:49am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/6 "2022-02-16T05:49:16Z")

</div>

> [@jimkleiber](#):
>
> Have you thought about adding the option to use other languages?

My intention was to just launch it and see if there’s interest in the community. This plugin is a bit special to me because I made the spec for it almost 3 years ago when I didn’t have the know how of how to build it. 🙂

Here’s my post

> **[Pavilion](https://pavilion.tech/)**
>
> Pavilion is the leading Discourse consultancy.

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [February 16, 2022, 5:55am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/7 "2022-02-16T05:55:18Z")

</div>

@jimkleiber  
I’ve also made sure new dictionary sources can be added easily. Happy to accept PRs in that regard too.

---

<div class="post-metadata">

### Author: ![jimkleiber](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jimkleiber/32/121814_2.png) [@jimkleiber](https://meta.discourse.org/u/jimkleiber)
#### Post date: [February 16, 2022, 6:08am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/8 "2022-02-16T06:08:38Z")

</div>

Well then maybe this plugin can help me also learn how to build a plugin (and do a PR) ☺ I’ll take a look one of these days and let you know. Thank you!

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [February 16, 2022, 6:15am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/9 "2022-02-16T06:15:27Z")

</div>

> [@fzngagan](#):
>
> Support plural forms of words

The one thing which I didn’t touch was the lemma api to fetch the singular form of words. Its important because the oxford api especially(and probably others) work with singular form. That would be valuable too.

---

<div class="post-metadata">

### Author: ![abrambailey](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abrambailey/32/119786_2.png) [@abrambailey](https://meta.discourse.org/u/abrambailey)
#### Post date: [September 22, 2022, 2:41pm UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/10 "2022-09-22T14:41:52Z")

</div>

Hi @fzngagan … I have an interesting use case, and I wonder if your plugin could help me.

I run a forum that is for people with hearing loss and there are lots and lots of terms that newbies need to learn. We have a wiki with some definitions, but it would be very handy if we could add system definitions and have defined terms and acronyms be automatically underlined without the user setting the [dict] tag. Having the Oxford suggested definitions is handy, but I imagine many of these words will need custom definition.

Thanks!

---

<div class="post-metadata">

### Author: ![fzngagan](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fzngagan/32/259349_2.png) [@fzngagan](https://meta.discourse.org/u/fzngagan)
#### Post date: [September 23, 2022, 4:10am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/11 "2022-09-23T04:10:18Z")

</div>

> [@abrambailey](#):
>
> but it would be very handy if we could add system definitions and have defined terms and acronyms be automatically underlined without the user setting the [dict] tag.

We have [Auto-Linkify Words](https://meta.discourse.org/t/linkify-words-in-post/82193) Theme Component but it goes only as far as converting an appearance of a word to a link. It can certainly be forked to achieve what you’re suggesting. You can hire a developer from #Marketplace if you’re happy to sponsor the work.

---

<div class="post-metadata">

### Author: ![denvergeeks](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/denvergeeks/32/327671_2.png) [@denvergeeks](https://meta.discourse.org/u/denvergeeks)
#### Post date: [September 24, 2022, 6:42am UTC](https://meta.discourse.org/t/discourse-dictionary-plugin/214484/12 "2022-09-24T06:42:56Z")

</div>

@abrambailey have you considered… the **abbrify words (with styling)** theme component? I’m using it to provide inline on-hover definitions on my site… you can se it in action here: [The Future of the Metaverse in Daily Life - Tech News and Tips - n👀bish.me](https://noobish.me/t/the-future-of-the-metaverse-in-daily-life/284)

> [@Add \<abbr\> tags to words in posts](https://meta.discourse.org/t/add-abbr-tags-to-words-in-posts/88394):
>
> About This theme component is ported from [Auto-Linkify Words](https://meta.discourse.org/t/linkify-words-in-post/82193) to provide functionality similar to the [Abbreviations and acronyms plugin](https://meta.discourse.org/t/abbreviations-and-acronyms-plugin/38501) – namely to wrap various abbreviations used in a given forum/site/Discourse installation in \<abbr\> tags. Location [https://github.com/metabrainz/discourse-abbrify-words](https://github.com/metabrainz/discourse-abbrify-words)How to install Credits Thanks to @sam for writing the “Linkify words in post” plugin.

> [@Add \<abbr\> tags to words in posts](https://meta.discourse.org/t/add-abbr-tags-to-words-in-posts/88394/28):
>
> I did a rough user stylesheet (CSS) to allow me see tooltips on mobile. It requires [Stylus](https://add0n.com/stylus.html) extension (I use Firefox on Android that supports extensions). This kind of stuff could be included in the plugin but I actually use it on all sites. abbr[title]:hover { border: 2px solid white; color: #333; background: #FF6; } abbr[title]:hover:after { content: " (" attr(title) ")"; }
