Localization Reference

How it Works

ActiveScaffold facilitates localization by using the Object#as_() method:

<h4><%= as_('Are you sure?') -%></h4>

In the config block ActiveScaffold delays localization until after the session is known, so that you have the chance to know what the target locale should be. Assign the value to the config element:

active_scaffold :event do |config|
  config.columns[:address].label = 'Mailing Address'
end

and ActiveScaffold will call the Object#as_() method later.

How to Localize ActiveScaffold

Choose a localization plugin or gem. The Ruby on Rails website maintains a nice plugin comparison page of localization options. The Globalize plugin and the Gettext gem appear to be the most widely adopted options.

Then override Object#as_() and redirect control to the plugin or gem:

def as_(*args)
  # place custom localization handling here like
  _(*args)
end

Another Option

At one time ActiveScaffold did more than just facilitate localization. When it was decided to remove that code from core, it was captured in the ActiveScaffoldLocalize plugin. This plugin localizes all of the ActiveScaffold strings. It also demonstrates a very simple mechanism for localizing your application.

Bonus Localization

ActiveScaffold will also use the DATE_FORMATS[:default] string for dates and times, if present. More information can be found on the Rails Wiki.