Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/midwire/tr4n5l4te
Use Google Translate without an API key.
https://github.com/midwire/tr4n5l4te
google google-translate i18n internationalization languages translate translator yaml
Last synced: about 2 months ago
JSON representation
Use Google Translate without an API key.
- Host: GitHub
- URL: https://github.com/midwire/tr4n5l4te
- Owner: midwire
- License: mit
- Created: 2016-03-15T01:26:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-06T18:21:08.000Z (12 months ago)
- Last Synced: 2024-12-05T18:11:55.179Z (about 2 months ago)
- Topics: google, google-translate, i18n, internationalization, languages, translate, translator, yaml
- Language: Ruby
- Size: 97.7 KB
- Stars: 39
- Watchers: 2
- Forks: 14
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Tr4n5l4te
**Version: 0.1.17**
Use Google Translate without an API key.
Like me, maybe you've found that Google makes it a pain to work with their API. Tr4n5l4te gets around all that.
## Installation
First, install [PhantomJS](http://phantomjs.org/).
Add this line to your application's Gemfile:
```ruby
gem 'tr4n5l4te'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install tr4n5l4te
## Usage
In your code:
```ruby
translator = Tr4n5l4te::Translator.new
english_strings = [
'hello',
'how are you'
]
english_strings.each do |text|
puts translator.translate(text, :en, :es)
end
# => hola
# => cómo estás
```### Command Line
➤ ./exe/translate -h
Options:
-y, --yaml-file= A YAML locale file - filename determines source language 'en.yml' - English
-l, --lang= Destination language
-i, --list List known languages
-s, --sleep-time= Sleep time (default: 2)
-t, --timeout= Poltergeist timeout option (default: 30)
-v, --verbose Be verbose with output
-h, --help Show this messageTo translate a YAML file:
$ ./exe/translate -y /path/to/yml/file -l "destination-language"
The translator will sleep for 2 seconds, by default, between each string translation. You can override that by passing in the amount of time, in seconds, you want it to sleep:
$ ./exe/translate -y config/locales/en.yml -l French -s 3
Warning: If you pass in '0' and translate a large file, it is very likely that Google will ban your IP address.
To list all known languages
$ ./exe/translate --list
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
### Specs
The specs are sprinkled with integration tests which will actually go out and hit the live web. To run them:
$ INTEGRATION=1 rake spec
Please be kind or Google is likely to ban your IP address.
#### Spec Coverage
$ INTEGRATION=1 COVERAGE=1 rake spec
$ open coverage/index.html # if you are on OSX## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/midwire/tr4n5l4te.
### Contributors
Thanks to all of those who contribute!
* @kirylpl - Fixed phantomjs selector, migration to Optimist gem
* @gahia - Fixed phantomjs SSL handshake problem, Look for and report non-neutral gender translations. Now accepts the "male" translation by default and warns that there are alternatives, Don't fail if a translation is not found but instead show a warning message and continue.## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).