https://github.com/itzmeanjan/translate
A simple to use Dart package, for detecting & translating text/ html pages using Yandex.Translate API
https://github.com/itzmeanjan/translate
dart tranlation yandex-translate
Last synced: 7 months ago
JSON representation
A simple to use Dart package, for detecting & translating text/ html pages using Yandex.Translate API
- Host: GitHub
- URL: https://github.com/itzmeanjan/translate
- Owner: itzmeanjan
- License: mit
- Created: 2019-05-30T16:29:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T14:57:06.000Z (over 6 years ago)
- Last Synced: 2024-10-06T13:41:29.354Z (about 1 year ago)
- Topics: dart, tranlation, yandex-translate
- Language: Dart
- Homepage:
- Size: 225 KB
- Stars: 5
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# translate
A simple to use Dart package, for detecting & translating *text* and *html pages* using Yandex.Translate APIShow some :heart:, by putting :star:
**This package is readily avaiable for [use](https://pub.dev/packages/translate).**
## what does it do ?
- Fetches list of languages along with language codes, supported by Yandex.Translate API
- Detects which language given text belongs to
- Translates text or html page to certain language, denoted by language code## How to use ?
First get yourself a *Yandex.Translate* API Key, which can be found [here](https://translate.yandex.com/developers/keys).Fetch list of supported language :
```dart
Languages('api_key')
.fetch()
.then(
(data) => print(data),
onError: (e) => print(e),
).then((val) => exit(0));
```
Response in case of success,
```json
{
ru: 'Russian',
en: 'English',
}
```
Response in case of error,
```json
{
error: ' ... '
}
```
Detect language of text :
```dart
DetectIt('api_key')
.detect('Hello World', hint: [
'en',
'de',
'ru',
'hi',
]) // hints are to be prioritized by platform while detecting language, if provided
.then(
(data) => print(data),
onError: (e) => print(e),
)
.then((val) => exit(0));
```
Response in case of success,
```json
{
lang: 'en'
}
```
Response in case of error,
```json
{
error: ' ... '
}
```
Translate Text :
```dart
TranslateIt('api_key')
.translate(
'Hello WorldHello World
',
'en-ru', // only `ru` will also do same job
type: 'html') // type is `html`, cause this text is markedup
.then(
(data) => print(data),
onError: (e) => print(e),
)
.then((val) => exit(0));
```
English | Russian
--------|---------
|
------------------Response in case of success,
```json
{
text: ' ... '
}
```
Response in case of error,
```json
{
error: ' ... '
}
```
## Courtesy :
Translation API is powered by [Yandex.Translate](https://translate.yandex.com/), so all thanks goes to them.If you're interested in learning more about T&C, take a look [here](https://tech.yandex.com/translate/doc/dg/concepts/design-requirements-docpage/).
You can also go for [priced version](https://translate.yandex.com/developers/prices).
Hoping, it was helpful :wink: