SwiftGoogleTranslate is a Swift library that provides a convenient way to interact with the Google Translate API. With this library, you can easily translate text between different languages in your iOS or macOS applications.
Installation
To install SwiftGoogleTranslate, you have a few options:
-
Using CocoaPods:
pod 'SwiftGoogleTranslate'
-
Using Swift Package Manager:
.package(url: "https://github.com/maximbilan/SwiftGoogleTranslate.git", from: "1.0.0")
-
Manual installation:
-
Download the latest release from the GitHub repository.
-
Add the
SwiftGoogleTranslate.swift
file to your Xcode project.
-
Usage
Once you have SwiftGoogleTranslate installed, you can start using it in your project.
import SwiftGoogleTranslate
// Translate text from English to French
SwiftGoogleTranslate.shared.translate("Hello", "en", "fr") { (result) in
switch result {
case .success(let translation):
print("Translation: \(translation)")
case .failure(let error):
print("Error translating: \(error)")
}
}
That’s all you need to get started with SwiftGoogleTranslate! You can now integrate language translation into your iOS or macOS app effortlessly.