From 334d386f8ae052e4f3b4442347cb5be8c5c02c8f Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 27 Jul 2026 00:06:34 +0200 Subject: Let Globalize decide what locale to display for a page translation --- app/models/page.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/page.rb b/app/models/page.rb index 817e3bd4..cf003f74 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -83,7 +83,7 @@ class Page < ApplicationRecord if options[:order_by] == "title" return scope - .order(Arel.sql("(SELECT pt.title FROM page_translations pt WHERE pt.page_id = pages.id AND pt.locale = #{ActiveRecord::Base.connection.quote(I18n.locale.to_s)}) #{direction}")) + .order(Arel.sql("(SELECT pt.title FROM page_translations pt WHERE pt.page_id = pages.id AND pt.locale = #{ActiveRecord::Base.connection.quote(Globalize.locale.to_s)}) #{direction}")) .paginate(:page => page, :per_page => options[:limit]) end @@ -145,7 +145,7 @@ class Page < ApplicationRecord return true unless template_name == draft.template_name return true unless translated_locales.sort_by(&:to_s) == draft.translated_locales.sort_by(&:to_s) changed = false - translated_locales.each { |locale| I18n.with_locale(locale) { changed = true unless title == draft.title && abstract == draft.abstract && body == draft.body } } + translated_locales.each { |locale| Globalize.with_locale(locale) { changed = true unless title == draft.title && abstract == draft.abstract && body == draft.body } } return changed end -- cgit v1.3