-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Column fallback to original value every time there's no translation present #645
Comments
OK easiest fix for A) is as simple as: column_fallback ->(locale) {
I18n.available_locales
} this is simple enough that might not merit a full blown feature. closing it now |
I am so dumb, that effectively disables Mobility all together 🙈 Going back to square one, wondering if there's a way to check wether the translation exists or not within that Proc 🤔 |
@benoror I'm not sure I understand your question, but I'm pretty sure that lambda needs to return a boolean. A truthy result would tell Mobility to go ahead and fallback to the original column. For example, I have a use case where I want Mobility to always fallback for English locales, regardless of region, so here's what I set: # NOTE: Prior to Mobility, all table column values have been in English, without
# regional differences. We want the Mobility to ignore handling 'en' content as
# translations and instead read/write to the original columns.
column_fallback -> (locale) { locale.to_s.starts_with?('en') } |
I stumbled upon ColumnFallback (#512 (comment)) which mostly meets our needs, except for one small tangent:
Expected Behavior
TL;DR; Wondering if there's a clean way to default to column value every time there's a missing translation, including for
I18n.default_locale
.Full Context:
At my project we currently have a huge set of tables with content that hasn't been translated, we would like to have a
default_locale
and other available languages but we're having second thoughts of the redundancy of copying over / regenerating the very same content all over again to the translation tables, hence we would like to default to the original value always, unless there's an explicit translation present, independently of the locale (as said before, evendefault_locale
)Actual Behavior
It always fallbacks to looking at the translated value except for
default_locale
Possible Fix
A) Workaround
Possibly using a
Proc
for the plugin value with custom logic?B) Code feature (if ever gets contemplated):
In the original implementation I suppose the change would be somewhere around here:
mobility/lib/mobility/plugins/active_record/column_fallback.rb
Line 29 in 7cbca64
...to always call
super
?I haven't dig into the newer implementation tho
The text was updated successfully, but these errors were encountered: