From fe104aa2c52f61cd8555fbc98c20501f50f4aae8 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Sat, 25 Jul 2026 17:45:34 +0200 Subject: Extract admin strings to i18n: revisions, page_translations, and menu items, --- app/views/menu_items/edit.html.erb | 12 ++--- app/views/menu_items/index.html.erb | 10 ++-- app/views/menu_items/new.html.erb | 12 ++--- app/views/page_translations/edit.html.erb | 32 ++++++------ app/views/page_translations/show.html.erb | 18 +++---- app/views/revisions/diff.html.erb | 66 ++++++++++++------------- app/views/revisions/index.html.erb | 36 +++++++------- app/views/revisions/show.html.erb | 22 ++++----- config/locales/de.yml | 70 +++++++++++++++++++++++++-- config/locales/en.yml | 70 +++++++++++++++++++++++++-- test/controllers/revisions_controller_test.rb | 10 ++-- 11 files changed, 242 insertions(+), 116 deletions(-) diff --git a/app/views/menu_items/edit.html.erb b/app/views/menu_items/edit.html.erb index 89854c93..0652dc78 100644 --- a/app/views/menu_items/edit.html.erb +++ b/app/views/menu_items/edit.html.erb @@ -1,25 +1,25 @@ -

Edit Menu Item

+

<%= t(".title") %>

<%= form_for @menu_item do |f| %>
-
Search
+
<%= t("admin.common.search") %>
<%= text_field_tag :menu_search_term %>
-
Node Id
+
<%= MenuItem.human_attribute_name(:node_id) %>
<%= f.text_field :node_id %>
-
Path
+
<%= MenuItem.human_attribute_name(:path) %>
<%= f.text_field :path %>
-
Title
+
<%= MenuItem.human_attribute_name(:title) %>
<%= f.text_field :title %>
-
<%= f.submit 'Update' %>
+
<%= f.submit t("admin.common.update") %>
<% end %>
diff --git a/app/views/menu_items/index.html.erb b/app/views/menu_items/index.html.erb index 591eb68d..cdc60c63 100644 --- a/app/views/menu_items/index.html.erb +++ b/app/views/menu_items/index.html.erb @@ -1,7 +1,7 @@ -

Menu Items

+

<%= t(".title") %>

<%= link_to new_menu_item_path, class: 'action_button' do %> - <%= icon("plus", library: "tabler", "aria-hidden": true) %> Create menu item + <%= icon("plus", library: "tabler", "aria-hidden": true) %> <%= t(".create_item") %> <% end %> @@ -11,11 +11,11 @@
- + diff --git a/app/views/menu_items/new.html.erb b/app/views/menu_items/new.html.erb index 408ba7bd..713ac967 100644 --- a/app/views/menu_items/new.html.erb +++ b/app/views/menu_items/new.html.erb @@ -1,20 +1,20 @@ -

Add Menu Item

+

<%= t(".title") %>

<%= form_for @menu_item do |f| %> -
Search
+
<%= t("admin.common.search") %>
<%= text_field_tag :menu_search_term %>
-
Node Id
+
<%= MenuItem.human_attribute_name(:node_id) %>
<%= f.text_field :node_id %>
-
Path
+
<%= MenuItem.human_attribute_name(:path) %>
<%= f.text_field :path %>
-
Title
+
<%= MenuItem.human_attribute_name(:title) %>
<%= f.text_field :title %>
-
<%= f.submit 'Create' %>
+
<%= f.submit t("admin.common.create") %>
<% end %> diff --git a/app/views/page_translations/edit.html.erb b/app/views/page_translations/edit.html.erb index ac91d22c..f398a544 100644 --- a/app/views/page_translations/edit.html.erb +++ b/app/views/page_translations/edit.html.erb @@ -1,22 +1,20 @@
- Editing the <%= @locale.to_s.upcase %> translation of <%= title_for_node(@node) %>. + <%= t(".editing_prefix") %> <%= @locale.to_s.upcase %> <%= t(".translation_of") %> <%= title_for_node(@node) %>.
-

