Input & Output
Input methods
Section titled “Input methods”yaku accepts input in three ways, checked in this order:
| Priority | Method | Example |
|---|---|---|
| 1 (highest) | File (-f) | yaku --to en -f article.ja.txt |
| 2 | Positional argument | yaku --to en "Bonjour le monde" |
| 3 | stdin pipe | echo "こんにちは" | yaku --to en |
| 4 (lowest) | Interactive input | yaku --to en then type text + Ctrl+D |
If multiple are provided, the higher-priority source wins.
File input (-f)
Section titled “File input (-f)”Translate one or more files. When multiple files are given, their contents are concatenated:
# Single fileyaku --to en -f README.ja.md
# Multiple filesyaku --to en -f chapter1.fr.md -f chapter2.fr.mdyaku auto-detects the format from the file extension (.md, .json, .yaml). See Format-Aware Translation for details.
Positional argument
Section titled “Positional argument”Pass short text directly on the command line:
yaku --to en "おはようございます"yaku --to en "La reunión es mañana a las diez."Multiple arguments are joined with spaces:
yaku --to en Bonjour le monde# Translates "Bonjour le monde"stdin pipe
Section titled “stdin pipe”Pipe text from another command:
echo "Bonjour le monde" | yaku --to encat article.ja.md | yaku --to engit log --oneline -5 | yaku --to encurl -s https://example.com/api/docs | yaku --to enstdin 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 enin 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.
Output
Section titled “Output”stdout (default)
Section titled “stdout (default)”yaku writes translated text to stdout and nothing else. Errors, hints, and verbose info go to stderr. This keeps output clean for piping:
# Pipe to clipboard (macOS)echo "こんにちは" | yaku --to en | pbcopy
# Pipe to another commandyaku --to en -f report.ja.md | wc -w
# Redirect to fileyaku --to en -f doc.fr.md > translated.mdFile output (-o)
Section titled “File output (-o)”Write directly to a file:
yaku --to en -f README.ja.md -o README.mdyaku prints a confirmation to stderr:
Wrote README.mdStreaming output (--stream)
Section titled “Streaming output (--stream)”See the translated text as the LLM generates it, instead of waiting for the full response:
yaku --to en --stream -f long-article.ja.mdStreaming 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.
Verbose output (--verbose)
Section titled “Verbose output (--verbose)”Print model name, token usage, and elapsed time to stderr:
echo "Bonjour" | yaku --to en --verbosestdout:
Hellostderr:
Model: gemini-2.5-flash | Tokens: 42 in / 38 out | Time: 1.2sSince verbose info goes to stderr, you can still pipe stdout cleanly:
echo "Bonjour" | yaku --to en --verbose | pbcopy# Clipboard gets "Hello", terminal shows model infoOutput sanitization
Section titled “Output sanitization”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.