Interior design site
Category: | Industry: Trade & Retail
In this project for a Netherland client in late 2009, one of the major features that we built is a multi-language feature for his existing Rails application, an interior design / product site. We have done multi-language feature for several Rails applications in the past, using gettext, gibberish, gibberish_db, etc, but here we use Globalize2 plugin and Rails built-in internationalization I18n.
We used I18n for all our static contents, it’s a piece of cake. And all you need to do is to update that ymls files. For dynamic contents, we use Globalize2.
Here comes the fun part. Because you are most likely be working on an existing application, the bulk of the work is not making a nice back-end for multi-language objects, but it’s making sure the Rails application works correctly after we implement multi-language. It’s especially true when the application doesn’t have a complete test (rspec) suite.
Some things worth noting:
- All occurrences of find_by_name will no longer work correctly. So grep that and modify accordingly
- Basically all queries that use ‘name’ field, either on the select clause or condition clause, will also no longer work correctly
- All routes that need locale path should also be added /locale/ to it
- Javascript methods within a .js file that calls a Rails action and needs ‘locale’. Simply make a global Javascript variable for the locale and use that when necessary within the .js file
-
Javascript method that uses hard-coded words. Eg.
this.value = ‘Beware’. Either we refactor it completely since it’s most likely we can do it another cleaner way, or we have to pull out that Javascript method from .js file to rhtml