diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-07-27 00:06:34 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-07-27 00:06:34 +0200 |
| commit | 334d386f8ae052e4f3b4442347cb5be8c5c02c8f (patch) | |
| tree | 1b52ccb67595964eea528bdec65bc4b0c7165e64 /app/models | |
| parent | ced4c12b399c526dd5dd0eb0d5d086244515cd85 (diff) | |
Let Globalize decide what locale to display for a page translation
Diffstat (limited to 'app/models')
| -rw-r--r-- | app/models/page.rb | 4 |
1 files 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 | |||
| 83 | 83 | ||
| 84 | if options[:order_by] == "title" | 84 | if options[:order_by] == "title" |
| 85 | return scope | 85 | return scope |
| 86 | .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}")) | 86 | .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}")) |
| 87 | .paginate(:page => page, :per_page => options[:limit]) | 87 | .paginate(:page => page, :per_page => options[:limit]) |
| 88 | end | 88 | end |
| 89 | 89 | ||
| @@ -145,7 +145,7 @@ class Page < ApplicationRecord | |||
| 145 | return true unless template_name == draft.template_name | 145 | return true unless template_name == draft.template_name |
| 146 | return true unless translated_locales.sort_by(&:to_s) == draft.translated_locales.sort_by(&:to_s) | 146 | return true unless translated_locales.sort_by(&:to_s) == draft.translated_locales.sort_by(&:to_s) |
| 147 | changed = false | 147 | changed = false |
| 148 | translated_locales.each { |locale| I18n.with_locale(locale) { changed = true unless title == draft.title && abstract == draft.abstract && body == draft.body } } | 148 | translated_locales.each { |locale| Globalize.with_locale(locale) { changed = true unless title == draft.title && abstract == draft.abstract && body == draft.body } } |
| 149 | return changed | 149 | return changed |
| 150 | end | 150 | end |
| 151 | 151 | ||
