Plugins - gibberish_rails

StarAdd to favorites

Please see the full description in the README
Excerpt from the README:
This plugin:
1. Adds the method Gibberish.supported? to Gibberish::Localize to use it‘s map of languages to determine if a locale is supported. For example Gibberish.supported?(:en) returns true. It can be passed a string or a symbol. The previous Gibberish API returned an array of languages, but it was just so much more efficient to use the hash Gibberish had already built I added my method to the api. My Helper (6) below needs this method.
2. Redefines the Rails core method ActionView::Helpers::ActiveRecordHelper.error_message_for so messages are translates with Gibberish.
3. Overrides default error messages in ActiveReccord:Errors to include a Gibberish key. The key is blank (i.e. the entire string) so they can be automatically re-Gibberished in step 4. (next).
4. The method “add” in ActiveRecord::Errors has been overridden retranslate messages during the around filter. This become necessary because Rails 2.0.2 caches parts of messages at the class load time.
5. Redefines the method Validations.ClassMethods.validates_length_of to retranslate the messages it caches at class load up time.
6. Adds a helper method “GibberishRails.best_guess_locale” that can be used in an around filter to determine the “best guess” locale the application should be using. The highest priority is given to a parameter, followed by HTTP_ACCEPT_LANGUAGE, and finally the Gibberish default. Also, if the user wants es-mx and we support es, it will return a local of es. Here is an example usage that uses the session to cache the locale so if you are using the HTTP_ACCEPT_LANGUAGE (instead of RESTful routes), it will cache in the session instead of parsing headers every time:


   class ApplicationController < ActionController::Base
     # ...
     around_filter :use_best_guess_locale
     # ...
     # Set's the best guess language Giberish's around filter
     def use_best_guess_locale
       session[:locale] = GibberishRails.best_guess_locale(params[:locale], request.env['HTTP_ACCEPT_LANGUAGE']) if ( ! session[:locale] || params[:locale] || RAILS_ENV == 'development' )

       Gibberish.use_language(session[:locale]) {
         yield
       }
     end
   end

Rama McIntosh

http://myutil.com/2008/1/22/gibberish_rails-a-ruby-on-rails-plugin-to-translate-rails-with-gibberish

http://svn.myutil.com/projects/plugins/gibberish_rails/

Rails' (MIT)

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Internationalization

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?