Home arrow Ruby-on-Rails arrow Page 2 - Going Global with Multiple Language Support

Going Global with Multiple Language Support

In this second part of a four-part article series on adding support for multiple languages to a Ruby-on-Rails ecomerce application, you will learn how to use Globalize to add this important capability. This article is excerpted from chapter 10 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
June 30, 2010
  1. · Going Global with Multiple Language Support
  2. · Setting Up Globalize
  3. · Implementing the Change Locale User Story
  4. · Implementing the Translation User Stories

print this article

Going Global with Multiple Language Support - Setting Up Globalize
(Page 2 of 4 )

As previously mentioned, Globalize uses three database tables. After you’ve installed Globalize, as described earlier, run the following command to update your database schema and import the data:

$ rake globalize:setup

The command can take a minute or two to run, as it inserts a lot of data.

Next, you need to update the application’s environment configuration to include Globalize. This will initialize Globalize at startup. You should also set the base language and the default locale for your application in the same configuration file. To do all this, add the following code to the end of config/environment.rb :

# globalize
include Globalize
Locale.set_base_language 'en-US' DEFAULT_LOCALE = 'en-US'

The default locale is a separate setting, since it does not necessarily need to be the same as the base language. We are including Globalize in the default namespace with the include Globalize call, so that we can use Locale.set instead of Globalize::Locale.set .

Implementing the User Stories

With Globalize set up, we can now start localizing the Emporium application. But first, we’ll change the base controller so that users can change the locale.

Note  We won’t be following TDD very strictly in this chapter, as we want to concentrate on showing you how to use the Globalize plugin.

blog comments powered by Disqus

- Ruby-on-Rails Faces Second Security Flaw in ...
- Ruby 2.0 Prepped for February 2013 Release
- Why LinkedIn Switched from Ruby on Rails
- Adding Style with Action Pack
- Handling HTML in Templates with Action Pack
- Filters, Controllers and Helpers in Action P...
- Action Pack and Controller Filters
- Action Pack Categories and Events
- Logging Out, Events and Templates with Actio...
- Action Pack Sessions and Architecture
- More on Action Pack Partial Templates
- Action Pack Partial Templates
- Displaying Error Messages with the Action Pa...
- Action Pack Request Parameters
- Creating an Action Pack Registration Form

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials