Swift wrapper around the Microsoft Translator API. By default, it translates to English from whatever language is detected.
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.
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.
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 |
- Subscribe to the Microsoft Translator service here. You’ll probably need to set up a new account first. Good luck.
- 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).
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.
Please make sure to follow our general coding style and add test coverage for new features!