Tamim Azizadah
2006-Aug-25 07:53 UTC
Can''t get Globalize to work correctly - please help!
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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Tamim Azizadah
2006-Aug-25 09:52 UTC
Re: Can''t get Globalize to work correctly - please help!
I just found something strange. I changed the following: def product_details begin Locale.set "es-ES" @product = Product.find(params[:id], :conditions => @@active) .... *TO THIS: * def product_details begin Locale.set "es-ES" @product = Product.find(:all, :conditions => "id = #{params[:id]} AND #{@@active}") @product = @product[0] ... And in this case Globalize returns the translated name. But why does it not return it when I use Product.find? Tamim Azizadah wrote:> 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 > > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---