One of the previous articles was covering I18n in Rails. We talked about storing and fetching translations, localizing the app and other useful stuff. What we have not discussed, however, are the different ways to manage locale across requests.
By default, Rails is going to use locale set in the I18n.default_locale
(which is :en
or any other value you define in the configuration) or the value from I18n.locale
if it was explicitly defined. Of course, if an application supports multiple languages, its users need a way to change locale and their choice should be persisted. Therefore, in this article we will explore the following solutions:
One of the previous articles was covering I18n in Rails. We talked about storing and fetching translations, localizing the app and other useful stuff. What we have not discussed, however, are the different ways to manage locale across requests.
By default, Rails is going to use locale set in the I18n.default_locale (which is :en or any other value you define in the configuration) or the value from I18n.locale if it was explicitly defined. Of course, if an application supports multiple languages, its users need a way to change locale and their choice should be persisted. Therefore, in this article we will explore the following solutions: […]