I'm trying to implement fallbacks for translated attributes using Globalize3 and I18n fallbacks. To get fallbacks up and running, I added to my environment.rb file:
#support for locale fallbacks
require "i18n/backend/fallbacks"
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
And then in my config file:
config.i18n.fallbacks = {'en-US' => 'zh-CN', 'zh-CN' => 'en-US'}
Now I have an app running where, if a field is not translated in the 'en-US' locale, it'll fall back on the 'zh-CN' locale, and vice versa.
However, this means that the fallback also occurs on forms on the site. This is undesired behaviour for two reasons:
- Users might think that this means that this locale has this value for the input being seen (whereas it was inherited from the fallback locale).
- Saving a form with these inherited values actually saves the translations as the current locale's values - so then all of a sudden you've got data on both locales, but the user may not know this (or know why).
I'd like to disable the fallbacks while on edit pages / in forms showing objects with translated attributes. Is there any way to do this?
I'm using versions of Globalize3 and I18n from svenfuchs https://github.com/svenfuchs/globalize3