Forum: Rails I18n Installation workaround for i18n gem 0.3.5 on rails 2.3.4 not working

Posted by ginger72 (Guest)
on 2010-03-05 22:06
(Received via mailing list)
I am using the installation description on

http://github.com/svenfuchs/i18n

where I have downloaded the gem into vendor/plugins/i18 and added the
following lines, as suggested, to an intitializer (i18n.rb):

def reload_i18n!
  raise "Move to i18n version 0.2.0 or greater" if Rails.version >
"2.3.4"
  $:.grep(/i18n/).each { |path| $:.delete(path) }
  I18n::Backend.send :remove_const, "Simple"
  $: << Rails.root.join('vendor', 'plugins', 'i18n', 'lib').to_s
end
reload_i18n!

Then in the console I18n.t :hello would returns "Translation missing"

Unfortunately, due to other incompatibilities (Unicorn), I don't want
to upgrade to rails 2.3.5.

P.S. Working on a plugin that offers a migration path from Globalize1
apps to I18n+Globalize2
Posted by ginger72 (Guest)
on 2010-03-05 22:33
(Received via mailing list)
Below I copied the installation instructions from 
http://github.com/svenfuchs/i18n

It does not work with either version of the i18n gem.

Any help to get the i18n gem work on rails 2.3.4 is highly
appreciated.

Kind regards,

Juergen


---
Installation on Rails < 2.3.5 (deprecated)
Up to version 2.3.4 Rails will not accept i18n gems > 0.1.3. There is
an unpacked
gem inside of active_support/lib/vendor which gets loaded unless gem
‘i18n’, ‘~> 0.1.3’.
This requirement is relaxed in 6da03653

The new i18n gem can be loaded from vendor/plugins like this:

def reload_i18n! raise “Move to i18n version 0.2.0 or greater” if
Rails.version > “2.3.4” $:.grep(/i18n/).each { |path|
$:.delete(path) } I18n::Backend.send :remove_const, “Simple” $: <<
Rails.root.join(‘vendor’, ‘plugins’, ‘i18n’, ‘lib’).to_s end
Then you can `reload_i18n!` inside an i18n initializer.
---
Posted by Sven Fuchs (Guest)
on 2010-03-06 00:57
(Received via mailing list)
Juergen,

I'm not sure how this has made it into the readme, but ... it might be 
easier for you to just patch Rails here. You could just freeze Rails to 
vendor/rails and apply some patch that changes these lines:

http://github.com/rails/rails/blob/v2.3.4/activesu...

to match these:

http://github.com/rails/rails/blob/v2.3.5/activesu...

After that Rails should pick up whatever I18n gem version you've 
installed as long as it's >= 0.1.3
Posted by Jürgen Feßlmeier (Guest)
on 2010-03-06 19:21
(Received via mailing list)
Hi Sven,

thanks for your quick reply. That is an option I had considered, but
was way too overconfident that the published code must have worked.

Anyway, all is good now, thanks again.

Kind regards,
Juergen
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.