<%= link_to 'View revision history', node_revisions_path(@node, :locale => @locale) %>

+

<%= link_to t("page_translations.revision_history_link"), node_revisions_path(@node, :locale => @locale) %>

- Metadata such as images, tags, template, and author belong to the page - as a whole, not to a single translation — change those from the - <%= link_to 'default-locale editor', edit_node_path(@node) %>. + <%= t(".metadata_hint_prefix") %> <%= link_to t(".metadata_hint_link"), edit_node_path(@node) %>.

- <%= button_to 'Unlock + Back', unlock_node_path(@node), method: :put, + <%= button_to t("nodes.edit.unlock_back"), unlock_node_path(@node), method: :put, form: { class: 'button_to state_changing' }, disabled: @node.autosave.present? %> - <%= submit_tag "Save #{@locale.to_s.upcase} translation", form: "translation_edit_form" %> - <%= submit_tag "Save + Unlock + Exit", name: "unlock_exit", form: "translation_edit_form" %> - <%= link_to "Preview ↗", preview_page_path(@page, :locale => @locale), target: "_blank", rel: "noopener", class: "preview_link" %> + <%= submit_tag t(".save_translation", :lang => @locale.to_s.upcase), form: "translation_edit_form" %> + <%= submit_tag t("nodes.edit.save_unlock_exit"), name: "unlock_exit", form: "translation_edit_form" %> + <%= link_to t("nodes.edit.preview"), preview_page_path(@page, :locale => @locale), target: "_blank", rel: "noopener", class: "preview_link" %>
@@ -32,23 +30,23 @@ <%= form_with url: node_translation_path(@node, @locale), method: :patch, local: true, id: "translation_edit_form", data: { autosave_url: autosave_node_translation_path(@node, @locale), show_url: node_path(@node) } do |f| %>
-
Title
+
<%= Page.human_attribute_name(:title) %>
<%= text_field_tag "page[title]", @translation&.title %>
-
Abstract
+
<%= Page.human_attribute_name(:abstract) %>
<%= text_area_tag "page[abstract]", @translation&.abstract %>
-
Body
+
<%= Page.human_attribute_name(:body) %>
- -
@@ -59,7 +57,7 @@
diff --git a/app/views/page_translations/show.html.erb b/app/views/page_translations/show.html.erb index c4091fc3..0fbcd0b6 100644 --- a/app/views/page_translations/show.html.erb +++ b/app/views/page_translations/show.html.erb @@ -1,29 +1,29 @@ -

Compare — <%= title_for_node(@node) %>

+

<%= t(".title") %> — <%= title_for_node(@node) %>

-

<%= link_to 'View revision history', node_revisions_path(@node, :locale => @locale) %>

+

<%= link_to t("page_translations.revision_history_link"), node_revisions_path(@node, :locale => @locale) %>

<%= @locale.to_s.upcase %>

-
Title
+
<%= Page.human_attribute_name(:title) %>
<%= @translation&.title %>
-
Abstract
+
<%= Page.human_attribute_name(:abstract) %>
<%= sanitize(@translation&.abstract.to_s) %>
-
Body
+
<%= Page.human_attribute_name(:body) %>
<%= sanitize(@translation&.body.to_s) %>
-

<%= I18n.default_locale.to_s.upcase %> (default)

-
Title
+

<%= I18n.default_locale.to_s.upcase %> (<%= t(".default_marker") %>)

+
<%= Page.human_attribute_name(:title) %>
<%= @default_translation&.title %>
-
Abstract
+
<%= Page.human_attribute_name(:abstract) %>
<%= sanitize(@default_translation&.abstract.to_s) %>
-
Body
+
<%= Page.human_attribute_name(:body) %>
<%= sanitize(@default_translation&.body.to_s) %>
diff --git a/app/views/revisions/diff.html.erb b/app/views/revisions/diff.html.erb index 7e7b729e..1318bd37 100644 --- a/app/views/revisions/diff.html.erb +++ b/app/views/revisions/diff.html.erb @@ -1,18 +1,18 @@ -

