Skip to content

Input & Output

yaku accepts input in three ways, checked in this order:

PriorityMethodExample
1 (highest)File (-f)yaku --to en -f article.ja.txt
2Positional argumentyaku --to en "Bonjour le monde"
3stdin pipeecho "こんにちは" | yaku --to en
4 (lowest)Interactive inputyaku --to en then type text + Ctrl+D

If multiple are provided, the higher-priority source wins.

Translate one or more files. When multiple files are given, their contents are concatenated:

Terminal window
# Single file
yaku --to en -f README.ja.md
# Multiple files
yaku --to en -f chapter1.fr.md -f chapter2.fr.md

yaku auto-detects the format from the file extension (.md, .json, .yaml). See Format-Aware Translation for details.

Pass short text directly on the command line:

Terminal window
yaku --to en "おはようございます"
yaku --to en "La reunión es mañana a las diez."

Multiple arguments are joined with spaces:

Terminal window
yaku --to en Bonjour le monde
# Translates "Bonjour le monde"

Pipe text from another command:

Terminal window
echo "Bonjour le monde" | yaku --to en
cat article.ja.md | yaku --to en
git log --oneline -5 | yaku --to en
curl -s https://example.com/api/docs | yaku --to en

stdin is only read when no -f flag and no positional arguments are provided. yaku detects whether stdin is a pipe or a terminal:

  • Pipe mode — reads silently (e.g., echo "こんにちは" | yaku --to en)

  • Interactive mode — if you run yaku --to en in a terminal with no input, yaku prompts you to type text directly:

    Enter text to translate (Ctrl+D to finish):

    Type or paste your text, then press Ctrl+D to submit.

yaku writes translated text to stdout and nothing else. Errors, hints, and verbose info go to stderr. This keeps output clean for piping:

Terminal window
# Pipe to clipboard (macOS)
echo "こんにちは" | yaku --to en | pbcopy
# Pipe to another command
yaku --to en -f report.ja.md | wc -w
# Redirect to file
yaku --to en -f doc.fr.md > translated.md

Write directly to a file:

Terminal window
yaku --to en -f README.ja.md -o README.md

yaku prints a confirmation to stderr:

Wrote README.md

See the translated text as the LLM generates it, instead of waiting for the full response:

Terminal window
yaku --to en --stream -f long-article.ja.md

Streaming works with text and Markdown formats only. JSON and YAML translations always wait for the complete response (the structure must be intact before reassembly).

Streaming is automatically disabled when -o is used — the full output must be assembled before writing to a file.

Supported backends: Gemini, OpenAI, Anthropic. The hosted backend does not support streaming yet.

Print model name, token usage, and elapsed time to stderr:

Terminal window
echo "Bonjour" | yaku --to en --verbose

stdout:

Hello

stderr:

Model: gemini-2.5-flash | Tokens: 42 in / 38 out | Time: 1.2s

Since verbose info goes to stderr, you can still pipe stdout cleanly:

Terminal window
echo "Bonjour" | yaku --to en --verbose | pbcopy
# Clipboard gets "Hello", terminal shows model info

yaku automatically cleans up common LLM artifacts from the translated text:

  • Strips preambles — removes unwanted prefixes like “Here is the translation:” or “Translation:”
  • Strips trailing explanations — removes notes the LLM appends after a double newline (e.g., “Note: I translated X as Y because…”)
  • Strips wrapping quotes — removes "text" or 「text」 wrappers that the LLM sometimes adds
  • Strips code fences — removes ``` wrappers around the output

This runs on all backends automatically. You do not need to enable it.