Every word your users hover, looked up on their device

The dictionary ships inside your application: the file, the lookup engine and the update feed that immit's own apps use. A lookup happens on the device, works offline and draws nothing from the API balance. The sample, the 2,000 most common words of each language, is free to build and test against.

No card to build and test

JS@immit/dictionary
JavaScript
const { entries, matched } = await dictionary.lookup(
  '食べましたか。',
  'jpn'
)
{
  "matched": "食べました",
  "entries": [
    {
      "headword": "食べる",
      "lang": "jpn",
      "pronunciations": [
        {
          "reading": "たべる",
          "accent": 2,
          // …
        }
      ],
      "senses": [
        {
          "pos": "動詞",
          "translations": {
            "eng": {
              "glosses": [
                {
                  "text": "to eat"
                },
                {
                  "text": "to have (a meal)"
                }
              ]
            }
          },
          // … definition, examples
        },
        // … 1 more sense
      ],
      "inflections": [
        {
          "text": "食べました",
          "form": "過去形",
          "tone": "polite",
          "polarity": "positive",
          // …
        },
        // … 42 more rows
      ],
      // … id, frequency_rank, spellings, relations
    }
  ]
}
  • state: ready
  • edition: sample
  • languages: eng, jpn

Already done for you

The word under the cursor
Pass the text from the hovered character onwards. 食べました is found as one word, under its headword 食べる.
On the device, offline
A lookup sends no request. It answers in a few milliseconds, with or without a connection.
Kept up to date
A sync when your application starts brings a full dictionary up to date with the entries that changed since the last one.
A page or an extension
The engine is WebAssembly in an npm package. It opens from a web page or an extension page, and a Manifest V3 extension runs it in an offscreen document.

From a hovered word to a popup

page.html
<style>
  ::highlight(hovered) { background: gold }
</style>
<p>昼ご飯はもう食べましたか。</p>
<p id="popup" hidden></p>
<script type="module" src="./hover.js"></script>
hover.js
import { openDictionary } from '@immit/dictionary'

const dictionary = await openDictionary({ licenseKey: 'il_...' })
await dictionary.sync()

const popup = document.querySelector('#popup')

function hovered(x, y) {
  const caret = document.caretPositionFromPoint(x, y)
  const node = caret?.offsetNode
  if (!(node instanceof Text)) {
    return null
  }
  for (const start of [caret.offset - 1, caret.offset]) {
    const character = new Range()
    character.setStart(node, Math.max(start, 0))
    character.setEnd(node, Math.min(start + 1, node.length))
    const box = character.getBoundingClientRect()
    if (box.left <= x && x < box.right && box.top <= y && y < box.bottom) {
      return { node, start }
    }
  }
  return null
}

document.addEventListener('mousemove', async ({ clientX, clientY }) => {
  const at = hovered(clientX, clientY)
  const text = at?.node.data.slice(at.start, at.start + 20)
  const found = text ? await dictionary.lookup(text, 'jpn') : null
  const [entry] = found?.entries ?? []
  popup.hidden = !entry
  CSS.highlights.clear()
  if (!entry) {
    return
  }
  const word = new Range()
  word.setStart(at.node, at.start)
  word.setEnd(at.node, at.start + found.matched.length)
  CSS.highlights.set('hovered', new Highlight(word))
  const [said] = entry.pronunciations
  const glosses = entry.senses[0].translations.eng.glosses
  popup.textContent = [
    entry.headword,
    said.reading,
    said.accent,
    glosses.map((gloss) => gloss.text).join(', ')
  ].join(' · ')
})
On your user's screen · 食べました hovered

昼ご飯はもう食べましたか。

食べるたべるpitch 2

to eat, to have (a meal)

What it costs

$12 a month for each started 1,000 installs. The sample is free, and a product released to the public needs the paid license.

See pricing

800 installs

1 × $12, one for each started 1,000 installs
$12
You pay each month$12

The lowest price, which covers up to 1,000 installs. That is $0.015 an install.

12,000 installs

12 × $12, one for each started 1,000 installs
$144
You pay each month$144

That is $0.012 an install, charged for the installs counted in the month before.

Questions

Are my application and its extension one license?
Yes. One license covers one product and all its applications and extensions, with one key, and their installs are counted together. A person who has both holds two installs. The license
Does the file hold audio?
No. Each pronunciation carries the link to its audio on immit's servers. The license gives no right to copy or store audio files, and a product that plays the audio shows the credit the notices file gives for its voice.
How big is the download?
About 295 MB for Japanese, 132 MB for English, 427 MB for both and 11 MB for the sample. The first sync downloads the whole file, so show its progress. An install takes more room on the device than its download. Every size
What happens to a copy when the license ends?
Installs get no more updates, and each one stops answering within 90 days. You stop shipping the dictionary in new versions of your product. What a person saved into their own study material is theirs to keep.
What does a sync send?
Your license key and a random id made on the device, and nothing that names a user or says what they read or look up. The license has words for your privacy notice.
Where does it run?
In a web page or a browser extension. Pages and Manifest V3 extensions in Chromium browsers are what the package is built and tested for. The docs say where Safari and Firefox stand.

A license key at once, and the sample free.