Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/tisfeng/appletranslation
- Owner: tisfeng
- License: mit
- Created: 2024-10-17T15:58:04.000Z (30 days ago)
- Default Branch: main
- Last Pushed: 2024-11-11T14:18:57.000Z (5 days ago)
- Last Synced: 2024-11-11T15:26:42.850Z (5 days ago)
- Topics: apple, translation
- Language: Swift
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)
```