瀏覽代碼

Merge pull request #51 from Riamse/patch-1

Improve ultilingual dictionary capabilities
tags/v0.2
Ben Kurtovic 9 年之前
父節點
當前提交
d963e13af0
共有 1 個檔案被更改,包括 6 行新增0 行删除
  1. +6
    -0
      earwigbot/commands/dictionary.py

+ 6
- 0
earwigbot/commands/dictionary.py 查看文件

@@ -51,6 +51,9 @@ class Dictionary(Command):
except exceptions.SiteNotFoundError:
site = self.bot.wiki.add_site(project="wiktionary", lang=lang)

multilingual = "#" in term
if multilingual:
lang_requested = term[term.find("#")+1:]
page = site.get_page(term, follow_redirects=True)
try:
entry = page.get()
@@ -67,6 +70,9 @@ class Dictionary(Command):

result = []
for lang, section in sorted(languages.items()):
if multilingual:
if lang == lang_requested:
return u"({0}) {1}".format(lang, definition)
definition = self.get_definition(section, level)
result.append(u"({0}) {1}".format(lang, definition))
return u"; ".join(result)


Loading…
取消
儲存