-
Notifications
You must be signed in to change notification settings - Fork 329
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
Can't use I18n for confirmation messages #649
Comments
If you put I18n.t in active_scaffold block, is evaluated when app starts, so language doesn't change. You must set a symbol there, then active_scaffold will translate it, it will look for symbol under active_scaffold scope. ActiveScaffold::Registry.cache is caching translation for current action, because when you have a long list, with many rows with same actions, it's faster to translate one and then use interpolation to replace %{label}, than translate many times. |
It works like a charm! Thank you! I will write down what I did, in case other people are interested in the topic:
I suppose there's no chance for Proc support, right? |
I could accept a patch supporting proc, but I don't know if it would be any improvement |
How to replicate:
Expected behaviour: The confirmation message should be translated in
ro
oren
, depdending on the subdomain.Actual behaviour: The confirmation message is translated in the default language.
Why is this happening?
set_locale
method runs afteractive_scaffold
is configured.How to fix it?
Option 1: Allow
confirm
parameter to be either a string or a Proc. Then this code should work:Option 2: Perhaps there is some other way of sending that confirmation message. But I don't understand what this line does:
ActiveScaffold::Registry.cache(:translations, @confirm) { as_(@confirm) } % {label: label}
Conclusion: I would choose Option 1, since even if there is already support for Option 2, Option 1 offers more flexibility.
The text was updated successfully, but these errors were encountered: