mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Add support for dictd and StarDict dictionaries
This commit is contained in:
@@ -284,6 +284,36 @@ The TTS module doesn't directly handle speech output. Rather, its methods return
|
||||
|
||||
The SSML attributes `ssml:ph` and `ssml:alphabet` are supported. There's no support for PLS and CSS Speech.
|
||||
|
||||
### Offline Dictionaries
|
||||
|
||||
The `dict.js` module can be used to load dictd and StarDict dictionaries. Usage:
|
||||
|
||||
```js
|
||||
import { StarDict } from './dict.js'
|
||||
import { inflate } from 'your inflate implementation'
|
||||
|
||||
const { ifo, dz, idx, syn } = { /* `File` (or `Blob`) objects */ }
|
||||
const dict = new StarDict()
|
||||
await dict.loadIfo(ifo)
|
||||
await dict.loadDict(dz, inflate)
|
||||
await dict.loadIdx(idx)
|
||||
await dict.loadSyn(syn)
|
||||
|
||||
// look up words
|
||||
const query = '...'
|
||||
await dictionary.lookup(query)
|
||||
await dictionary.synonyms(query)
|
||||
```
|
||||
|
||||
Note that you must supply your own `inflate` function. Here is an example using [fflate](https://github.com/101arrowz/fflate):
|
||||
```js
|
||||
const inflate = data => new Promise(resolve => {
|
||||
const inflate = new fflate.Inflate()
|
||||
inflate.ondata = data => resolve(data)
|
||||
inflate.push(data)
|
||||
})
|
||||
```
|
||||
|
||||
### OPDS
|
||||
|
||||
The `opds.js` module can be used to implement OPDS clients. It can convert OPDS 1.x documents to OPDS 2.0:
|
||||
|
||||
Reference in New Issue
Block a user