Revisions#diff

+

<%= t(".title") %>

- <%= link_to 'Revisions', node_revisions_path(@node) %> + <%= link_to t(".revisions_link"), node_revisions_path(@node) %>

- Comparing <%= describe_page_reference(params[:start_revision]) %> - against <%= describe_page_reference(params[:end_revision]) %> - — showing the <%= @locale.to_s.upcase %> translation + <%= 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") %>

<% if @locale_summary.size > 1 %>

- Locale: + <%= 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]}" %> @@ -23,21 +23,21 @@ <% end %> <% end %>

-

* has a difference between these two versions.

+

<%= t(".changed_hint") %>

<% end %>

- View: + <%= t(".view_label") %> <% if @diff_view == :inline %> - Inline + <%= t("revisions.inline") %> <% else %> - <%= link_to 'Inline', diff_node_revisions_path(@node, start_revision: params[:start_revision], end_revision: params[:end_revision], view: 'inline', locale: @locale) %> + <%= 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 %> - Side by side + <%= t("revisions.side_by_side") %> <% else %> - <%= link_to 'Side by side', diff_node_revisions_path(@node, start_revision: params[:start_revision], end_revision: params[:end_revision], view: 'side_by_side', locale: @locale) %> + <%= 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 %>

@@ -49,17 +49,17 @@ <%= 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 'Diff' %> + <%= submit_tag t(".diff_button") %> <% end %> <% else %> -

<%= link_to 'Compare two numbered revisions instead', node_revisions_path(@node) %>

+

<%= link_to t(".compare_numbered"), node_revisions_path(@node) %>

<% end %> <% if @available_layer_pairs.present? %>
<% @available_layer_pairs.each do |pair| %> <% next if [params[:start_revision].to_s, params[:end_revision].to_s].sort == pair.map(&:to_s).sort %> - <%= button_to "Diff #{pair.first.to_s.capitalize} vs. #{pair.last.to_s.capitalize}", + <%= 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 }, @@ -68,9 +68,9 @@ <% if !@locked_by_other && (@node.autosave || @node.draft) %> <%= button_to revert_node_path(@node), method: :put, params: { return_to: request.fullpath }, - form: { data: { confirm: "This cannot be undone. Continue?" }, class: 'button_to destructive' } do %> + form: { data: { confirm: t("admin.common.confirm_irreversible") }, class: 'button_to destructive' } do %> <%= icon("trash", library: "tabler", "aria-hidden": true) %> - <%= @node.draft && !@node.autosave ? "Destroy Draft" : "Discard Autosave" %> + <%= @node.draft && !@node.autosave ? t("nodes.show.destroy_draft") : t("nodes.show.discard_autosave") %> <% end %> <% end %>
@@ -80,34 +80,34 @@ <% if @diff_view == :side_by_side %>
-

Title

+

<%= Page.human_attribute_name(:title) %>

<%= raw @diff[:title][0] %>

-

Abstract

+

<%= Page.human_attribute_name(:abstract) %>

<%= raw @diff[:abstract][0] %>

-

Body

+

<%= Page.human_attribute_name(:body) %>

<%= raw @diff[:body][0] %>
-

Title

+

<%= Page.human_attribute_name(:title) %>

<%= raw @diff[:title][1] %>

-

Abstract

+

<%= Page.human_attribute_name(:abstract) %>

<%= raw @diff[:abstract][1] %>

-

Body

+

<%= Page.human_attribute_name(:body) %>

<%= raw @diff[:body][1] %>
<% else %> -

Title

+

<%= Page.human_attribute_name(:title) %>

<%= raw @diff[:title] %>

-

Abstract

+

<%= Page.human_attribute_name(:abstract) %>

<%= raw @diff[:abstract] %>

-

Body

+

<%= Page.human_attribute_name(:body) %>

<%= raw @diff[:body] %> <% end %> -

Tags

+

<%= Page.human_attribute_name(:tag_list) %>

