summaryrefslogtreecommitdiff
path: root/app/controllers/revisions_controller.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-07-13 19:12:56 +0200
committererdgeist <erdgeist@erdgeist.org>2026-07-13 19:12:56 +0200
commitba789678f9e8ed189413afb1446ad210df34e488 (patch)
tree23ac4ce3c3403438fa8e50985de2db3b11a924a8 /app/controllers/revisions_controller.rb
parent4072efdc912ecb3b79621fb1838434f792e3a531 (diff)
Make revision diffs locale-aware, defaulting to whichever locale changed
diff_against compared title/abstract/body under whatever I18n.locale happened to be ambient, with no concept of 'diff this translation specifically' -- so a change confined to one locale was invisible to Diff Head vs. Draft regardless of which locale you were looking at when you clicked it, exactly the 'yields nothing' complaint from earlier this session. Page#diff_against gains a locale: keyword, additive only -- nil preserves the exact original ambient-locale behavior every existing caller and test already depends on; passing a locale switches to reading each side's actual PageTranslation row directly, same fallback-free reasoning as Page#translation_summary. Page#locale_diff_summary reports one entry per locale present on either side, so an added or removed translation counts as a change even where content matches everywhere it exists on both. RevisionsController#diff now resolves a real locale before diffing -- defaulting to whichever locale actually changed, falling back to the default locale only when nothing did -- and the view carries that locale through every existing control (view toggle, layer-pair buttons, the revision-select form) so it and the view/layer-pair axis stay independently selectable rather than resetting each other.
Diffstat (limited to 'app/controllers/revisions_controller.rb')
-rw-r--r--app/controllers/revisions_controller.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/revisions_controller.rb b/app/controllers/revisions_controller.rb
index 4b0c549..0aed243 100644
--- a/app/controllers/revisions_controller.rb
+++ b/app/controllers/revisions_controller.rb
@@ -29,8 +29,13 @@ class RevisionsController < ApplicationController
29 redirect_to(node_path(@node)) and return 29 redirect_to(node_path(@node)) and return
30 end 30 end
31 31
32 @locale_summary = @end.locale_diff_summary(@start)
33 requested_locale = params[:locale].presence&.to_sym
34 default_locale = @locale_summary.find { |s| s[:changed] }&.dig(:locale) || I18n.default_locale
35 @locale = @locale_summary.any? { |s| s[:locale] == requested_locale } ? requested_locale : default_locale
36
32 @diff_view = params[:view] == "side_by_side" ? :side_by_side : :inline 37 @diff_view = params[:view] == "side_by_side" ? :side_by_side : :inline
33 @diff = @end.diff_against(@start, view: @diff_view) 38 @diff = @end.diff_against(@start, view: @diff_view, locale: @locale)
34 @available_layer_pairs = @node.available_layer_pairs 39 @available_layer_pairs = @node.available_layer_pairs
35 @locked_by_other = @node.locked? && @node.lock_owner != current_user 40 @locked_by_other = @node.locked? && @node.lock_owner != current_user
36 end 41 end