Prev | Current Page 395 | Next

Brad Ediger

"Advanced Rails"


The basic English-only interface is shown in Figures 8-3 through 8-6; the user can
create and view address book entries.
Figure 8-3. Blank state of an empty address book
Rails L10n | 263
Localizing the address book
Now we will localize the address book??™s interface so that the interface elements
appear in the language of the user??™s choice. First we will install the Globalize plugin.
This can be done by any method of your choice (see Chapter 3 for plugin installation
options), but we will use svn export:
$ svn export svn://svn.globalize-rails.org/globalize/trunk vendor/plugins/globalize
Globalize comes with a Rake task to set up the tables. Unfortunately, Globalize
trunk is still broken, and it misidentifies user-created translations as built in. To fix
this, immediately after we create the translation tables, we will change the built_in
column of the globalize_translations table to default to false:
Figure 8-4. Adding a person
264 | Chapter 8: i18n and L10n
$ rake globalize:setup
$ script/console
>> ActiveRecord::Schema.define do
?> change_column_default :globalize_translations, :built_in, false
>> end
Figure 8-5. Viewing a newly created person
Figure 8-6. Viewing all people; one created
Rails L10n | 265
Now, we need to modify the views to use the String#t method, so that the views can
be translated. This can be a tedious process; here is one resulting view:
app/views/people/_form.


Pages:
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407