Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tisfeng/appletranslation

AppleTranslation is a wrapper for the Apple Translation API.
https://github.com/tisfeng/appletranslation

apple translation

Last synced: about 3 hours ago
JSON representation

AppleTranslation is a wrapper for the Apple Translation API.

Awesome Lists containing this project

README

        

# AppleTranslation

AppleTranslation is a wrapper for the [Apple Translation API](https://developer.apple.com/documentation/Translation/translating-text-within-your-app).

It's a part of [Easydict](https://github.com/tisfeng/Easydict).

## Usage

```swift
import AppleTranslation

// English -> Chinese
let translationService = TranslationService(
configuration: .init(
source: .init(languageCode: .english),
target: .init(languageCode: .chinese)
)
)
var response = try await translationService.translate(text: "Hello, world!")
print(response.targetText)

// Chinese -> English
response = try await translationService.translate(
text: "你好",
sourceLanguage: .init(languageCode: .chinese),
targetLanguage: .init(languageCode: .english)
)
print(response.targetText)
```