Skip to content

What is the suggested way to implement locale switching? #318

Discussion options

You must be logged in to vote

I updated to 1.5.3 and have adjusted the PreviewController as follows and everything is working great! Thanks so much! 👏

class PreviewController < ViewComponentsController
  around_action :switch_locale

  def switch_locale(&action)
    locale = params[:lookbook][:display][:lang] || I18n.default_locale
    I18n.with_locale(locale, &action)
  end
end

Replies: 5 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@henrik
Comment options

@Spone
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@emaklita
Comment options

@halo
Comment options

Answer selected by Spone
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants