Click To Globalize: Ready for Rails 2.1!
Click to Globalize is ready for Rails 2.1!
I spent a lot of time to make this release the best of ever! I know that a lot of time has passed since the latest Rails major release, and I apologize for this.
The official Globalize it seems dead, but the great work of Nate Clark (aka heythisisnate) has made it compatible with Rails 2.1. Thanks Nate!
The Rails Edge now includes a basic support for i18n!
What's Changed?
The first big change is about the configuration, past versions has cluttered a bit your ApplicationController, I know, but now Click uses a YAML file configuration file for locales.
1 locales: 2 english: en-US 3 italian: it-IT 4 5 # optional 6 default: :english 7 8 # optional 9 formatting: textile
As you can see, it's more readable than put an Hash inside your main controller, and it also take the advantage to separate configuration from logic.
The second change regards the default language, you can use the above file to declare it, or use the Globalize syntax (Globalize::Locale.set_base_language('en-US')), but you have to choose a locale before the app starts.
This because Click needs a secure fallback mechanism, if no active Locale was set, it's always guarantees your application to work.
The third feature is about formatting: you can always choose between textile and markdown without editing ApplicationController, but using the same configuration file.
I removed the deprecated class method ApplicationController#globalize? in favor of the instance one.
This means you can use it to turn on/off Click to Globalize, just returning a boolean value:
1 ApplicationController < ActionController::Base 2 protected 3 def globalize? 4 current_user.admin? 5 end 6 end
This version also includes tiny fixes, refactoring and cleanup.
You may wish to learn a bit about Click to Globalize, so I encourage you to visit the official page.
I hope you enjoy your i18n on Rails!
advertising





Posted by jerome lefeuvre on 2008-07-30 17:48:10 UTC (permalink)
Hi Lucas,
I try to install your plugins but I have a problem.
When I restart the server, I have this error :
/Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails/plugin/loader.rb:145:in `ensure_all_registered_plugins_are_loaded!': Could not locate the following plugins: action_mailer_layouts, action_mailer_tls, acts_as_list, acts_as_state_machine, acts_as_textiled, attribute_fu, calendar_date_select, debug-view-helper, exception_notification, gems, globalize, label_helpers, lightbox, popup, rdialog, redbox, restful-authentication, role_requirement, sortable_column_headers, static_actions, uploadcolumn, validates_date_time, validates_email_veracity_of, and validatesdatetime (LoadError)
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails/plugin/loader.rb:36:in `load_plugins'
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/initializer.rb:283:in `load_plugins'
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/initializer.rb:138:in `process'
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `send'
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `run'
from /Users/james/MyProjects/gitProject/venteJerome/vendor/plugins/click-to-globalize/init.rb:7:in `evaluate_init_rb'
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/rails/plugin.rb:95:in `evaluate_init_rb'
from /Library/Ruby/Gems/1.8/gems/activesupport-2.1.0/lib/active_support/core_ext/kernel/reporting.rb:11:in `silence_warnings'
... 36 levels...
from /Library/Ruby/Gems/1.8/gems/rails-2.1.0/lib/commands/server.rb:39
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:27:in `require'
from script/server:3
can you help me ?
I use the rails 2.1
Thanks