I recently installed and I believe properly configured the Globalize
plugin. However, it seems to work in one view and not another.
I have two product views - one for a listing of multiple products and
one for a listing of a single product’s details. My base language is set
in environment.rb as:
include Globalize
Locale.set_base_language ‘en-US’
Locale.set ‘en-US’
I have a controller called product. Here’s the index method snippet (I’m
setting the Locale explicitly to test it out):
def index
Locale.set “es-ES”
@products = Product.find(:all, :order => “date_added”, :conditions
=> @@active
…
My product model looks like:
class Product < ActiveRecord::Base
…
translates :name, :description
…
In this case, Globalize works correctly and displays the Spanish names
correctly as seen in screenshot:
http://www.tmpforums.com/images/tam/listings.jpg
The product_details method looks like:
def product_details
begin
Locale.set “es-ES”
@product = Product.find(params[:id], :conditions => @@active)
…
However, no matter what I do, it always keeps displaying the English
name in this view:
http://www.tmpforums.com/images/tam/details.jpg
I took a look at the globalize_translations table and to the best of my
knowledge it looks fine:
http://www.tmpforums.com/images/table.jpg
I’ve checked the view template and I’m not changing the locale in the
view at all. I’ve even tried setting the locale in the view template to
“es-ES” and it STILL displays it as English. I have no idea what I’m
doing wrong, but I suspect it’s something subtle I’m missing. Would
really appreciate any help with this. Thanks!
Best Regards,
Tamim