• Stars
    star
    106
  • Rank 325,871 (Top 7 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 10 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple Swift API for Microsoft Translator

Polyglot

Build Status

Swift wrapper around the Microsoft Translator API. By default, it translates to English from whatever language is detected.

Installation

The easiest way to get started is to use CocoaPods. Just add the following line to your Podfile:

pod 'Polyglot', '~> 0.5'

Otherwise, just include the contents of the Polyglot directory manually to your project.

Basic Usage

Create a new Polyglot instance.

let translator = Polyglot(clientId: "YOUR_CLIENT_ID", clientSecret: "YOUR_CLIENT_SECRET")

You can optionally specify to & from language codes.

translator.fromLanguage = Language.Dutch // It will automatically detect the language if you don't set this.
translator.toLanguage = Language.English // English. This is the default.

Start translating.

let dutch = "Ik weet het niet."
translator.translate(dutch) { translation in
    print("\"\(dutch)\" means \"\(translation)\"")
}

Check out the sample project for a quick demo.

Supported Languages

This list will grow as Microsoft Translator’s list grows.

Supported languages
Arabic
Bosnian
Bosnian (Latin)
Bulgarian
Catalan
ChineseSimplified
ChineseTraditional
Croation
Czech
Danish
Dutch
English
Estonian
Finnish
French
German
Greek
Haitian Creole
Hebrew
Hindi
HmongDaw
Hungarian
Indonesian
Italian
Japanese
Kiswahili
Klingon
Klingon pIqaD
Korean
Latvian
Lithuanian
Malay
Maltese
Norwegian
Persian
Polish
Portuguese
Queretaro Otomi
Romanian
Russian
Serbian
Serbian (Cyrillic)
Serbian (Latin)
Slovak
Slovenian
Spanish
Swedish
Thai
Turkish
Ukrainian
Urdu
Vietnamese
Welsh
Yucatec Maya

Setting up an account for Microsoft Translator

  1. Subscribe to the Microsoft Translator service here. You’ll probably need to set up a new account first. Good luck. :trollface:
  2. Create a new application here. This is where you will be given a client ID and client secret (which you will need for using Polyglot).

Contributing

We’d love to see your ideas for improving this library! The best way to contribute is by submitting a pull request. We’ll do our best to respond to your patch as soon as possible. You can also submit a new GitHub issue if you find bugs or have questions. :octocat:

Please make sure to follow our general coding style and add test coverage for new features!