Add DeepL-API.plist to your project. (Put it into the main bundle.)
Usage
Requests translation
import DeepLAPI
// texts to be translated.
let list: [String] = [
"What are those?",
"Those are two cows.",
"You have two cows.",
"You have to give one to your neighbor."
]
// translate the list to Japanese using auto-detection.
let response = try await DeepLAPI.translate(list, to: .JA)
// translate the list from English to Japanese
let response = try await DeepLAPI.translate(list, from: .EN, to: .JA)
// print translated texts.
for translation in response.transrations {
print(translation.text)
}
// "あれは何?"
// "2頭の牛だ"
// "2頭いるでしょ?"
// "1頭はお隣さんにあげなきゃね。"
import DeepLAPI
let usage = try await DeepLAPI.getUsage()
print(usage.characterCount) // Characters translated
print(usage.characterLimit) // Current maximum number of characters
print(usage.documentCount) // Documents translated
print(usage.documentLimit) // Current maximum number of documents
// for team accounts only
print(usage.teamDocumentCount // Documents translated by all users in the team
print(usage.teamDocumentLimit) // Current maximum number of documents
import DeepLAPI
let languages = try await getSourceLanguages()
for language in languages {
print("\(language.name) [\(language.language)]) // "Japanese [JA]"
}
import DeepLAPI
let languages = try await getTargetLanguages()
for language in languages {
let support = language.supportsFormality ? "(Support Formality)" : ""
print("\(language.name) [\(language.language)] \(support)")
// "German [DE] (Support Formality)"
}
DeepL API client library for iOS
Initial Setup
Usage
Requests translation
API document
Retrieves usage information
API document
Retrieves Supported Languages (Source)
API document
Retrieves Supported Languages (Target)
API document
Requirements
Dependencies
Web Client to get data from an API endpoint.
Utility to simplify making a URL String with parameters.