sinatra and i18n gem

To make work i18n gem and sinatra in your add:

# include the gem, otherwise add it to your bundle file if you manage gems with bundler.
require 'i18n'

# assuming that you have your locale files (.yml) in ./config/locales directory
I18n.load_path += Dir[File.join(File.dirname(__FILE__), 'config', 'locales', '*.yml').to_s]

Then somewhere in you app add the t() helper:

helpers do
  def t(*args)

Happy internationalizing!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>