hammerspoon2-docs
    Preparing search index...

    Namespace translation

    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.

    hs.translation.status("en", "fr").then(s => {
    if (s === "installed") {
    const session = 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")
    }
    })

    Functions

    session
    status
    supportedLanguages