Upgrade to Pro — share decks privately, control downloads, hide ads and more …

I18n Alchemy

I18n Alchemy

Lightning Talk por Lucas Mazza, na RubyConf Brasil 2012.

Plataformatec

August 30, 2012
Tweet

More Decks by Plataformatec

Other Decks in Programming

Transcript

  1. Rails + i18n l(@event.starts_at, :format => :short) # '30 de

    Agosto' number_with_precision(1200.3) # '1,200.30'
  2. I18n.with_locale :pt do @event.localized.starts_at = '30/08/2012' @event.starts_at # => Date.new(2012,

    08, 30) @event.localized.starts_at # => '30/08/2012' @event.localized.price = '150,00' @event.localized.starts_at = 3.days.ago @event.save! end I18nAlchemy
  3. I18nAlchemy • Configurações através do i18n • Não é dependente

    do ActiveRecord • Escreva os seus próprios parsers!
  4. module MyParser def self.parse(value) # ... end def self.localize(value) #

    ... end end class Product < ActiveRecord::Base include I18n::Alchemy localize :total, :using => MyParser end