You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
TL;DR: the components updated with Turbo Streams in my Rails app always use the default locale instead of the currently set locale.
I have a Rails application with multiple engines. I'm implementing the possibility of switching between two languages, but all the HTML rendered via Turbo Stream doesn't respect the locale and it always uses the default locale for translations. I couldn't find anything in the documentation of Turbo Streams about dealing with internationalisation.
Currently I change the locale following the indications in the Rails docs, with an around_action callback to switch_locale:
I render parts of the HTML calling broadcast_render_to(...) from a controller or a model. For example, the following piece of code is an after_save callback por my PersonalData model. When the model gets updated, it updates the display component, a small box showing a summary of the user's personal data:
My intuition is that I can somehow have a custom controller to execute Turbo Stream actions which also includes the around_action :switch_locale callback. However, I cannot find any documentation or code that would allow me to do that.
The text was updated successfully, but these errors were encountered:
TL;DR: the components updated with Turbo Streams in my Rails app always use the default locale instead of the currently set locale.
I have a Rails application with multiple engines. I'm implementing the possibility of switching between two languages, but all the HTML rendered via Turbo Stream doesn't respect the locale and it always uses the default locale for translations. I couldn't find anything in the documentation of Turbo Streams about dealing with internationalisation.
Currently I change the locale following the indications in the Rails docs, with an around_action callback to switch_locale:
I render parts of the HTML calling broadcast_render_to(...) from a controller or a model. For example, the following piece of code is an after_save callback por my PersonalData model. When the model gets updated, it updates the display component, a small box showing a summary of the user's personal data:
And the partial looks like this:
My intuition is that I can somehow have a custom controller to execute Turbo Stream actions which also includes the around_action :switch_locale callback. However, I cannot find any documentation or code that would allow me to do that.
The text was updated successfully, but these errors were encountered: