Translate text between languages using the macOS on-device Translation framework.
Language identifiers use BCP-47 format (e.g. "en", "fr", "zh-Hans").
Call hs.translation.supportedLanguages() to list every language the framework
recognises, and hs.translation.status() to check whether a specific pair is
installed and ready for offline use.
Language packs are downloaded through
System Settings → General → Language & Region → Translation Languages*.
hs.translation cannot trigger downloads programmatically; session() returns
null when the requested pair is not yet installed.
Quick start
hs.translation.status("en", "fr").then(s=> { if (s === "installed") { constsession = hs.translation.session("en", "fr") session.translate("Good morning").then(r=>console.log(r)) } else { console.log("Install en→fr in System Settings → Language & Region → Translation Languages") } })
Translate text between languages using the macOS on-device Translation framework. Language identifiers use BCP-47 format (e.g.
"en","fr","zh-Hans"). Callhs.translation.supportedLanguages()to list every language the framework recognises, andhs.translation.status()to check whether a specific pair is installed and ready for offline use. Language packs are downloaded through System Settings → General → Language & Region → Translation Languages*.hs.translationcannot trigger downloads programmatically;session()returnsnullwhen the requested pair is not yet installed.Quick start