svenfuchs/i18n — Issue #119: include "include" method to all Backends not just Simple backend
Author: sartip
Created: 2011-11-09 06:17:25+00:00
State: open

Hi, only the Simple backend can include other Extensions like i18n::Backend::Memoize and I think is in the following line:

```ruby
(class << self; self; end).class_eval { public :include }
```

Is it possible to have that functionality on all the Backends, because I had to create an external module in /lib with the following to extend the Memoize functionality to KeyValue.

```ruby
module Translator

DATABASES = {
"development" => 2,
"test" => 1,
"production" => 0
}

def self.store
@store ||= Redis.new(:db => DATABASES[Rails.env.to_s])
end

class Backend < I18n::Backend::KeyValue
include I18n::Backend::Memoize

def initialize
super(Translator.store, false)
end
end
end
```

and then I had to create a file in /config/initializers/i18n_backends with the following

```ruby
require "translator"
I18n.backend = I18n::Backend::Chain.new(Translator::Backend.new, I18n.backend) # Translator (redis + memoize) fallback to YML file
```
Most of the code was Excerpted from "Crafting Rails Applications"