.... In this option the output is always in UTF-8 coding. * the `my_wwwjdic.json_uri '`word`'` command, instead, returns the URL for translation of `word` in a JSON format as `{ "`word`: "`url`" }` with normal display format. * `translate`: you can, finaly, obviously ask for a specific translation using the configured parameters. * you can get a simple translation with the command `my_wwwjdic.translate 'word'`, that returns a string containing the web page content of the translation of `word` in the raw display format. It's equivalent to `my_wwwjdic.translate 'word', display: :raw`. * `my_wwwjdic.translate 'word', nil, filename`, regardless the `nil` (see it later), the third `filename` parameter is the name of the file where the translation will be saved into. Specifying this `filename` parameter, the translation will not be shown, but it will be saved in the specified file. * Another possible result for translation is to get it in JSON format also with the possibility to save it in a file: `my_wwwjdic.json_translate 'word'`, returns the JSON format of the translation: * The JSON will contain a field having the same name of the word to be translated that contains the URL of the translation from the reference dictionary server used. The URL is exatcly the same used to retrieve the translation and filling the resulting JSON. * The `title` field will contain the title of the translation page result. * The `translation` field will contain the raw translation as received from the server. * The `message` field will contain all the text that will possibly be included as error message in the translation. This means that if any `
` tag encloses some text, such text
will be presented in this `message` field.
* The `lines` field will contain an array of all the lines of the
translation, that is: the `lines` field contains a split of the
`translation` field using its existing `\n` characters.
* The `content` field contains an array of JSON objects, each
containing the formatted translation of each line:
* a field with the name of the word asked for translation,
containing the actual translation, first field of the
translation in each line;
* a `kana` field with the kana writing for the translation, as
shown in brackets, in each line;
* a `text` field containing the explanation associated to such
translation;
* a `meanings` field containing the different meaning associated
to each line.
The `/` characters mark the splitting point for each line.
So, basically, the JSON will contain the whole raw translation, the
same translation split into different lines, when asked by the
translation itself, and each of those lines above split again into a
set of available meanings.
For the example translation above, the resulting JSON format is:
```json5
{
"word": "http://www.edrdg.org/cgi-bin/wwwjdic/wwwjdic.cgi?1ZDQword",
"title": "WWWJDIC: Word Display",
"translation": "伝言 [つてこと] /(n) (1) (See 伝言・でんごん) verbal message/word (from someone)/(n) (2) rumour/rumor/\n伝言 [でんごん] /(n,vs) verbal message/word (from someone)/(P)/\n一議 [いちぎ] /(n) word (opinion, objection)/\n言の葉 [ことのは;ことのえ] /(n) (1) (arch) word/(n) (2) (See 和歌) waka (classic Japanese poem, esp. a tanka)/\nワード /(n) (1) word/(n) (2) {comp} word/(n) (3) {comp} Word/Microsoft Word/(P)/\n語 [ご] /(n,n-suf) (1) language/(n,n-suf,ctr) (2) word/(P)/\n単語 [たんご] /(n,adj-no) {ling} word/vocabulary/(usually) single-character word/(P)/\n訪れ [おとずれ] /(n) (1) visit/call/(n) (2) arrival (e.g. of spring)/advent/coming/appearance/(n) (3) news/tidings/word/(P)/\n音沙汰;音さた [おとさた] /(n) news (from someone)/word/contact/\n言 [げん(P);こと] /(n) word/remark/statement/(P)/\n知らせ(P);報せ [しらせ] /(n) (1) (See お知らせ) news/word/tidings/notice/notification/information/(n) (2) omen/(P)/\n言葉(P);詞;辞 [ことば(P);けとば(言葉)(ok)] /(n) (1) (See 言語) language/dialect/(n) (2) (See 単語) word/words/phrase/term/expression/remark/(n) (3) speech/(manner of) speaking/(n) (4) learning to speak/language acquisition/(P)/",
"message": null,
"lines": [
"伝言 [つてこと] /(n) (1) (See 伝言・でんごん) verbal message/word (from someone)/(n) (2) rumour/rumor/",
"伝言 [でんごん] /(n,vs) verbal message/word (from someone)/(P)/",
"一議 [いちぎ] /(n) word (opinion, objection)/",
"言の葉 [ことのは;ことのえ] /(n) (1) (arch) word/(n) (2) (See 和歌) waka (classic Japanese poem, esp. a tanka)/",
"ワード /(n) (1) word/(n) (2) {comp} word/(n) (3) {comp} Word/Microsoft Word/(P)/",
"語 [ご] /(n,n-suf) (1) language/(n,n-suf,ctr) (2) word/(P)/",
"単語 [たんご] /(n,adj-no) {ling} word/vocabulary/(usually) single-character word/(P)/",
"訪れ [おとずれ] /(n) (1) visit/call/(n) (2) arrival (e.g. of spring)/advent/coming/appearance/(n) (3) news/tidings/word/(P)/",
"音沙汰;音さた [おとさた] /(n) news (from someone)/word/contact/",
"言 [げん(P);こと] /(n) word/remark/statement/(P)/",
"知らせ(P);報せ [しらせ] /(n) (1) (See お知らせ) news/word/tidings/notice/notification/information/(n) (2) omen/(P)/",
"言葉(P);詞;辞 [ことば(P);けとば(言葉)(ok)] /(n) (1) (See 言語) language/dialect/(n) (2) (See 単語) word/words/phrase/term/expression/remark/(n) (3) speech/(manner of) speaking/(n) (4) learning to speak/language acquisition/(P)/"
],
"content": [
{
"word": "伝言",
"kana": "つてこと",
"text": "(n)(1) (See 伝言・でんごん) verbal message/word (from someone)/(n) (2) rumour/rumor",
"meanings": [
"(n) (1) (See 伝言・でんごん) verbal message",
"word (from someone)",
"(n) (2) rumour",
"rumor"
]
},
{
"word": "伝言",
"kana": "でんごん",
"text": "(n,vs) verbal message/word (from someone)/(P)",
"meanings": [
"(n,vs) verbal message",
"word (from someone)",
"(P)"
]
},
{
"word": "一議",
"kana": "いちぎ",
"text": "(n) word (opinion, objection)"
},
{
"word": "言の葉",
"kana": "ことのは;ことのえ",
"text": "(n) (1) (arch) word/(n) (2) (See 和歌) waka (classic Japanese poem, esp. a tanka)",
"meanings": [
"(n) (1) (arch) word",
"(n) (2) (See 和歌) waka (classic Japanese poem, esp. a tanka)"
]
},
{
"kana": "ワード",
"word": "ワード",
"text": "(n) (1) word/(n) (2) {comp} word/(n) (3) {comp} Word/Microsoft Word/(P)",
"meanings": [
"(n) (1) word",
"(n) (2) {comp} word",
"(n) (3) {comp} Word",
"Microsoft Word",
"(P)"
]
},
{
"word": "語",
"kana": "ご",
"text": "(n,n-suf) (1) language/(n,n-suf,ctr) (2) word/(P)",
"meanings": [
"(n,n-suf) (1) language",
"(n,n-suf,ctr) (2) word",
"(P)"
]
},
{
"word": "単語",
"kana": "たんご",
"text": "(n,adj-no) {ling} word/vocabulary/(usually) single-character word/(P)",
"meanings": [
"(n,adj-no) {ling} word",
"vocabulary",
"(usually) single-character word",
"(P)"
]
},
{
"word": "訪れ",
"kana": "おとずれ",
"text": "(n) (1) visit/call/(n) (2) arrival (e.g. of spring)/advent/coming/appearance/(n) (3) news/tidings/word/(P)",
"meanings": [
"(n) (1) visit",
"call",
"(n) (2) arrival (e.g. of spring)",
"advent",
"coming",
"appearance",
"(n) (3) news",
"tidings",
"word",
"(P)"
]
},
{
"word": "音沙汰;音さた",
"kana": "おとさた",
"text": "(n) news (from someone)/word/contact",
"meanings": [
"(n) news (from someone)",
"word",
"contact"
]
},
{
"word": "言",
"kana": "げん(P);こと",
"text": "(n) word/remark/statement/(P)",
"meanings": [
"(n) word",
"remark",
"statement",
"(P)"
]
},
{
"word": "知らせ(P);報せ",
"kana": "しらせ",
"text": "(n) (1) (See お知らせ) news/word/tidings/notice/notification/information/(n) (2) omen/(P)",
"meanings": [
"(n) (1) (See お知らせ) news",
"word",
"tidings",
"notice",
"notification",
"information",
"(n) (2) omen",
"(P)"
]
},
{
"word": "言葉(P);詞;辞",
"kana": "ことば(P);けとば(言葉)(ok)",
"text": "(n) (1) (See 言語) language/dialect/(n) (2) (See 単語) word/words/phrase/term/expression/remark/(n) (3) speech/(manner of) speaking/(n) (4) learning to speak/language acquisition/(P)",
"meanings": [
"(n) (1) (See 言語) language",
"dialect",
"(n) (2) (See 単語) word",
"words",
"phrase",
"term",
"expression",
"remark",
"(n) (3) speech",
"(manner of) speaking",
"(n) (4) learning to speak",
"language acquisition",
"(P)"
]
}
]
}
```
Please note that the resulting JSON is not pretty-printed, as shown
here.
* Now let's come to the second parameter of the methods above (set to
`nil` in the examples), the arguments for the translation.
The default is to translate to/from English/Japanese with normal
display layout and no other specificities, except that the API
automatically identifies Japanese or English and manages the romaji
and so on.
The returned URL is the default EDR&DG one, as required by Jim Breen
himself.
What if the user wants to customize something?
The `args`, second parameter of all those methods above, is a
dictionary (hash map) that allows specifying which parameters and to
which values they shall be set.
Valid parameters, and their values are:
* `dict` parameter allows both numbers and (exact) strings to select
dictionaries:
| Number | Dictionary Name |
|:------:|---------------------------|
| 1 | Jpn-Eng General (EDICT) |
| 2 | Japanese Names (ENAMDICT) |
| 3 | Computing/Telecomms |
| 4 | Life Sciences/Bio-Med |
| 5 | Legal Terms |
| 6 | Finance/Marketing |
| 7 | Buddhism |
| 8 | Miscellaneous |
| 9 | Special Text-glossing |
| A | Engineering/Science |
| B | Linguistics |
| C | River & Water Systems |
| D | Automobile Industry |
| E | Japanese Wordnet |
| F | Work-in-progress File |
| G | Japanese-German (WaDoku) |
| H | Japanese-French |
| I | Japanese-Russian |
| J | Japanese-Swedish |
| K | Japanese-Hungarian |
| L | Japanese-Spanish |
| M | Japanese-Dutch |
| N | Japanese-Slovenian |
| O | Japanese-Italian |
| P | Untranslated |
| Q | Combined Jpn-Eng |
| R | Expanded Text-glossing |
* `display` parameter to select the final format of the referred
HTML page (either regular HTML or raw): `:regular`, `:raw`.
* `server` allows the user to select from the default URL (at
Electronic Dictionaries R&D Group) or the Monash university URL:
`:edrdg`, `:monash`.
Some examples of these parameters' usage:
* `my_wwwjdic.translate 'Sprache', dict: 'G', key: english`, this
translates using the `F` dictionary, that is the German one
* `my_wwwjdic.uri 'Sprache', dict: 'G'`, same as above, but returns
the translation URL, instead
* `my_wwwjdic.raw_uri 'Sprache', dict: 'G'`, same as above, but
returns the translation URL with raw display, instead
* `my_wwwjdic.uri 'Sprache', dict: 'G', display: raw`
## Maintainers
* [Marco Bresciani](https://savannah.nongnu.org/users/marcobresciani)
## Thanks
* *Contributor*: [Jim
Breen](http://www.csse.monash.edu.au/~jwb/index.html)
* *Author*: [Jon Maken](mailto:jon.forums@gmail.com), [An HTTP/HTTPS/FTP
file downloader library/CLI based upon MiniPortile's HTTP
implementation.](https://gist.github.com/jonforums/2202048)
About *An HTTP/HTTPS/FTP file downloader library/CLI based upon
MiniPortile's HTTP implementation*, please note that "License:
3-clause BSD".
This license is GNU GPLv3 compatible according to