Skip to content
This repository has been archived by the owner on Jul 5, 2023. It is now read-only.

hoyelam/DeepL-Swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DeepLAPI(unofficial)

DeepL is a translation service similar to Google Translate. DeepAPI is a Swift open-source library that implements Swift-based clients to interact with the DeepL API using an Authentication Key. You can get an Authentication Key on their website. As of right now, this library supports only the free version of the API

Installation

The library requires macOS 10.16+ / iOS 14.0+ / tvOS 14.0+ / watchOS 7.0+

You can add DeepLAPI-Swift by adding it as a Swift Package Manager dependency:

  1. From the File menu, select Add packages
  2. Enter "[https://github.com/hoyelam/DeepL-Swift]"
  3. Select the package

Using Package.swift?

dependencies: [
    .package(url: "https://github.com/hoyelam/DeepL-Swift")
]

Example

To translate a text

let authToken = "12345QWERTASDFG" // Provided by DeepL
let service = DeepLAPI(authToken: authToken)
let request = TranslationRequest(
    text: "Hello World!",
    sourceLanguage: .english,
    targetLanguage: .dutch
)

do {
    let result = try await service.translateText(request: request)
    print(result.translations)
} catch let error {
    // Your amazing error handling
}

To be supported

  • DeepL Pro
  • Managing Glossaries
  • Translating Documents