Repolode
afc163

afc163/fanyi

A command-line Chinese-English translator (npm package "fanyi") that combines iciba, Youdao dictionary results and LLM translation.

Stars
1,554
Forks
147
Open issues
5
Last commit
2 months ago

What is it?

fanyi is a command-line translator for Chinese and English. Run `fanyi <word>` (or the short alias `fy`) in a terminal and it returns dictionary entries from iciba and Youdao together with a translation generated by an LLM. It handles single words, phrases, and full Chinese sentences.

By default it works without configuration: when no API key is set, LLM translation goes through a built-in proxy. Users who want their own model can set `LLM_API_KEY`, `LLM_API_BASE_URL` and `LLM_MODEL_ID` to use any OpenAI-compatible endpoint. Each source can be switched off globally with `fanyi config set`. A `list` command shows past lookups grouped by date.

The project also ships an Agent Skill, so AI coding agents such as Claude Code can call fanyi automatically when asked to translate a word.

Key features

  • 01Shows iciba, Youdao and LLM results side by side for each lookup.
  • 02Works out of the box with a built-in free LLM proxy.
  • 03Supports any OpenAI-compatible model through environment-style configuration.
  • 04Streams LLM output with colored word-sense highlighting.
  • 05Keeps a searchable history viewable with the `list` command.
  • 06Includes an Agent Skill for AI coding assistants.

Use cases

  • Looking up an English word or Chinese term without leaving the terminal.
  • Translating a quick Chinese sentence into English while coding or writing.
  • Letting an AI coding agent handle translation requests through the bundled skill.
  • Comparing dictionary definitions with an LLM translation for the same phrase.

Quick start

  1. 1

    Install the CLI globally with npm

    npm i fanyi -g
  2. 2

    Translate a word or sentence

    fanyi love

Things to know

  • Only translates between Chinese and English.
  • Translation results depend on third-party sources (iciba, Youdao, and an LLM).

Topics

FAQ

What is fanyi?
A command-line Chinese-English translator (npm package "fanyi") that combines iciba, Youdao dictionary results and LLM translation. fanyi is a command-line translator for Chinese and English. Run `fanyi <word>` (or the short alias `fy`) in a terminal and it returns dictionary entries from iciba and Youdao together with a translation generated by an LLM. It handles single words, phrases, and full Chinese sentences.
Is fanyi free to use? What license does it have?
fanyi is open source under the MIT license. Check the license terms before using it in commercial products.
Is fanyi still maintained?
Updated within 6 months. The last commit to fanyi was on Sep 7, 2026.
What can I use fanyi for?
Looking up an English word or Chinese term without leaving the terminal. Translating a quick Chinese sentence into English while coding or writing. Letting an AI coding agent handle translation requests through the bundled skill. Comparing dictionary definitions with an LLM translation for the same phrase.
How do I install fanyi?
Install the CLI globally with npm: npm i fanyi -g Translate a word or sentence: fanyi love
Where can I get fanyi?
The source code and installation instructions are on GitHub: https://github.com/afc163/fanyi

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects