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).
This commit is contained in:
@@ -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}"
|
||||
|
||||
@@ -1,23 +1,23 @@
|
||||
<nav class="paginate-container" aria-label="{{t.pagination.aria.label}}">
|
||||
<nav class="paginate-container" aria-label="{{tt.pagination.aria.label}}">
|
||||
<div class="pagination" id="pagination">
|
||||
<a
|
||||
aria-label="{{t.pagination.aria.previous_page}}"
|
||||
aria-label="{{td.pagination.aria.previous_page}}"
|
||||
class="previous_page {{^previous_page}}disabled{{/previous_page}}"
|
||||
href="?page_num={{previous_page}}{{query_string}}"
|
||||
id="prev"
|
||||
rel="prev"
|
||||
>
|
||||
{{t.pagination.previous}}
|
||||
{{tt.pagination.previous}}
|
||||
</a>
|
||||
|
||||
<a
|
||||
aria-label="{{t.pagination.aria.next_page}}"
|
||||
aria-label="{{td.pagination.aria.next_page}}"
|
||||
class="next_page {{^next_page}}disabled{{/next_page}}"
|
||||
href="?page_num={{next_page}}{{query_string}}"
|
||||
id="next"
|
||||
rel="next"
|
||||
>
|
||||
{{t.pagination.next}}
|
||||
{{tt.pagination.next}}
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@@ -21,6 +21,13 @@ module Precious
|
||||
autofill I18n.t(locale_klass_name)
|
||||
end
|
||||
|
||||
# Returns all I18n translation strings from the root of an I18n YAML file.
|
||||
# Otherwise, it works exactly like the `#t` method that's also defined in
|
||||
# this file.
|
||||
def tt
|
||||
autofill I18n.t('.')
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# Recursively looks up I18n translation values and autofills any YAML
|
||||
|
||||
Reference in New Issue
Block a user