The code powering m.abunchtell.com https://m.abunchtell.com
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 

29 righe
558 B

  1. # frozen_string_literal: true
  2. module Localized
  3. extend ActiveSupport::Concern
  4. included do
  5. before_action :set_locale
  6. end
  7. private
  8. def set_locale
  9. I18n.locale = default_locale
  10. I18n.locale = current_user.locale if user_signed_in?
  11. rescue I18n::InvalidLocale
  12. I18n.locale = default_locale
  13. end
  14. def default_locale
  15. ENV.fetch('DEFAULT_LOCALE') do
  16. user_supplied_locale || I18n.default_locale
  17. end
  18. end
  19. def user_supplied_locale
  20. http_accept_language.language_region_compatible_from(I18n.available_locales)
  21. end
  22. end