jeudi 13 novembre 2014

Globalize2, Disable fallback for a specific field


Vote count:

0




I use globalize2, on a Rails2 project, to handle internationalization. I have a Page model with title, description, and so on.


I use a field called "url_redirect" that's used to redirect the page to another URL, based on the language I'm currently using. For eg:



Page.find(1)

title description locale url_redirect
test .... it
my_test .... en www.google.it


On the controller side I check the presence of url_redirect and make a simple redirect_to unless blank. Unfortunately, I use the globalize2 fallbacks... so even though I'm on the italian site, the field url_redirect returns www.google.it.. These are the fallbacks:



require "i18n/backend/fallbacks"
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
module Globalize

class << self

def fallbacks(locale = self.locale)
case locale
when :it then [:it, :en, :es, :fr]
when :en then [:en, :it, :es, :fr]
when :es then [:es, :en, :it, :fr]
when :fr then [:fr, :it, :en, :es]
end
end

end
end


How can I avoid fallback only for that specific field? I would like something like this How to avoid Globalize3 from returning fallback translations for an attribute into a specific context? for globalize2.


Thanks in advance.



asked 1 min ago







Globalize2, Disable fallback for a specific field

Aucun commentaire:

Enregistrer un commentaire