Project

mi_hermano

0.0
No commit activity in last 3 years
No release in over 3 years
Mi Hermano translates strings using the Google Spreadsheets API (since the Translate API is no longer available).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Installation

Installing the gem is fairly easy. In your Gemfile:

gem "mi_hermano"

Usage

To use Mi Hermano, you’ll have to create an empty Google Spreadsheet and use its key (found in its URL) when calling setup:

MiHermano.setup({
  :username => "me@gmail.com",
  :password => "my_secret_password",
  :spreadsheet_key => "nxBFQGKpnzObbVyyIkGtajktMFAhDRGFiEdM66Vacmjz",
})

After that, you can use translate to translate strings:

MiHermano.translate("Hello, my friends!", :en, :fr) # => "Bonjour, mes amis!"

Options

You can define a default source language and a default target language when initializing Mi Hermano. These settings will be used if you do not specify a source or a target when calling translate.

MiHermano.setup({
  :username => "me@gmail.com",
  :password => "my_secret_password",
  :spreadsheet_key => "nxBFQGKpnzObbVyyIkGtajktMFAhDRGFiEdM66Vacmjz",
  :default_source => :en,
  :default_target => :es
})

MiHermano.translate("Hello, my friends!") # => "Hola, mis amigos!"

Known issues

Since we rely on a Google Spreadsheet function, translating a string is slow. It’s recommended that you use it background jobs.

License

Mi Hermano is © 2012 Rémi Prévost and may be freely distributed under the MIT license. See the LICENSE file.

Original demo code by Mahmoud Khaled.