Skip to content

Commit

Permalink
fix: 修正查询中文时可能报错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
luoweihua7 committed Nov 23, 2022
1 parent 0f50b69 commit 19c7628
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Binary file modified iciba - Lookup word.alfredworkflow
Binary file not shown.
6 changes: 4 additions & 2 deletions src/iciba.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ def iciba_search(word):
r=wf.get_json(url)
if ("symbols" in r["message"]["baesInfo"]):
result = r["message"]["baesInfo"]["symbols"][0]
if len(result["ph_en"]) > 0 and len(result["ph_am"]) > 0:
wf.add_item(title=word, subtitle="%s[ %s ] %s[ %s ]" % (i18n.dic["DEFAULT_EN"], result["ph_en"], i18n.dic["DEFAULT_AM"], result["ph_am"]), icon="icon.png", valid=True, arg=word)
ph_en = result.get('ph_en', '')
ph_am = result.get('ph_am', '')
if len(ph_en) > 0 and len(ph_am) > 0:
wf.add_item(title=word, subtitle="%s[ %s ] %s[ %s ]" % (i18n.dic["DEFAULT_EN"], ph_en, i18n.dic["DEFAULT_AM"], ph_am), icon="icon.png", valid=True, arg=word)
for dic in result["parts"]:
wf.add_item(title=";".join(dic["means"]), subtitle=dic["part"], icon="icon.png", valid=True, arg=word)
elif ("translate_result" in r["message"]["baesInfo"]):
Expand Down

0 comments on commit 19c7628

Please sign in to comment.