Skip to content

paradiseduo/SystemTranslation

 
 

Repository files navigation

SystemTranslation

Apple's Translation framework binds TranslationSession with SwiftUI's View, It doesn't have an init method for initialization, a session must be started using the translationTask of its View.

This library decouples these dependencies. It achieves this by displaying a transparent, non-interactive window to host a View for translation, enabling translation without SwiftUI or a user interface.

Requirements

AppKit or UIKit macOS 15 or later. iOS 18 or later. Swift 5.10 or later.

Usage

Use the TranslationService singleton for translation,

func translate(_ text: String, source: TranslationLanguage, target: TranslationLanguage) async throws -> String.

Since some languages may not be downloaded, please have the user download them before translation.

func prepareTranslation(in viewController: NSUIViewController, source: TranslationLanguage, target: TranslationLanguage) async throws

About

Headless for Apple Translation framework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Swift 100.0%