try another color:
try another fontsize: 60% 70% 80% 90%
Mobabel
Build one Babel Tower in the mobile world to communicate!

Modict And 创建新的在线字典

  1. 编辑 URL
  2. XML
  3. HTML
  4. Plain Text
  5. 正则表达式过滤器


编辑 URL

Up
首先你需知道在线翻译的接口Url,这里有一些例子:

http://dict.cn/ws.php?q=word

http://wap.mydict.com/API.php?q=wort

http://dict.bcwelt.de/api/bcsearch.php?f=de&t=en&w=wort

通常情况下,最后一个参数是给输入单词预留的,所以你的Url应该是这样的:

http://dict.cn/ws.php?q=

http://wap.mydict.com/API.php?q=

http://dict.bcwelt.de/api/bcsearch.php?f=de&t=en&w=

然后你要知道接口所需的编码和返回内容的语言编码

XML

Up
如果翻译接口返回的是XML格式,下面有个例子:


<dict>
<key>word</key>
<lang>ec</lang>
<audio>http://dict.cn/mp3.php?q=efVw7</audio>
<pron>w:d</pron>
<def>一些解释</def>
<sent>
<orig>Could we have a word before you go to the meeting?</orig>
<trans>对第一个例句的解释......</trans>
</sent>
<sent>
<orig>blablablablablablablablablablablablablabla</orig>
<trans>对第二个句子的解释......</trans>
</sent>
</dict>

所以节点 <pron>, <def> 和 <sent> 是你所需的节点, 你可以添加如下过滤器:

在线翻译的输出结果会将如下显示:


w:d
word, letter, some translation
Could we have a word before you go to the meeting?
对第一个例句的解释......
blablablablablablablablablablablablablabla
对第二个句子的解释......

你也可以这样改变过滤器:

在线翻译的输出结果也会作如下改变:


w:d
word, letter, some translation
Could we have a word before you go to the meeting?
blablablablablablablablablablablablablabla
对第一个例句的解释......
对第二个句子的解释......

HTML

Up
如果翻译接口返回的是HTML格式,操作如同XML

Plain Text

Up
如果翻译接口返回的既不是HTML 也不是 XML, 举例来说:


[server]
[Wort]Word[/Wort]
[def]translation of this word[/def]
[/server]

你可以这样设置过滤器:

在线翻译的输出结果会将如下显示:


Word
translation of this word

或者你也可以这样自定义过滤器:

在线翻译的输出结果也会作如下改变:


translation of this word
Word

正则表达式过滤器

Up
如果你比较了解正则表达式, 你也可以使用正则表达式过滤器来过滤你所需要的内容.

举例:
http://translate.google.com/translate_t?&langpair=de|en&ie=UTF8&oe=UTF8&text=was

结果将以HTML格式返回,内容相当复杂,只有图中所示节点才是你所需:

正则表达式可以这么写:

id=.?result_box[^>]*>([^<]*)

在线翻译的输出结果将会如下:

what