Skip to content

Recipe: Pipe Combinations

yaku reads from stdin and writes to stdout, making it a natural fit for Unix pipelines.

Use markitdown to extract text from PDFs, then translate:

Terminal window
markitdown report.pdf | yaku --to en --format md

Use curl to fetch a page and translate its content:

Terminal window
curl -s https://example.com | yaku --to en

For Markdown content:

Terminal window
curl -s https://raw.githubusercontent.com/user/repo/main/README.md | \
yaku --to en --format md

Use the GitHub CLI to fetch and translate issues:

Terminal window
# Translate an issue body
gh issue view 123 --json body -q .body | yaku --to en
# Translate all comments on an issue
gh api repos/owner/repo/issues/123/comments \
--jq '.[].body' | yaku --to en
Terminal window
# Translate JSON API response
curl -s https://api.example.com/products | yaku --to en --format json
# Translate and pipe to jq for formatting
curl -s https://api.example.com/data | \
yaku --to en --format json | jq '.'
Terminal window
# macOS: translate clipboard and replace
pbpaste | yaku --to en | pbcopy
# Linux (xclip)
xclip -selection clipboard -o | yaku --to en | xclip -selection clipboard
Terminal window
# Using -o flag
echo "Bonjour" | yaku --to en -o greeting.txt
# Using shell redirection
echo "Bonjour" | yaku --to en > greeting.txt
# Translate multiple files with a loop
for f in docs/ja/*.md; do
yaku --to en -f "$f" -o "docs/en/$(basename "$f")"
done
Terminal window
man ls | col -b | yaku --to en | less

col -b strips formatting codes from man page output.

Terminal window
# Translate only the first 100 lines
head -100 large-doc.md | yaku --to en --format md
# Translate, then count words
yaku --to en -f article.ja.md | wc -w
# Extract strings from code, translate
grep -Eo '"[^"]*"' src/strings.go | yaku --to en
  • Use --format when piping. Without a file extension to detect, yaku defaults to plain text. Set --format md, --format json, or --format yaml explicitly.
  • Filter before translating. Use head, tail, or grep to reduce input size. This saves tokens and time.
  • Use -o instead of > for file output. The -o flag prints a confirmation message to stderr, making it clearer that the file was written.