Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maximbilan/SwiftGoogleTranslate
Lightweight framework for using Cloud Translation API by Google
https://github.com/maximbilan/SwiftGoogleTranslate
google google-cloud-platform swift translate translation xcode
Last synced: about 2 months ago
JSON representation
Lightweight framework for using Cloud Translation API by Google
- Host: GitHub
- URL: https://github.com/maximbilan/SwiftGoogleTranslate
- Owner: maximbilan
- License: mit
- Created: 2018-10-28T18:33:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-07-20T20:59:17.000Z (12 months ago)
- Last Synced: 2024-05-04T11:41:09.632Z (about 2 months ago)
- Topics: google, google-cloud-platform, swift, translate, translation, xcode
- Language: Swift
- Homepage:
- Size: 40 KB
- Stars: 94
- Watchers: 3
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-translations - SwiftGoogleTranslate - A framework to use cloud translation API by Google in Swift. (Tools / Machine translation for developers)
- awesome-i18n - SwiftGoogleTranslate - framework to use cloud translation API by Google in Swift (π¦ Libraries / Swift (iOS & macOS))
README
## SwiftGoogleTranslate
[![Version](https://img.shields.io/cocoapods/v/SwiftGoogleTranslate.svg?style=flat)](http://cocoadocs.org/docsets/SwiftGoogleTranslate)
[![License](https://img.shields.io/cocoapods/l/SwiftGoogleTranslate.svg?style=flat)](http://cocoadocs.org/docsets/SwiftGoogleTranslate)
[![Platform](https://img.shields.io/cocoapods/p/SwiftGoogleTranslate.svg?style=flat)](http://cocoadocs.org/docsets/SwiftGoogleTranslate)
[![CocoaPods](https://img.shields.io/cocoapods/dt/SwiftGoogleTranslate.svg)](https://cocoapods.org/pods/SwiftGoogleTranslate)A framework to use Cloud Translation API by Google in Swift.
:snowman::frog::penguin::whale::turtle:## Installation
CocoaPods:
pod 'SwiftGoogleTranslate'
Carthage:
github "maximbilan/SwiftGoogleTranslate"
Swift Package Manager:
dependencies: [
.package(url: "https://github.com/maximbilan/SwiftGoogleTranslate", from: "0.2.2"))
]
Manual:
Copy SwiftGoogleTranslate.swift to your project.## Initialization
First of all you have to generate API key to use Google Cloud services in the console.
And then use the following code:
```swift
SwiftGoogleTranslate.shared.start(with: "API_KEY_HERE")
```## Using
The framework supports 3 endpoinds: translate, detect, languages. You can find more information in the official source. How to use from the framework.
Translation:
```swift
SwiftGoogleTranslate.shared.translate("Hello!", "es", "en") { (text, error) in
if let t = text {
print(t)
}
}
```Detection:
```swift
SwiftGoogleTranslate.shared.detect("Β‘Hola!") { (detections, error) in
if let detections = detections {
for detection in detections {
print(detection.language)
print(detection.isReliable)
print(detection.confidence)
print("---")
}
}
}
```A list of languages:
```swift
SwiftGoogleTranslate.shared.languages { (languages, error) in
if let languages = languages {
for language in languages {
print(language.language)
print(language.name)
print("---")
}
}
}
```## License
SwiftGoogleTranslate is available under the MIT license. See the LICENSE file for more info.