-
Notifications
You must be signed in to change notification settings - Fork 92
Description
I am using fallbacks. One of my locales is "en-GB", and I think the I18n fallbacks defaults to "en" as a fallback.
However this bug exists also without fallbacks, it's just easier to explain this kind of case.
During validations, translation_for will be called:
https://github.com/shioyama/mobility/blob/master/lib/mobility/backends/active_record/table.rb#L291
It will build a translation for this "en" locale, even though this is not necessary.
Additionally I have a presence validation on the Translation class (friendly_id slug). Therefore due to this, I cannot save my models, because fallbacks is generating empty translations on the model. Even if I did not have that validation, it would create unwanted empty translations in the DB upon saving.
Temporarily I fixed it by patching generate_fallbacks to exclude the 'en' locale, but that only partly fixes it - only for models which have translations for all locales I use.
Possible solution would be for the reader to not call build, and only writer to call build. I can whiff up a PR if you think that solution is the best we can do.