0.0.5 • Published 7 years ago

hjdict v0.0.5

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

HjDict

npm Travis

An unofficial HjDict API in Javascript. 沪江小D非官方API

(简体中文文档)

🌐 Live demo

Quick Example

Get Japanese-Chinese dict:

HjDict.jp2cn('傘', data => {
  console.log(data)
  // Do what you what with the data
})
{
  "query": "傘",
  "explains": [{
    "primary": "傘",
    "secondary": "かさ",
    "tertiary": "kasa",
    "mp3": "http://d1.g.hjfile.cn/voice/jpsound/J12852.mp3",
    "details": [{
      "part_of_speech": "名词",
      "items": [{
        "type": "text",
        "text": "伞。(傘)。"
      }, {
        "type": "list",
        "jp": "傘をさす。",
        "cn": "撑伞,打伞。"
      }]
    }]
  }, {
    "primary": "傘",
    "secondary": "からかさ",
    "tertiary": "karakasa",
    "mp3": "http://d1.g.hjfile.cn/voice/jpsound/J14795.mp3",
    "details": [{
      "part_of_speech": "名词",
      "items": [{
        "type": "text",
        "text": "纸伞,油纸伞。(さしがさ。)"
      }]
    }]
  }]
}

For more data format, please check the API document.

Install

Browser

Download hjdict.js and add following code in your HTML head:

<script src="<Path To>/hjdict.js">

Or you can just use

<script src="https://antfu.github.io/hjdict/dist/hjdict.js">

Note: When using HjDict in browser, you may face Cross Origin problem. You should try the solution here.

Node

npm install hjdict node-fetch
const fetch = require('node-fetch')
const HjDict = require('hjdict')
HjDict.set_fetch(fetch)

For Node.js, you should install note-fetch and pass it though HjDict.set_fetch.

Cross Origin Request

Since version 0.0.3, the default CORS proxy is set to http://crossorigin.me/. You can always set/unset it by using the following code at the begin of your scripts:

// Set the cors proxy
HjDict.set_cors_proxy('http://crossorigin.me/')

// Reset
HjDict.set_cors_proxy('')

Language Support

Supported/Planed:

  • Japanese-Chinese
  • Chinese-Japanese
  • English-Chinese
  • Chinese-English

Note: There are some other languages are supported by HjDict.com but not in this list. Since I am not a user of those languages, I may not have time to implement them. However, any PR is welcome 🤗.

License

MIT - antfu

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago