mac-translate-cli provides trn, a small Swift command-line translator for macOS 26.4 Tahoe or later.
- 🍎 Uses the macOS built-in Translation framework, optimized for Apple Silicon.
- ⚡ Fast in everyday use because translation runs through Apple's on-device system translation service.
- 💸 Free to use: no paid translation API key or subscription is required.
- 🔒 Fully local: your source text does not need to be sent to a remote translation API.
- 🛠️ Secure and convenient for private notes, documents, shell pipelines, and developer workflows.
- 🎛️ Select high-quality Apple Intelligence translation or low-latency traditional translation with
--quality. - 📊 The quality report found
lowsufficient for the tested English/Japanese cases, while running about 10x faster thanhigh.
Install trn with Homebrew:
brew tap hotchpotch/mac-translate-cli https://github.com/hotchpotch/mac-translate-cli
brew install hotchpotch/mac-translate-cli/trnRun a translation:
trn --to ja "Hello world!"
#=> こんにちは、世界!Use it in a pipeline:
echo "Hello world!" | trn --to ja
#=> こんにちは、世界!- macOS 26.4 Tahoe or later
- Command Line Tools with the macOS 26.4 SDK or later for building the executable
- Xcode with the macOS 26.4 SDK or later for running the test suite
- Installed Apple translation language packages for the language pairs you want to use
If a required language package is supported but not installed, trn reports that the package needs to be installed from System Settings.
trn behaves like a Unix-style filter: it accepts text from standard input, buffers it into translation chunks, translates the chunks concurrently, and writes the translated text to standard output in the original order. You can also pass one positional text argument for quick one-off translations.
Quality-sensitive evaluation:
trn --from en --to ja --quality high "Hello world!"
trn --from en --to ja --quality low "Hello world!"low is the default and is usually the practical choice for English/Japanese translation. Use --quality high when you want to compare against Apple's high-fidelity translation model or inspect whether a specific sentence benefits from it.
Basic translation:
trn --to ja "Hello world!"
#=> こんにちは、世界!Use a language name instead of a language code:
trn --to japanese "Hello world!"
#=> こんにちは、世界!Read source text from standard input:
echo "Hello world!" | trn --to ja
#=> こんにちは、世界!Specify the source language explicitly:
trn --from en --to ja "Hello world!"
#=> こんにちは、世界!Choose translation quality:
trn --to ja --quality high "Hello world!"
trn --to ja -q low "Hello world!"low is the default and uses Apple's lower-latency traditional translation models. high uses Apple Intelligence high-fidelity translation when available.
If --from is omitted, trn auto-detects the source language from the input text before creating the translation request:
trn --to en "こんにちは、世界!"
#=> Hello, world!Buffered paragraph translation is the default. trn splits input on newlines and keeps each chunk at or below 512 characters when possible. The -s / --stream flag is still accepted for clarity and backward compatibility, but it is not required.
cat notes.txt | trn --to jaThe default maximum concurrency is 4. You can change it with -j or --concurrency:
cat notes.txt | trn --to ja --concurrency 2
cat notes.txt | trn --to ja -j 2Buffered chunks are translated concurrently, but output order is preserved.
When --from is omitted, trn detects the source language once from the full input and reuses that language for every chunk.
Change the translation buffer size with -b or --buffer-size. The value is a character count. Smaller buffers start work sooner and can reduce per-request size; larger buffers preserve more context per translation request.
cat notes.txt | trn --to ja --buffer-size 256
cat notes.txt | trn --to ja -b 1024Example:
printf 'Hello world!\nGood morning.\n' | trn --to ja --concurrency 2
#=> こんにちは、世界!
#=>
#=> おはようございます。Build the debug executable:
swift buildRun the executable from the build directory:
.build/debug/trn --to ja "Hello world!"
#=> こんにちは、世界!Build a release executable:
swift build -c releaseCopy the release binary into a directory on your PATH.
For a user-local bin directory:
mkdir -p ~/.bin
cp .build/release/trn ~/.bin/For a system-wide install location:
sudo cp .build/release/trn /usr/local/bin/After copying, confirm that the command is available:
trn --to ja "Hello world!"
#=> こんにちは、世界!Run the test suite:
swift testThe tests use Swift Testing, so run them with Xcode selected rather than Command Line Tools only.
Build the package:
swift buildThe core behavior lives in Sources/TranslateCore/ so it can be tested without launching a subprocess. The executable entry point is Sources/trn/main.swift.
MIT License. See LICENSE.
Yuichi Tateno (@hotchpotch)