google_translate

Version, currently 0.2.13 versions

github.com/greyblake/crystal-google_translate

Google Translate client for Crystal

14 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  google_translate:
    github: greyblake/crystal-google_translate
    version: ~> 0.2.1

Then run:

shards install

shard.yml

Crystal
no constraint declared
License
MIT
Author
Sergey Potapov <blake131313@gmail.com>

Dependencies

Runtime Dependencies

  • cossack~> 0.1.0github: greyblake/crystal-cossack

Development Dependencies

  • spec2*github: greyblake/spec2.cr, branch: crystal-0-18-0dev

README

# Crystal GoogleTranslate [![Build Status](https://travis-ci.org/greyblake/crystal-google_translate.svg?branch=master)](https://travis-ci.org/greyblake/crystal-google_translate)

Crystal client for GoogleTranslate

## Installation

Add this to your application's `shard.yml`:

```yaml
dependencies:
  google_translate:
    github: greyblake/crystal-google_translate
```


## Usage

```crystal
require "google_translate"
```

### Example
The following code translates german word `tanzen` with a typo(double n) and prints the result:


```crystal
client = GoogleTranslate::Client.new
tr = client.translate("de", "en", "tanzenn")

puts "#{tr.source_lang} -> #{tr.target_lang}"
puts "Query: #{tr.query}"
puts "Corrected query: #{tr.corrected_query}"
puts "Text: #{tr.text}"
tr.variants.each do |word_class, words|
  puts word_class
  words.each do |word|
    puts "  #{word}"
  end
end
```

Output:

```
de -> en
Query: tanzenn
Corrected query: tanzen
Text: dance
verb
  dance
  hop
  spin
  bob
  foot
```


## Development

To run specs:

```
crystal spec
```

## Contributors

- [greyblake](https://github.com/greyblake) Sergey Potapov - creator, maintainer