Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the sort options go through i18n. #1025

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions app/views/search/common/_facet_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ Variable that should be available

<%
extras = if resource_type.name == 'Event'
[['Earliest', 'early'], ['Latest', 'late'], ['Most recent', 'new']]
[[t('sidebar.sort.values.earliest'), 'early'],
[t('sidebar.sort.values.latest'), 'late'],
[t('sidebar.sort.values.most_recent'), 'new']]
elsif resource_type.name == 'Source'
[['Most recent', 'new'], ['Last finished', 'finished']]
[[t('sidebar.sort.values.most_recent'), 'new'],
[t('sidebar.sort.values.last_finished'), 'finished']]
else
[['Most recent', 'new']]
[[t('sidebar.sort.values.most_recent'), 'new']]
end %>

<%= render partial: 'search/common/sort_by', locals: { resources: resource_type, extras: extras } %>
Expand Down
14 changes: 8 additions & 6 deletions app/views/search/common/_sort_by.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
Parameters:
Extras - Array of Arrays with options for select
e.g.
[['Earliest', 'early'], ['Latest', 'late']]
[[t('sidebar.sort.values.earliest'), 'early'],
[t('sidebar.sort.values.latest'), 'late']]
%>
<% if defined? extras %>
<% extras = extras.reverse! || false %>
<% end %>


<% options = [
['Title ascending', 'asc'],
['Title descending', 'desc'],
['Last modified', 'mod'],
# ['Relevance', 'rel']
[t('sidebar.sort.values.title_ascending'), 'asc'],
[t('sidebar.sort.values.title_descending'), 'desc'],
[t('sidebar.sort.values.last_modified'), 'mod'],
# [t('sidebar.sort.values.relevance'), 'rel']
] %>

<% if extras %>
Expand All @@ -21,7 +23,7 @@ e.g.
<% end %>

<ul class="unstyled nav-simple facet-sort-wrap">
<li><h4 class="nav-heading">Sort</h4></li>
<li><h4 class="nav-heading"><%= t('sidebar.sort.heading') %></h4></li>
<li class="sidebar-group">
<ul>
<li class="facet-sort-group">
Expand Down
12 changes: 12 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -748,3 +748,15 @@ en:
mailer:
events_require_approval:
subject: "Last week's events on %{site_name}"
sidebar:
sort:
heading: Sort
values:
title_ascending: Title ascending
title_descending: Title descending
last_modified: Last modified
relevance: Relevance
earliest: Earliest
latest: Latest
most_recent: Most recent
last_finished: Last finished
Loading