0
votes

We user I18n gem for translations in our application.

With the translations, it is expected to fallback to default_locale which is :en, if the translation is not available in corresponding locale.

Class Article
  ...
  translates :title
  ...
end

While accessing as a french user,

article.title => title in english 

but 

article.attributes(:title) => nil

I guess attributes picks directly from the active_record object (french translation) and since it is not available, it returns nil. Is there a way to make attributes as well fallback to default locale if translation is not available in corresponding locale.

1

1 Answers

1
votes

You can use I18n.fallbacks:

I18n.default_locale = :"en-US" 
I18n.fallbacks[:fr] # => [:fr, :"en-US", :en]

Take a look how to use Fallbacks on I18n Wiki