If you follow the I18N Rails Guide, all generated links contain the locale parameter (localhost/en/about, localhost/fr/about). This is because we use the method defaul
defaul
Ok I understand much better. Indeed, you almost did it.
You just need a very useful operator in Ruby: ||
||
If the first value exists, it's used, otherwise the second argument is taken into account.
def set_locale I18n.locale = params[:locale] || :en end