From 6c20570d2a4c6cb698d0a08dbcb86ecc2a25a131 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 27 Jul 2026 11:16:14 +0200 Subject: Pin admin content reads to the default locale --- .../concerns/pinned_to_default_locale.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 app/controllers/concerns/pinned_to_default_locale.rb (limited to 'app/controllers/concerns') diff --git a/app/controllers/concerns/pinned_to_default_locale.rb b/app/controllers/concerns/pinned_to_default_locale.rb new file mode 100644 index 00000000..6c7fb900 --- /dev/null +++ b/app/controllers/concerns/pinned_to_default_locale.rb @@ -0,0 +1,22 @@ +# Chrome locale and content locale are separate concerns, and in the +# admin they must not touch. Globalize.locale falls back to +# I18n.locale when unset, so without this pin a visit to /en/admin +# would silently switch every Page and MenuItem read to its English +# translation. +# +# Translation editors are the exception and select their locale from +# params, not from the chrome. They nest their own +# Globalize.with_locale inside this one, which wins. +module PinnedToDefaultLocale + extend ActiveSupport::Concern + + included do + around_action :pin_to_default_locale + end + + private + + def pin_to_default_locale + Globalize.with_locale(I18n.default_locale) { yield } + end +end -- cgit v1.3