Coder Social home page Coder Social logo

tr4n5l4te's Introduction

Tr4n5l4te

Version: 0.1.3

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.

Add this line to your application's Gemfile:

gem 'tr4n5l4te'

And then execute:

$ bundle

Or install it yourself as:

$ gem install tr4n5l4te

Usage

In your code:

translator = Tr4n5l4te::Translator.new
english_strings = %w(
  hello
  how are you
)
english_strings.each do |text|
  puts translator.translate(text, :en, :es)
end
# => hola
# => cómo estás

Command Line

To 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 -t

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.

License

The gem is available as open source under the terms of the MIT License.

tr4n5l4te's People

Watchers

James Cloos avatar Jose Luis Chafardet avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.