27th marzo 2009 by WebAir

Upgrade Rails to 2.3.2 with Gettext support
Ruby-GetText-Package-2.0.0 finalmente è compatibile con rails-2.3.2. (la versione rails-2.3.1 e precedenti non funzionano con gettext-2.0.0)
In questa micro guida illustriamo brevemente come upgradare rails-2.x.x a rails-2.3.2 con gettext.
Installa rails-2.3.2 o successivo (Richiesto)
$ gem install rails
Installiamo le nuove le gems (Richiesto)
(su) $ gem uninstall gettext # for gettext-1.93.0 $ gem install gettext_rails Successfully installed locale-2.0.0 Successfully installed gettext-2.0.0 Successfully installed gettext_activerecord-2.0.0 Successfully installed locale_rails-2.0.0 Successfully installed gettext_rails-2.0.0 5 gems installed
Aggiorniamo l’applicazione rails
config/environment.rb (Richiesto)
Rails::Initializer.run do |config| : : config.gem "locale_rails" config.gem "gettext_activerecord" config.gem "gettext_rails" end
app/controller/app/controllers/application_controller.rb (Richiesto)
Rinominiamo application.rb in application_controller.rb. init_gettext era presente anche nelle vecchie versioni di gettext.
Rakefile (Raccomandato)
Creiamo un file con i comandi di base per gettext in lib/tasks (sostituiamo clrk con il nome della nostra applicazione).
# desc "gettext base command"
namespace :gettext do
desc "Create mo-files for L10n"
task :makemo do
require 'gettext_rails/tools'
GetText.create_mofiles
end
desc "Update pot/po files to match new version."
task :updatepo do
require 'gettext_rails/tools'
GetText.update_pofiles("clerk", Dir.glob("{app,lib}/**/*.{rb,erb}"),
"clerk 1.0.0")
end
end
La nostra applicazione è pronta a essere eseguita!
P.S. Se utilizzate RedCloth dovete aggiungere questa riga in enviroment.rb:
Rails::Initializer.run do |config| : : config.gem "RedCloth", :lib => "redcloth", :source => "http://code.whytheluckystiff.net" end
E poi eseguire questi 2 comandi
(su) $ rake gems:unpack $ rake gems:build
Per altri problemi controllate su http://sudothinker.com/2009%2F3%2F2%2Frails-2-3-upgrade-problems-and-solutions potrebbe esserci la soluzione che cercate!









i would recommend to simply switch to fast_gettext
http://github.com/grosser/fast_gettext
, a simpler/cleaner/faster/efficient solution that will not break when any part of rails is updated, since it cooperates with I18n (through gettext_i18n_rails plugin).
Yes it’s an option, but only if you use only base functionality, that gem doesn’t seems to support full gettext api, for what i can see on the project site
I strongly advise to run also rake updatepo because the new parser stops with an error on things like
var = “‘#{date.strftime(”%Y-%m-%d 00:00:00″)}’”
which must be turned into
var = %(’#{date.strftime(”%Y-%m-%d 00:00:00″)}’)
Apparently it doesn’t like the string inside a string thing.
@grosser: does fast_gettext collects and manages _(”strings”) in the source code like gettext does? (rake updatepo/makemo)
yep, np_ and ns_ are missing, since so far noone needed them…
I’ll try it in my next project
hi is there a neat way to uninstall rails 2.3.2 and go back to 2.2.2 plz help out the new rails isnt working for me and is too complicated
you can simply type gem install rails -v=2.2.2 to instal rails 2.2.2, and uninstall with same gem uninstall rails -v=2.3.2