Discourse Dictionary Plugin 🆎

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.

:link: GitHub: GitHub - fzngagan/discourse-dictionary: A discourse plugin to add meanings of a given word to the post
:arrow_right: Install: Follow the plugin installation guide.

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/
  • 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.
20 Likes

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

7 Likes

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

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:

    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!

1 Like

I think so. :slight_smile:

1 Like

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. :slight_smile:

Here’s my post

1 Like

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

2 Likes

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

1 Like

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.

1 Like

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!

1 Like

We have Linkify words in post 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.

@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 - nOObish.me

1 Like