Translate words via command line


Keywords
python, youdao
License
MIT
Install
pip install fy==1.6.0

Documentation

pyecharts logo

🌐 fy

Translate words via command line. Inspired by afc163/fanyi, but more features.

Travis Build Status Appveyor Build Status Appveyor Build Status PyPI - Python Version PyPI - Python Version MIT License

特性

  • 单词字典查询
  • 中英句子互译
  • 关键词高亮
  • 发音(只在 Windows 下,Linux/MacOS 暂时未找到合适的第三方库)
  • Prompt shell,支持单词补全
  • 支持配置文件(配置查询来源以及对应接口的 TOKEN KEY)
  • records shell,记录查询历史

🔰 安装

pip 安装

$ pip install fy

源码安装

$ git clone https://github.com/chenjiandongx/fy.git
$ cd fy
$ pip install -r requirements.txt
$ python setup.py install

📝 使用

$ fy --help
usage: fy [-h] [-s] [-r] [-R] [-v] [WORDS [WORDS ...]]

Translate words via command line

positional arguments:
  WORDS          the words to translate

optional arguments:
  -h, --help     show this help message and exit
  -s, --shell    spawn a query prompt shell.
  -r, --records  spawn a records prompt shell.
  -R, --reset    reset fy configuration.
  -v, --version  displays the current version of fy.

查单词

英译中

中译英

query prompt shell

records prompt shell

使用 SQLite 数据库,表名称为 words

🔧 配置

配置文件内容为

$ car ~/.fy.json

{
    "query_source": "google,youdao,iciba",
    "youdao_key": "1945325576",
    "youdao_key_from": "Youdao-dict-v21",
    "iciba_key": "4B26F43688FA072E0B94F68FFCE224CF",
    "enable_sound": true
}

查询源

目前支持 google、youdao、iciba,如果只想使用 youdao 源,可修改为 query_source: "youdao",google/iciba 同理

TOKEN KEY

目前使用的 TOKEN KEY 都是我自己申请的,youdao 有限制,iciba 没有,开发者可以自行申请替换。

📅 Changelog

V1.6.0 - 2019-09-16

  • Update: 新增 pangu 分词

V1.5.2 - 2019-08-28

  • Add: 新增 -R 参数,重置配置信息

V1.5.1 - 2019-08-19

  • Update: 输出格式调整

V1.5.0 - 2019-08-19

  • Add: 新增 google 翻译源

V1.4.1 - 2019-01-28

  • Add: 新增关闭声音配置项

V1.4.0 - 2019-01-28

  • Update: 使用 sqlite prompt shell

V1.3.0 - 2019-01-27

  • Add: 支持保存历史查询记录

V1.2.1 - 2019-01-26

  • Update: 声明支持的 Python 版本

V1.2.0 - 2019-01-26

  • Add: 提供配置文件

V1.1.0 - 2019-01-25

  • Add: 新增发音功能

V1.0.0 - 2019-01-24

  • Alpha: 第一个正式版发布

📃 LICENSE

MIT ©chenjiandongx