Switch off I18n/Globalize3 fallbacks per Rails model basis

284 Views Asked by At

Is it possible to switch off I18n/Globalize3 fallbacks per Rails model basis? I.e. some models use fallback, some don't.

1

There are 1 best solutions below

0
On

Yes, it is possible by overriding the globalize_fallbacks method in your model. Take for example a post model with translated title and content:

class Post < ActiveRecord::Base

  translates :title, :content

  # Disable fallbacks for this model
  def globalize_fallbacks(locale)
    [locale]
  end

end

You simply specify that the requested locale can only fallback to itself, no matter what is defined in your global configuration.