• Stars
    star
    1,315
  • Rank 35,778 (Top 0.8 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A 🇨🇳 and 🇺🇸 translate tool in your command line.

Fanyi

A 🇨🇳 and 🇺🇸🇬🇧 translate tool in your command line, powered by youdao/iciba/ChatGPT.

NPM version NPM downloads

Install

$ npm install fanyi -g

Usage

$ fanyi word

For short:

$ fy word

Translation data is fetched from iciba.com and fanyi.youdao.com, and only support translation between Chinese and English.

In Mac/Linux bash, words will be pronounced by say command.

Translate one word.

$ fanyi love
 love  [ lʌv ]  ~  fanyi.youdao.com

 - n. 恋爱;亲爱的;酷爱;喜爱的事物;爱情,爱意;疼爱;热爱;爱人,所爱之物
 - v. 爱,热爱;爱戴;赞美,称赞;喜爱;喜好;喜欢;爱慕
 - n. (英)洛夫(人名)

 1. Love
    ,爱情,恋爱
 2. Endless Love
    无尽的爱,不了情,蓝色生死恋
 3. puppy love
    早恋,青春期恋爱,初恋

 love [ lʌv ] [ lʌv ]  ~  iciba.com

 - vt.&vi. 爱,热爱;爱戴;喜欢;赞美,称赞;
 - vt. 喜爱;喜好;喜欢;爱慕;
 - n. 爱情,爱意;疼爱;热爱;爱人,所爱之物;

 1. They happily reflect the desire for a fusional love that inspired the legendary LOVE bracelet Cartier.
    快乐地反映出为富有传奇色彩的卡地亚LOVE手镯所赋予的水乳交融之爱恋情愫。
 2. Love is the radical of lovely, loveliness, and loving.
    Love是lovely,loveliness及loving的词根。
 3. She rhymes"love"with"dove".
    她将"love""dove"两字押韵。
 4. In sports, love means nil.
    体育中,love的意思是零。
 5. Ludde Omholt with his son, Love, in S?derma a bohemian and culturally rich district in Stockholm.
    LuddeOmholt和他的儿子Love在南城——斯德哥尔摩市的一个充满波西米亚风情的文化富饶区散步。

More words.

$ fanyi make love

Support Chinese, even sentence.

$ fanyi 和谐
$ fanyi 子非鱼焉知鱼之乐
$ fanyi list

Also, you can use list command to see the history of your search.

2022-08-17
   test
     n. 试验;考验;测验;化验;
     vt. 测验;考查;考验;勘探;
     vi. 受试验;受测验;受考验;测得结果;

Configuration

A configuration file can be put into ~/.config/fanyi/.fanyirc, in the user's home directory

Use subcommand fanyi config [options]

Example:

# Turn off the pronunciation
$ fanyi config --no-say
# or
$ fanyi config -S

# Disable the dictionaryapi
$ fanyi config --no-dictionaryapi
# or
$ fanyi config -D

A sample ~/.config/fanyi/.fanyirc file:

{
  "iciba": true,
  "youdao": true,
  "dictionaryapi": false,
  "say": false,
  "color": true,
  "OPENAI_API_KEY": "YOUR_OPENAI_API_KEY"
}

Enable ChatGPT 🚀

Set an OpenAI API key to enable ChatGPT translation.

$ fanyi config --openai-api-key sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

image

Turn off ChatGPT translation.

$ fanyi config --openai-api-key false

If we get this error:

Cannot reach OpenAI api, please check network

We need to ensure that the proxy and $http_proxy is correctly set.

For example(for clash X):

$ export http_proxy=http://127.0.0.1:7890

You can also set up other openai api hosts,such as api.chatanywhere.com.cn:

$ fanyi config --openai-api-host api.chatanywhere.com.cn

Error: spawn festival ENOENT

Try this workaround from say.js in Linux.

sudo apt-get install festival festvox-kallpc16k

More Repositories

1

surge-preview

🔂 Preview website in surge.sh for every pull request.
TypeScript
143
star
2

exeq

🔀 Excute shell commands in queue
JavaScript
103
star
3

sketch-awesome-plugins

🎨 一套不错的 Sketch3 插件合集。
Shell
73
star
4

afc163

55
star
5

array-tree-filter

filter in array tree
JavaScript
54
star
6

MiniblogImgPop

🗻 微博浮图控件
JavaScript
37
star
7

cmdize

Convert normal js to CMD module
JavaScript
36
star
8

npm-clean

Clean unused dependenices in package.json
JavaScript
22
star
9

confirm-cli

A confirm interface in command line
JavaScript
19
star
10

wa

A super convenience watch and upload tool.
JavaScript
19
star
11

color3d

Display color spaces with three.js
JavaScript
18
star
12

cdn

Upload your files to cdn
JavaScript
16
star
13

grunt-peaches

The Grunt task for peaches.
JavaScript
10
star
14

homebrew

10
star
15

dva-logger

redux-logger plugin for dva.
JavaScript
10
star
16

word-color

Color your words!
JavaScript
9
star
17

es-dev-server-react

JavaScript
8
star
18

dora-plugin-upload

dora plugin for mocking file upload
JavaScript
8
star
19

chrome

Open chrome in shell
JavaScript
7
star
20

afc163.github.io

blog
HTML
6
star
21

dotfiles

Shell
5
star
22

Cold

兴趣导向的私人的研究性质的前端JS框架。
JavaScript
5
star
23

snakeGame

How time flies!
JavaScript
3
star
24

ued.alipay.com

alipay ued site.
JavaScript
3
star
25

svn-sync

Get svn info object synchronously.
JavaScript
2
star
26

react-dapp

JavaScript
2
star
27

myapp

react 测试 demo 工程
JavaScript
2
star
28

github-action-test

JavaScript
2
star
29

whoami

Who am I
JavaScript
2
star
30

now

spm package example
JavaScript
2
star
31

elasticsearch-package

Package same as:
Shell
2
star
32

cloudflare-worker-demo

JavaScript
1
star
33

ant-react-form-list

JavaScript
1
star
34

husky-test

1
star
35

monster

JavaScript
1
star
36

antd-pro-aliyun-theme

JavaScript
1
star