From bc490c64e5bb23638e2eb09446e202df09b29502 Mon Sep 17 00:00:00 2001 From: benjamin wil Date: Sat, 7 May 2022 20:13:37 -0700 Subject: [PATCH] Create locale helper for global translations There are some translation strings we should use across multiple views. Instead of duplicating the translations, we can use a different locale helper method, `#tt`, to get a hash of all available translations. Then, in a partial view like `pagination.mustache`, we can render translations regardless of what the current view class is. This commit adds the necessary helper, tests, and uses the new method to render translations on the `pagination.mustache` template, which is used by many other view classes (latest changes, history, and search). --- lib/gollum/locales/en.yml | 21 ++--- lib/gollum/templates/pagination.mustache | 10 +-- lib/gollum/views/helpers/locale_helpers.rb | 7 ++ test/gollum/views/test_locale_helper.rb | 95 ++++++++++++++++++++++ 4 files changed, 114 insertions(+), 19 deletions(-) diff --git a/lib/gollum/locales/en.yml b/lib/gollum/locales/en.yml index 363652ee..fafc5dc5 100644 --- a/lib/gollum/locales/en.yml +++ b/lib/gollum/locales/en.yml @@ -1,4 +1,11 @@ en: + pagination: + aria: + label: Pagination + next_page: Next page + previous_page: Previous page + next: Next + previous: Previous precious/views/compare: back_to_page_history: Back to Page History back_to_top: Back to Top @@ -12,13 +19,6 @@ en: browse_in_history_description: Browse the page at this point in the history compare_revisions: Compare Revisions history_for: History for - pagination: - aria: - label: Pagination - next_page: Next page - previous_page: Previous page - next: Next - previous: Previous precious/views/latest_changes: title: Latest Changes (Globally) precious/views/layout: @@ -34,12 +34,5 @@ en: show_all: "Show all %{count} hits in this page" back_to_top: Back to Top no_results: There are no results for your search - pagination: - aria: - label: Pagination - next_page: Next page - previous_page: Previous page - next: Next - previous: Previous search_results_for: Search results for title: "Search results for %{query}" diff --git a/lib/gollum/templates/pagination.mustache b/lib/gollum/templates/pagination.mustache index 76198d5f..020e0976 100644 --- a/lib/gollum/templates/pagination.mustache +++ b/lib/gollum/templates/pagination.mustache @@ -1,23 +1,23 @@ -