macOS command line tool to translate input using the built-in macOS Translation Service.
macOS 26 has a fairly robust built-in Translation service.
This command line tool uses the Translation service to translate text passed as arguments from one language to another using Apple's Translation framework.
This tool requires macOS 26.0.
You can build the package from source with
swift build -c releaseor use the pkg installer available in releases.
Important: You have to download the Translation resources in System Settings > Languge & Region > Translation Languages… (button at the bottom of that pane) before using this tool. Otherwise you will get Error: Unable to Translate messages. You only need to download the languages you are going to use.
By default, translate will translate the text from the arguments to the current system language. (in the examples, the current system language is English)
$ translate "Dies ist ein kurzer Satz."
This is a short sentence.Multiple arguments will be joined together, so you don't need to quote the input, unless there are special characters:
$ translate Dies ist ein kurzer Satz.
This is a short sentence.$ translate "Dies ist ein kurzer Satz!"
This is a short sentence.You can set different target languages with the --to flag:
$ translate "Dies ist ein kurzer Satz." --to fr
C'est une courte phrase.You can provide multiple --to options with different language codes. Each translation will be prepended with the language code.
$ translate --to en --to fr --to es "Dies ist ein kurzer Satz."
en: This is a short sentence.
fr: C'est une courte phrase.
es: Esta es una frase corta.The source language will be determined from the text. You can override the detection with the --from flag:
$ translate --from de "Dies ist ein kurzer Satz."
This is a short sentence.
$ translate --from de --to fr "Dies ist ein kurzer Satz."
C'est une courte phrase.When no arguments are given as arguments, text will be read from standard input:
$ echo "Dies ist ein kurzer Satz." | translate
This is a short sentence.Use the detect subcommand to detect the dominant language in the text:
$ translate detect "Dies ist ein kurzer Satz."
deXcode uses xcstrings to store localizations of text strings. You can use translate to add translations to an xcstrings file.
Usage:
$ translate xcstrings --to de --to fr path/to/Localizations.xcstrings path/to/Localizations_translated.xcstringsStrings marked in Xcode as "Don't Translate" will be skipped.
When no output path is given, the resulting json will be output to standard out. The status messages are printed to standard error, so you can redict stdout to a file or pipe it into a different tool, e.g.
$ translate xcstrings --to de Localizations.xcstrings | jq '.strings | keys'When the field for a given translation already has a value, it will be skipped unless the --replace-translations flag is set.