From dab53a1ef28ecc281d574b50d3433e806db375cd Mon Sep 17 00:00:00 2001
From: erdgeist
Date: Sun, 2 Aug 2026 14:31:50 +0200
Subject: Keep the compared translation independent of the interface language
---
app/views/revisions/diff.html.erb | 84 ++++++++++++++++++--------------------
app/views/revisions/index.html.erb | 10 ++---
app/views/revisions/show.html.erb | 6 +--
3 files changed, 47 insertions(+), 53 deletions(-)
(limited to 'app/views/revisions')
diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb
index 1318bd37..ba320365 100644
--- a/app/views/revisions/diff.html.erb
+++ b/app/views/revisions/diff.html.erb
@@ -4,57 +4,51 @@
<%= link_to t(".revisions_link"), node_revisions_path(@node) %>
-
- <%= t(".comparing") %> <%= describe_page_reference(params[:start_revision]) %>
- <%= t(".against") %> <%= describe_page_reference(params[:end_revision]) %>
- <%= t(".showing_prefix") %> <%= @locale.to_s.upcase %> <%= t(".translation_suffix") %>
-
+<% numeric_comparison = params[:start_revision].to_s =~ /\A\d+\z/ && params[:end_revision].to_s =~ /\A\d+\z/ %>
+<% start_control = numeric_comparison ?
+ select_tag(:start_revision, options_for_select(@node.pages.map(&:revision), params[:start_revision].to_i)) :
+ content_tag(:strong, describe_page_reference(params[:start_revision])) + hidden_field_tag(:start_revision, params[:start_revision]) %>
+<% end_control = numeric_comparison ?
+ select_tag(:end_revision, options_for_select(@node.pages.map(&:revision), params[:end_revision].to_i)) :
+ content_tag(:strong, describe_page_reference(params[:end_revision])) + hidden_field_tag(:end_revision, params[:end_revision]) %>
+<% locale_control = select_tag(:translation_locale, options_for_select(
+ @locale_summary.map { |s| [s[:changed] ? t("revisions.locale_changed", :lang => s[:locale].to_s.upcase) : s[:locale].to_s.upcase, s[:locale]] },
+ @translation_locale)) %>
+<% view_control = select_tag(:view, options_for_select(
+ [[t("revisions.inline"), "inline"], [t("revisions.side_by_side"), "side_by_side"]], @diff_view.to_s)) %>
+<% earlier, later = neighbour_revision_pairs(@node, params[:start_revision], params[:end_revision]) %>
-<% if @locale_summary.size > 1 %>
-
- <%= t("revisions.locale_label") %>
- <% @locale_summary.each_with_index do |s, i| %>
- <%= " · ".html_safe if i > 0 %>
- <% label = "#{s[:locale].to_s.upcase}#{' *' if s[:changed]}" %>
- <% if s[:locale] == @locale %>
- <%= label %>
- <% else %>
- <%= link_to label, diff_node_revisions_path(@node, start_revision: params[:start_revision], end_revision: params[:end_revision], view: @diff_view, locale: s[:locale]) %>
- <% end %>
+<%= form_tag diff_node_revisions_path(@node), :method => :get, :class => "diff_controls" do %>
+
+ <%= t(".comparing_html", :start => start_control, :end => end_control,
+ :lang => locale_control, :view => view_control) %>
+
+
+ <% if earlier %>
+ <%= link_to t(".pair_link", :from => earlier.first, :to => earlier.last), diff_node_revisions_path(@node,
+ start_revision: earlier.first, end_revision: earlier.last,
+ view: @diff_view, translation_locale: @translation_locale) %>
+ <% else %>
+ —
+ <% end %>
+ <%= submit_tag t(".diff_button") %>
+ <% if later %>
+ <%= link_to t(".pair_link", :from => later.first, :to => later.last), diff_node_revisions_path(@node,
+ start_revision: later.first, end_revision: later.last,
+ view: @diff_view, translation_locale: @translation_locale) %>
+ <% else %>
+ —
<% end %>
- <%= t(".changed_hint") %>
<% end %>
-
- <%= t(".view_label") %>
- <% if @diff_view == :inline %>
- <%= t("revisions.inline") %>
- <% else %>
- <%= link_to t("revisions.inline"), diff_node_revisions_path(@node, start_revision: params[:start_revision], end_revision: params[:end_revision], view: 'inline', locale: @locale) %>
- <% end %>
- ·
- <% if @diff_view == :side_by_side %>
- <%= t("revisions.side_by_side") %>
- <% else %>
- <%= link_to t("revisions.side_by_side"), diff_node_revisions_path(@node, start_revision: params[:start_revision], end_revision: params[:end_revision], view: 'side_by_side', locale: @locale) %>
- <% end %>
-
-
-<% numeric_comparison = params[:start_revision].to_s =~ /\A\d+\z/ && params[:end_revision].to_s =~ /\A\d+\z/ %>
-
-<% if numeric_comparison %>
- <%= form_tag diff_node_revisions_path do %>
- <%= select_tag :start_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:start_revision].to_i) %>
- <%= select_tag :end_revision, options_for_select(@node.pages.map{|x| x.revision}, params[:end_revision].to_i) %>
- <%= hidden_field_tag :view, @diff_view %>
- <%= hidden_field_tag :locale, @locale %>
- <%= submit_tag t(".diff_button") %>
- <% end %>
-<% else %>
- <%= link_to t(".compare_numbered"), node_revisions_path(@node) %>
+<% unless numeric_comparison %>
+
+ <%= link_to t(".compare_numbered"), node_revisions_path(@node) %>
+
<% end %>
+
<% if @available_layer_pairs.present? %>
<% @available_layer_pairs.each do |pair| %>
@@ -62,7 +56,7 @@
<%= button_to t("nodes.show.diff_layers", :from => t("nodes.show.layer_#{pair.first}"), :to => t("nodes.show.layer_#{pair.last}")),
diff_node_revisions_path(@node),
method: :get,
- params: { start_revision: pair.first, end_revision: pair.last, view: @diff_view, locale: @locale },
+ params: { start_revision: pair.first, end_revision: pair.last, view: @diff_view, translation_locale: @translation_locale },
form: { class: 'button_to computation' } %>
<% end %>
<% if !@locked_by_other && (@node.autosave || @node.draft) %>
diff --git a/app/views/revisions/index.html.erb b/app/views/revisions/index.html.erb
index 6bcf1820..d118f96a 100644
--- a/app/views/revisions/index.html.erb
+++ b/app/views/revisions/index.html.erb
@@ -9,10 +9,10 @@
<%= t("revisions.locale_label") %>
<% ([I18n.default_locale] + Page.non_default_locales).each_with_index do |locale, i| %>
<%= " · ".html_safe if i > 0 %>
- <% if locale == @locale %>
+ <% if locale == @translation_locale %>
<%= locale.to_s.upcase %>
<% else %>
- <%= link_to locale.to_s.upcase, node_revisions_path(@node, :locale => locale) %>
+ <%= link_to locale.to_s.upcase, node_revisions_path(@node, :translation_locale => locale) %>
<% end %>
<% end %>
@@ -34,7 +34,7 @@
<%= button_to t(".diff_revisions"), diff_node_revisions_path(@node),
method: :post,
- params: { locale: @locale },
+ params: { translation_locale: @translation_locale },
form: { id: 'diff_form', class: 'button_to computation' },
disabled: true %>
" data-selected="<%= t(".selected_word") %>">
@@ -50,10 +50,10 @@
| <%= radio_button_tag :start_revision, page.revision, index == 1 %> |
<%= radio_button_tag :end_revision, page.revision, index == 0 %> |
<%= page.revision %> |
-
<%= page.translations.find_by(:locale => @locale)&.title || "—" %> |
+
<%= page.translations.find_by(:locale => @translation_locale)&.title || "—" %> |
<%= page.editor.try(:login) %> |
<%= page.updated_at %> |
-
<%= link_to t(".show_link"), node_revision_path(@node, page, :locale => @locale) %> |
+
<%= link_to t(".show_link"), node_revision_path(@node, page, :translation_locale => @translation_locale) %> |
<%= button_to t(".restore_link"), restore_node_revision_path(@node, page),
method: :put,
diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb
index a39071c6..addcfa1a 100644
--- a/app/views/revisions/show.html.erb
+++ b/app/views/revisions/show.html.erb
@@ -1,13 +1,13 @@
-<% translation = @page.translations.find_by(:locale => @locale) %>
+<% translation = @page.translations.find_by(:locale => @translation_locale) %>
- <%= t(".title", :rev => @page.revision) %>: <%= translation&.title %> (<%= @locale.to_s.upcase %>)
+ <%= t(".title", :rev => @page.revision) %>: <%= translation&.title %> (<%= @translation_locale.to_s.upcase %>)
<%= t("admin.columns.actions") %>
- <%= link_to t(".show_all"), node_revisions_path(@node, :locale => @locale) %>
+ <%= link_to t(".show_all"), node_revisions_path(@node, :translation_locale => @translation_locale) %>
--
cgit v1.3
|