<% if @diff[:tags][:added].empty? && @diff[:tags][:removed].empty? %> -

No change.

+

<%= t(".no_change") %>

<% else %> <% end %> -

Template

+

<%= Page.human_attribute_name(:template_name) %>

<% if @diff[:template_name][:changed] %> -

<%= @diff[:template_name][:from] || '(none)' %> <%= @diff[:template_name][:to] || '(none)' %>

+

<%= @diff[:template_name][:from] || t(".none_marker") %> <%= @diff[:template_name][:to] || t(".none_marker") %>

<% else %> -

No change.

+

<%= t(".no_change") %>

<% end %> -

Assets

+

<%= Page.human_attribute_name(:assets) %>

<% if @diff[:assets][:added].empty? && @diff[:assets][:removed].empty? %> -

No change.

+

<%= t(".no_change") %>

<% else %> - - - - - - + + + + + + @@ -53,11 +53,11 @@ - + <% end %> @@ -73,9 +73,9 @@ var label = document.getElementById('diff_selection_label'); if (start && end) { - label.textContent = start.value + ' against ' + end.value; + label.textContent = start.value + ' ' + label.dataset.against + ' ' + end.value; } else if (start || end) { - label.textContent = (start || end).value + ' selected'; + label.textContent = (start || end).value + ' ' + label.dataset.selected; } else { label.textContent = ''; } diff --git a/app/views/revisions/show.html.erb b/app/views/revisions/show.html.erb index 64bc0eea..a39071c6 100644 --- a/app/views/revisions/show.html.erb +++ b/app/views/revisions/show.html.erb @@ -1,39 +1,39 @@ <% translation = @page.translations.find_by(:locale => @locale) %>
-

Revision <%= @page.revision %>: <%= translation&.title %> (<%= @locale.to_s.upcase %>)

+

<%= t(".title", :rev => @page.revision) %>: <%= translation&.title %> (<%= @locale.to_s.upcase %>)

