Sergio Xalambrí

Force a locale in Rails I18n from the params

If you want to change the local used for internationalization a single time from the params of the URL you need to use the with_locale method.

message = I18n.with_local params[:locale] do

Now your message will be in the locale received from the params of the URL, if it was not defined it would fallback to the default locale configured in your application.