Skip to content

min0625/mint

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

47 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐ŸŒ Other languages

๐ŸŒฟ Mint

Minimalist AI Translation CLI โ€” Simple. Fast. Intuitive.

GitHub Release PyPI npm codecov

Mint is a single-binary, LLM-powered translation CLI. Set two environment variables and translate anything from the command line โ€” files, piped output, or inline text. Built-in language detection, grammar correction, streaming output, and multi-language rotation.

export MINT_PROVIDER=google-genai
export MINT_API_KEY=your_key

mint -t ja "Good morning"         # ใŠใฏใ‚ˆใ†ใ”ใ–ใ„ใพใ™
echo "ๆ—ฉๅฎ‰" | mint -t en          # Good morning
cat document.txt | mint -t fr     # translate a whole file

โœจ Why Mint?

  • Zero-config โ€” Single binary; API keys via env vars, no config file pollution
  • Multi-provider โ€” Google Gemini, OpenAI, Anthropic, or local Ollama / LM Studio
  • Smart detection โ€” Auto-detects language on every call; language-neutral content (numbers, symbols) passes through unchanged
  • Smart correction โ€” Same-language input? Auto-corrects grammar & spelling instead of translating
  • Streaming โ€” Output streams in real-time, no waiting for long translations
  • Composable โ€” Pipe-friendly stdin/stdout; pairs seamlessly with grep, sed, xargs, and friends

๐Ÿ“‹ Installation

Automated install (recommended)

macOS / Linux

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/min0625/mint/main/script/install.sh)"

Auto-detects OS and architecture (Linux/macOS, x86_64/arm64), installs to ~/.local/bin. Override with MINT_INSTALL_DIR or pin a version with MINT_VERSION=v1.0.0.

Windows (PowerShell)

irm https://raw.githubusercontent.com/min0625/mint/main/script/install.ps1 | iex

Auto-detects architecture (x86_64/arm64) and installs to $HOME\.local\bin. Override with $env:MINT_INSTALL_DIR or pin a version with $env:MINT_VERSION = 'v1.0.0'.

Homebrew (macOS / Linux)

brew install min0625/tap/mint-ai

pipx

pipx install mint-ai

npm

npm install -g mint-ai

Manual download

Download the pre-built binary for your platform from GitHub Releases, move it into a directory on your PATH, then verify:

mint --version

๐Ÿš€ Quick Start

1. Set your provider

# Google Gemini (free tier available โ€” https://aistudio.google.com/apikey)
export MINT_PROVIDER=google-genai
export MINT_API_KEY=your_gemini_api_key

# OpenAI
export MINT_PROVIDER=openai
export MINT_API_KEY=sk-...

# Anthropic
export MINT_PROVIDER=anthropic
export MINT_API_KEY=sk-ant-...

# Ollama (no API key needed)
export MINT_PROVIDER=openai
export MINT_BASE_URL=http://localhost:11434
export MINT_MODEL_NAME=qwen2.5:7b  # use any model loaded in Ollama

# LM Studio (no API key needed)
export MINT_PROVIDER=openai
export MINT_BASE_URL=http://localhost:1234
export MINT_MODEL_NAME=lmstudio-community/Qwen2.5-7B-Instruct-GGUF  # use any model loaded in LM Studio

2. Translate

mint --target ja "Good morning"
mint -t zh-TW "Good morning"

echo "The quick brown fox" | mint -t fr
cat document.txt | mint -t zh-TW

Use --verbose / -v (or MINT_VERBOSE=true) to print diagnostic info and token usage to stderr:

mint -t ja -v "Good morning"
# [mint] provider: google-genai
# [mint] model: gemini-3.1-flash-lite
# [mint] single target โ€” skipping language detection
# [mint] target language: ja
# ใŠใฏใ‚ˆใ†ใ”ใ–ใ„ใพใ™
# [mint] tokens: 113 in / 2 out

Typical token usage (measured on gemini-3.1-flash-lite):

Mode Input Calls Input tokens Output tokens
Single-target (-t or single MINT_TARGET_LANG) short word/sentence 1 ~110โ€“130 ~1โ€“15
Single-target long article (testdata/sample.txt) 1 ~465โ€“470 ~450โ€“560
Multi-target rotation (comma-separated MINT_TARGET_LANG) short sentence 2 ~250โ€“260 ~2โ€“8
Explicit source -s + rotation short sentence 1 ~105โ€“120 ~1โ€“2

Token counts scale with input length. Output tokens vary by target language โ€” Japanese and Chinese tend to produce more tokens than English for equivalent content.

How far does 1M tokens go? (input + output combined, derived from the measured usage above):

Input ~Tokens per translation Translations per 1M tokens
Short word or phrase ~120 ~8,000
300-word article ~1,000 ~1,000

Counts combine input and output tokens. Providers price input and output separately and many offer free tiers โ€” check your provider's pricing page for current rates. Google Gemini's free tier at Google AI Studio needs no credit card.

Force the source language with --source / -s to translate input that is also valid in the target language (cross-language homographs, romanized text):

mint -s fr -t en "pain"          # French โ†’ bread (without -s, treated as English "pain")
mint -s ja -t en "konnichiwa"    # romaji Japanese โ†’ hello

3. Smart language detection

Translation with auto-detection:

export MINT_TARGET_LANG=en

mint "ๆ—ฉๅฎ‰"   # Detects Chinese โ†’ Good morning

Grammar & spelling correction โ€” when input language matches the target, Mint corrects instead of translates:

export MINT_TARGET_LANG=en

mint "Good mooorning"          # Detects English โ†’ Good morning
mint "She don't know nothing"  # Detects English โ†’ She doesn't know anything
mint "i luv coding"            # Detects English โ†’ I love coding

Language rotation โ€” translates to the next language in the list, wrapping around:

# Two languages
export MINT_TARGET_LANG=en,zh-TW
mint "Hello"   # en โ†’ zh-TW: ไฝ ๅฅฝ
mint "ไฝ ๅฅฝ"    # zh-TW โ†’ en: Hello

# Three languages
export MINT_TARGET_LANG=en,zh-TW,ja
mint "Hello"       # en โ†’ zh-TW: ไฝ ๅฅฝ
mint "ไฝ ๅฅฝ"        # zh-TW โ†’ ja: ใ“ใ‚“ใซใกใฏ
mint "ใ“ใ‚“ใซใกใฏ"   # ja โ†’ en: Hello

๐Ÿ”‘ Environment Variables

Variable Description Default
MINT_PROVIDER google-genai | openai | anthropic โ€” (required)
MINT_API_KEY API key; required when using the default endpoint; optional when MINT_BASE_URL is set (proxy handles auth) โ€”
MINT_BASE_URL Custom API base URL (domain only; each provider appends its own path); use with openai to target Ollama (http://localhost:11434), LM Studio (http://localhost:1234), or any other OpenAI-compatible endpoint Provider default
MINT_MODEL_NAME Model to use gemini-3.1-flash-lite / gpt-4o-mini / claude-haiku-4-5
MINT_TARGET_LANG Target language(s), e.g. en or en,zh-TW,ja System locale
MINT_VERBOSE Set to true to enable verbose diagnostic output (equivalent to --verbose) false

๐Ÿšฉ CLI Flags

Flag Short Description
--target <lang> -t Target language (BCP-47 tag, e.g. ja, zh-TW, fr). Overrides MINT_TARGET_LANG.
--source <lang> -s Source language (BCP-47 tag); skips auto-detection and forces translation from this language.
--verbose -v Print diagnostic info and token usage to stderr. Also enabled by MINT_VERBOSE=true.
--version Print version and exit.

๐Ÿ“… Roadmap

  • Multi-LLM provider support (Google Gemini, OpenAI, Anthropic, local via Ollama / LM Studio)
  • Smart language detection and multi-language rotation via MINT_TARGET_LANG
  • Explicit target language via --target / -t flag
  • Explicit source language via --source / -s flag
  • Streaming output
  • GoReleaser multi-platform binary release (Linux / macOS / Windows)
  • Batch translation mode
  • Glossary / custom dictionary support
  • Output format options (plain text, JSON, Markdown)
  • Caching for repeated translations

๐Ÿ“„ License

Apache License 2.0 โ€” see LICENSE for details.