Home

Awesome

wtf_lang TravisCI

Can't stop dreaming about an easy language detector? Just use wtf_lang!

Install

gem install wtf_lang

Usage

require 'wtf_lang'
  
WtfLang::API.key = "your_api_key" # you can get it here http://detectlanguage.com/

"ruby is so awesome!".lang # => "en"
"ruby is so awesome!".full_lang # => "ENGLISH"

# numeric value between 0-1.0 that represents 
# the confidence level in the language code for the given text.
"ruby is so awesome!".lang_confidence # => ["en", 0.15502742]

"ruby is so awesome!".en? # => true
"ruby is so awesome!".english? # => true

If you want to cache results to make less requests to google API, use variables

text = "ruby is so awesome!"
text.lang #=> "en"
text.full_lang #=> "english"

It works with symbols too!

:"ruby is so awesome!".lang # => "en"

Contributing to wtf_lang

Authors

Contributors

Vasiliy Ermolovich<br/>

Copyright

Copyright (c) 2012 nashby. See LICENSE.txt for further details.