I'm about to start adding I18n support for a Rails app I'm currently working on. In the past I have set the locale value from the URL. I just was wondering how bad practice it'd be to persist the locale?
So instead of something like this:
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || I18n.default_locale
end
Do something like
before_filter :set_locale
def set_locale
I18n.locale = current_user.try(:locale) || I18n.default_locale
end
It looks like FB persists the locale, what are the trade-offs of this schema? how might this affect SEO stuff?
Thanks!
I've faced these issues and ended up using this strategy:
If locale is not present in URL, try (in order):
Hope that helps; let me know if you'd like any points elaborated on.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With