README.md in babel_i18n-0.0.3 vs README.md in babel_i18n-0.0.4

- old
+ new

@@ -1,11 +1,9 @@ # BabelI18n -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/babel_i18n`. To experiment with that code, run `bin/console` for an interactive prompt. +This Ruby library allows to translate files locale dictionaries and provides methods to translate words and phrases using the Google Translate API -TODO: Delete this and the text above, and describe your gem - ## Installation Add this line to your application's Gemfile: ```ruby @@ -18,22 +16,67 @@ Or install it yourself as: $ gem install babel_i18n +## Google API Key + + This GEM requires a valid Google API key for all requests + + To find your application's API key, do the following: + + 1. Go to the [Google Developers Console](https://console.developers.google.com/). + 2. Select a project, or create a new one. + 3. In the sidebar on the left, expand **APIs & auth**. Next, click **APIs**. Select the **Enabled APIs** link in the API section to see a list of all your enabled APIs. Make sure that the Google Translate API is on the list of enabled APIs. If you have not enabled it, select the API from the list of APIs, then select the **Enable API** button for the API. + 4. In the sidebar on the left, select **Credentials**. + ## Usage -TODO: Write usage instructions here +### Translate file locale dictionary +#### Command line + + $ babel_i18n translate_file en.yml --to pt-BR --key YOUR_GOOGLE_API_KEY + +#### Or set GOOGLE_API_KEY Environment Variable + + $ export GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY + $ babel_i18n translate_file en.yml --to pt-BR + +### Translate words and phrases + +#### Command line + + $ babel_i18n translate_text Hi --from en --to pt-BR --key YOUR_GOOGLE_API_KEY + +#### Or set GOOGLE_API_KEY Environment Variable + + $ export GOOGLE_API_KEY=YOUR_GOOGLE_API_KEY + $ babel_i18n translate_text Hi --to pt-BR + +#### In your ruby application + +```ruby +BabelI18n::Base.new('Hi', ENV['GOOGLE_API_KEY']).from('en').to('pt-BR').translate +=> "Oi" +``` + +#### Detecting language, omitting parameter 'from' + +```ruby +BabelI18n::Base.new('Hi', ENV['GOOGLE_API_KEY']).to('pt-BR').translate +=> "Oi" +``` + ## Development After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). ## Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/babel_i18n. +Bug reports and pull requests are welcome on GitHub at https://github.com/gabrielpedepera/babel_i18n. ## License The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).