-
Actions
+
<%= t("admin.columns.actions") %>
- <%= link_to 'Show all revisions', node_revisions_path(@node, :locale => @locale) %> + <%= link_to t(".show_all"), node_revisions_path(@node, :locale => @locale) %>
-
Path
+
<%= t("admin.columns.path") %>
<%= @page.public_link %>
-
Author
+
<%= t("admin.columns.author") %>
<%= @page.user.try(:login) %>
-
Editor
+
<%= t("admin.columns.editor") %>
<%= @page.editor.try(:login) %>
-
Last updated
+
<%= t("nodes.show.last_updated") %>
<%= @page.updated_at %>
-
Published at
+
<%= t("nodes.show.published_at") %>
<%= @page.published_at %>
-
Title
+
<%= Page.human_attribute_name(:title) %>
<%= translation&.title %>
-
Abstract
+
<%= Page.human_attribute_name(:abstract) %>
<%= translation&.abstract %>
-
Body
+
<%= Page.human_attribute_name(:body) %>
<%= raw translation&.body %>
diff --git a/config/locales/de.yml b/config/locales/de.yml index 8a8a9a40..0ffc6ecc 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -103,6 +103,17 @@ de: tag_list: "Tags" latitude: "Breitengrad" longitude: "Längengrad" + page: + title: "Titel" + abstract: "Abstract" + body: "Text" + tag_list: "Tags" + template_name: "Template" + assets: "Anhänge" + menu_item: + node_id: "Node-ID" + path: "Pfad" + title: "Titel" tags: index: @@ -247,6 +258,8 @@ de: path: "Pfad" preview: "Vorschau" name: "Name" + editor: "Editor" + date: "Datum" author: "Autor" type: "Typ" menu: @@ -505,9 +518,6 @@ de: created: "Termin wurde angelegt." updated: "Termin wurde aktualisiert." tag_prefilled: "Tag '%{tag}' wurde vorausgefüllt, weil diese Seite mit '%{source}' getaggt ist. Er lässt sich unten entfernen." - occurrences: - created: "Termin-Instanz wurde angelegt." - updated: "Termin-Instanz wurde aktualisiert." revisions: unavailable: "Dieser Vergleich ist nicht mehr verfügbar." restored: "Revision %{rev} wiederhergestellt" @@ -565,6 +575,60 @@ de: as_headline: "als Aufmacher der Seite anhängen" headline_hint: "Gilt nur, wenn die Seite noch keinen Aufmacher hat." + revisions: + locale_label: "Sprache:" + inline: "Inline" + side_by_side: "Nebeneinander" + diff: + title: "Revisionen vergleichen" + revisions_link: "Revisionen" + comparing: "Vergleiche" + against: "mit" + showing_prefix: "— gezeigt wird die" + translation_suffix: "Übersetzung" + changed_hint: "* unterscheidet sich zwischen diesen beiden Versionen." + view_label: "Ansicht:" + diff_button: "Diff" + compare_numbered: "Stattdessen zwei nummerierte Revisionen vergleichen" + none_marker: "(keins)" + no_change: "Keine Änderung." + index: + title: "Revisionen für Node: %{path}" + back_to_node: "Zurück zum Node" + first: "Von" + last: "Bis" + diff_revisions: "Revisionen vergleichen" + against_word: "mit" + selected_word: "ausgewählt" + show_link: "anzeigen" + restore_link: "wiederherstellen" + confirm_restore: "Diese Revision wiederherstellen?" + show: + title: "Revision %{rev}" + show_all: "Alle Revisionen anzeigen" + + page_translations: + revision_history_link: "Revisionsübersicht anzeigen" + edit: + editing_prefix: "Bearbeite die" + translation_of: "Übersetzung von" + metadata_hint_prefix: "Metadaten wie Bilder, Tags, Template und Autor gehören zur Seite als Ganzes, nicht zu einer einzelnen Übersetzung — ändere sie im" + metadata_hint_link: "Editor der Standardsprache" + save_translation: "%{lang}-Übersetzung speichern" + show: + title: "Vergleich" + default_marker: "Standard" + + menu_items: + index: + title: "Menüeinträge" + create_item: "Menüeintrag anlegen" + confirm_destroy: "Diesen Menüeintrag wirklich löschen?" + new: + title: "Menüeintrag hinzufügen" + edit: + title: "Menüeintrag bearbeiten" + layouts: flash: go_to_status: "Zum Status" diff --git a/config/locales/en.yml b/config/locales/en.yml index 44b1615b..5f2f266a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -55,6 +55,17 @@ en: tag_list: "Tags" latitude: "Latitude" longitude: "Longitude" + page: + title: "Title" + abstract: "Abstract" + body: "Body" + tag_list: "Tags" + template_name: "Template" + assets: "Assets" + menu_item: + node_id: "Node Id" + path: "Path" + title: "Title" tags: index: @@ -200,6 +211,8 @@ en: preview: "Preview" name: "Name" author: "Author" + editor: "Editor" + date: "Date" type: "Type" menu: dashboard: "Dashboard" @@ -422,6 +435,16 @@ en: new: title: "New event" + menu_items: + index: + title: "Menu Items" + create_item: "Create menu item" + confirm_destroy: "Do you really want to destroy the menu entry?" + new: + title: "Add Menu Item" + edit: + title: "Edit Menu Item" + flash: common: logged_in: "Logged in successfully" @@ -456,9 +479,6 @@ en: created: "Event was successfully created." updated: "Event was successfully updated." tag_prefilled: "Tag '%{tag}' was pre-filled because this page is tagged '%{source}'. You can remove it below." - occurrences: - created: "Occurrence was successfully created." - updated: "Occurrence was successfully updated." revisions: unavailable: "That comparison is no longer available." restored: "Revision %{rev} restored" @@ -516,6 +536,50 @@ en: as_headline: "attach as the page's headline" headline_hint: "Applies only if the page has no headline yet." + revisions: + locale_label: "Locale:" + inline: "Inline" + side_by_side: "Side by side" + diff: + title: "Compare revisions" + revisions_link: "Revisions" + comparing: "Comparing" + against: "against" + showing_prefix: "— showing the" + translation_suffix: "translation" + changed_hint: "* has a difference between these two versions." + view_label: "View:" + diff_button: "Diff" + compare_numbered: "Compare two numbered revisions instead" + none_marker: "(none)" + no_change: "No change." + index: + title: "Revisions for Node: %{path}" + back_to_node: "Back to node" + first: "First" + last: "Last" + diff_revisions: "Diff revisions" + against_word: "against" + selected_word: "selected" + show_link: "show" + restore_link: "restore" + confirm_restore: "Restore this revision?" + show: + title: "Revision %{rev}" + show_all: "Show all revisions" + + page_translations: + revision_history_link: "View revision history" + edit: + editing_prefix: "Editing the" + translation_of: "translation of" + metadata_hint_prefix: "Metadata such as images, tags, template, and author belong to the page as a whole, not to a single translation — change those from the" + metadata_hint_link: "default-locale editor" + save_translation: "Save %{lang} translation" + show: + title: "Compare" + default_marker: "default" + layouts: flash: go_to_status: "Go to Status" diff --git a/test/controllers/revisions_controller_test.rb b/test/controllers/revisions_controller_test.rb index bb21ea68..8311735c 100644 --- a/test/controllers/revisions_controller_test.rb +++ b/test/controllers/revisions_controller_test.rb @@ -33,7 +33,7 @@ class RevisionsControllerTest < ActionController::TestCase login_as :quentin get :show, params: { :node_id => @node.id, :id => @node.pages.last.id } assert_response :success - assert_select ".layout_row_label", "Body" + assert_select ".layout_row_label", Page.human_attribute_name(:body) assert_select ".layout_row_content", {:count => 1, :text => "second"} end @@ -146,7 +146,7 @@ class RevisionsControllerTest < ActionController::TestCase post(:diff, params: { :node_id => @node.id, :start_revision => "head", :end_revision => "draft" }) assert_response :success - assert_select "a", "Side by side" + assert_select "a", I18n.t("revisions.side_by_side") end test "diffing two revisions also shows tag, template, and asset changes" do @@ -157,9 +157,9 @@ class RevisionsControllerTest < ActionController::TestCase post(:diff, params: { :node_id => @node.id, :start_revision => @node.pages.first.revision, :end_revision => @node.pages.last.revision }) assert_response :success - assert_select "h3", "Tags" - assert_select "h3", "Template" - assert_select "h3", "Assets" + assert_select "h3", Page.human_attribute_name(:tag_list) + assert_select "h3", Page.human_attribute_name(:template_name) + assert_select "h3", Page.human_attribute_name(:assets) end test "revisions#index links back to the node" do -- cgit v1.3
FirstLastRev.TitleEditorDate<%= t(".first") %><%= t(".last") %><%= t("admin.columns.rev") %><%= t("admin.columns.title") %><%= t("admin.columns.editor") %><%= t("admin.columns.date") %>
- <%= button_to 'Diff revisions', diff_node_revisions_path(@node), + <%= button_to t(".diff_revisions"), diff_node_revisions_path(@node), method: :post, params: { locale: @locale }, form: { id: 'diff_form', class: 'button_to computation' }, disabled: true %> - - - + " data-selected="<%= t(".selected_word") %>"> + +
<%= page.translations.find_by(:locale => @locale)&.title || "—" %> <%= page.editor.try(:login) %> <%= page.updated_at %><%= link_to 'show', node_revision_path(@node, page, :locale => @locale) %><%= link_to t(".show_link"), node_revision_path(@node, page, :locale => @locale) %> - <%= button_to 'restore', restore_node_revision_path(@node, page), + <%= button_to t(".restore_link"), restore_node_revision_path(@node, page), method: :put, - form: { data: { confirm: "Restore this revision?" }, class: 'button_to state_changing' } %> + form: { data: { confirm: t(".confirm_restore") }, class: 'button_to state_changing' } %>