Skip to content

Commit

Permalink
Merge pull request #49 from dorianmariefr/patch-1
Browse files Browse the repository at this point in the history
convert hash rocket syntax to symbol keys in README
  • Loading branch information
gmaliar authored Dec 22, 2020
2 parents 6df8b36 + 80d9c4a commit 23c05f3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ gem 'easy_translate'

```ruby
# auto-detect
EasyTranslate.translate('Hello, world', :to => :spanish) # => "Hola, mundo"
EasyTranslate.translate('Hello, world', :to => 'es') # => "Hola, mundo"
EasyTranslate.translate('Hello, world', to: :spanish) # => "Hola, mundo"
EasyTranslate.translate('Hello, world', to: 'es') # => "Hola, mundo"

# feel free to specify explicitly
EasyTranslate.translate('Hola, mundo', :from => :spanish, :to => :en) # => "Hello, world"
EasyTranslate.translate('Hola, mundo', from: :spanish, to: :en) # => "Hello, world"
```

## Batch translation (Yay!)

```ruby
# multiple strings
EasyTranslate.translate(['Hello', 'Goodbye'], :to => :spanish) # => ["¡Hola", "Despedida"]
EasyTranslate.translate(['Hello', 'Goodbye'], to: :spanish) # => ["¡Hola", "Despedida"]
```

## API Keys

```ruby
# make google happy - (NOTE: use these anywhere)
EasyTranslate.translate('Hello, world', :to => :es, :key => 'xxx')
EasyTranslate.translate('Hello, world', to: :es, key: 'xxx')

# don't want to set the key on every call? ** Me either! **
EasyTranslate.api_key = 'xxx'
Expand All @@ -67,12 +67,12 @@ EasyTranslate.detect ['Hello World', '我姓譚'] # => ['en', 'zh-CN']

```ruby
# detect language with confidence
EasyTranslate.detect "This is definitely English!", :confidence => true # => { :language => 'en', :confidence => 0.77272725 }
EasyTranslate.detect "This is definitely English!", confidence: true # => { :language => 'en', :confidence => 0.77272725 }
```

```ruby
# detect batch languages with confidence
EasyTranslate.detect ['This is definitely English!', '我姓譚'], :confidence => true # => [{ :language => 'en', :confidence => 0.77272725 }, { :language => 'zh-CN', :confidence => 1.0 }]
EasyTranslate.detect ['This is definitely English!', '我姓譚'], confidence: true # => [{ :language => 'en', :confidence => 0.77272725 }, { :language => 'zh-CN', :confidence => 1.0 }]
```

## Explicitly select translation model (NMT, PBMT)
Expand All @@ -93,9 +93,9 @@ See https://research.googleblog.com/2016/09/a-neural-network-for-machine.html fo
## Google Translate supports HTML (default) and plain text formats

```ruby
EasyTranslate.translate "Las doce en punto", :format => 'text', :to => :en
EasyTranslate.translate "Las doce en punto", format: 'text', to: :en
# => "Twelve o'clock"
EasyTranslate.translate "Las doce <b>en punto</b>", :format => 'html', :to => :en
EasyTranslate.translate "Las doce <b>en punto</b>", format: 'html', to: :en
# => "Twelve <b>o&#39;clock</b>"
```

Expand Down

0 comments on commit 23c05f3

Please sign in to comment.