rack-contrib
rack-contrib copied to clipboard
"En" is not a valid locale (I18n::InvalidLocale)
My rails app threw this recently when the HuaweiCrawler sent a request with http header Accept-Language: English. It looks like an issue with the capital E in En.
I18n::InvalidLocale: "En" is not a valid locale (I18n::InvalidLocale)
raise I18n::InvalidLocale.new(locale) if !locale_available?(locale)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
from i18n.rb:382:in 'enforce_available_locales!'
from i18n/config.rb:15:in 'locale='
from i18n.rb:75:in 'locale='
from rack/contrib/locale.rb:20:in 'call'
from rack/tempfile_reaper.rb:20:in 'call'
from rack/etag.rb:29:in 'call'
from rack/conditional_get.rb:31:in 'call'
from rack/head.rb:15:in 'call'
from action_dispatch/http/permissions_policy.rb:38:in 'call'
from action_dispatch/http/content_security_policy.rb:38:in 'call'
from rack/session/abstract/id.rb:274:in 'context'
from rack/session/abstract/id.rb:268:in 'call'
from action_dispatch/middleware/cookies.rb:706:in 'call'
from action_dispatch/middleware/callbacks.rb:31:in 'block in call'
from active_support/callbacks.rb:100:in 'run_callbacks'
from action_dispatch/middleware/callbacks.rb:30:in 'call'
from sentry/rails/rescued_exception_interceptor.rb:14:in 'call'
from action_dispatch/middleware/debug_exceptions.rb:31:in 'call'
from sentry/rack/capture_exceptions.rb:30:in 'block (2 levels) in call'
from sentry/hub.rb:309:in 'with_session_tracking'
from sentry-ruby.rb:430:in 'with_session_tracking'
from sentry/rack/capture_exceptions.rb:21:in 'block in call'
from sentry/hub.rb:89:in 'with_scope'
from sentry-ruby.rb:410:in 'with_scope'
from sentry/rack/capture_exceptions.rb:20:in 'call'
from action_dispatch/middleware/show_exceptions.rb:32:in 'call'
from rails/rack/logger.rb:41:in 'call_app'
from rails/rack/logger.rb:29:in 'call'
from action_dispatch/middleware/remote_ip.rb:96:in 'call'
from action_dispatch/middleware/request_id.rb:34:in 'call'
from rack/method_override.rb:28:in 'call'
from rack/runtime.rb:24:in 'call'
from active_support/cache/strategy/local_cache_middleware.rb:29:in 'call'
from action_dispatch/middleware/executor.rb:16:in 'call'
from rack/sendfile.rb:114:in 'call'
from action_dispatch/middleware/host_authorization.rb:143:in 'call'
from rails/engine.rb:535:in 'call'
from puma/configuration.rb:272:in 'call'
from puma/request.rb:100:in 'block in handle_request'
from puma/thread_pool.rb:378:in 'with_force_shutdown'
from puma/request.rb:99:in 'handle_request'
from puma/server.rb:464:in 'process_client'
from puma/server.rb:245:in 'block in run'
from puma/thread_pool.rb:155:in 'block in spawn_thread'
Apparently, it not coming from rails-i18n and also not from ruby-i18n.