Skip to content

Commit

Permalink
Improve typography of display_entries string with Unicode EN DASH (#1105
Browse files Browse the repository at this point in the history
)

In most English style guides, numeric ranges are separated by an en dash
with no spaces. This is subtly different than the previously used
hyphen. For example, see the Wikipedia article on dash:

https://en.wikipedia.org/wiki/Dash

> The en dash is commonly used to indicate a closed range of values – a
> range with clearly defined and finite upper and lower boundaries –
> roughly signifying what might otherwise be communicated by the word
> "through" in American English, or "to" in International English.
  • Loading branch information
jdufresne committed Feb 5, 2024
1 parent 5442f24 commit 8cf327c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ en:
one: "Displaying <b>1</b> %{entry_name}"
other: "Displaying <b>all %{count}</b> %{entry_name}"
more_pages:
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"
display_entries: "Displaying %{entry_name} <b>%{first}%{last}</b> of <b>%{total}</b> in total"
```

If you use non-English localization see [i18n rules](https://github.com/svenfuchs/i18n/blob/master/test/test_data/locales/plurals.rb) for changing
Expand Down
2 changes: 1 addition & 1 deletion kaminari-core/config/locales/kaminari.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ en:
one: "Displaying <b>1</b> %{entry_name}"
other: "Displaying <b>all %{count}</b> %{entry_name}"
more_pages:
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"
display_entries: "Displaying %{entry_name} <b>%{first}%{last}</b> of <b>%{total}</b> in total"
30 changes: 15 additions & 15 deletions kaminari-core/test/helpers/action_view_extension_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,24 @@ def to_s
sub_test_case 'the first page' do
test 'with default entry name' do
users = User.page(1).per(25)
assert_equal 'Displaying users <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total', view.page_entries_info(users)
assert_equal 'Displaying users <b>125</b> of <b>50</b> in total', view.page_entries_info(users)
end

test 'setting the entry name option to "member"' do
users = User.page(1).per(25)
assert_equal 'Displaying members <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'member')
assert_equal 'Displaying members <b>125</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'member')
end
end

sub_test_case 'the next page' do
test 'with default entry name' do
users = User.page(2).per(25)
assert_equal 'Displaying users <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total', view.page_entries_info(users)
assert_equal 'Displaying users <b>2650</b> of <b>50</b> in total', view.page_entries_info(users)
end

test 'setting the entry name option to "member"' do
users = User.page(2).per(25)
assert_equal 'Displaying members <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'member')
assert_equal 'Displaying members <b>2650</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'member')
end
end

Expand All @@ -276,7 +276,7 @@ def to_s
User.max_pages 4
users = User.page(4).per(10)

assert_equal 'Displaying users <b>31&nbsp;-&nbsp;40</b> of <b>40</b> in total', view.page_entries_info(users)
assert_equal 'Displaying users <b>3140</b> of <b>40</b> in total', view.page_entries_info(users)
ensure
User.max_pages nil
end
Expand All @@ -294,7 +294,7 @@ def total_count

users = page_info_presenter.new(User.page(1).per(25))

assert_equal 'Displaying users <b>1&nbsp;-&nbsp;25</b> of <b>1,000</b> in total', view.page_entries_info(users)
assert_equal 'Displaying users <b>125</b> of <b>1,000</b> in total', view.page_entries_info(users)
end
end
end
Expand All @@ -309,7 +309,7 @@ def total_count
begin
I18n.backend.store_translations(:en, User.i18n_scope => { models: { user: { one: "person", other: "people" } } })

assert_equal 'Displaying people <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total', view.page_entries_info(users)
assert_equal 'Displaying people <b>125</b> of <b>50</b> in total', view.page_entries_info(users)
ensure
I18n.backend.reload!
end
Expand All @@ -333,7 +333,7 @@ def total_count
}
},
more_pages: {
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"
display_entries: "Displaying %{entry_name} <b>%{first}%{last}</b> of <b>%{total}</b> in total"
}
}
}
Expand All @@ -347,7 +347,7 @@ def total_count

test 'the last page with default entry name' do
users = User.page(5).per(10)
assert_equal 'Displaying Benutzer <b>41&nbsp;-&nbsp;50</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'Benutzer')
assert_equal 'Displaying Benutzer <b>4150</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'Benutzer')
end
end
end
Expand All @@ -369,7 +369,7 @@ def total_count
}
},
more_pages: {
display_entries: "Displaying %{entry_name} <b>%{first}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"
display_entries: "Displaying %{entry_name} <b>%{first}%{last}</b> of <b>%{total}</b> in total"
}
}
}
Expand All @@ -395,7 +395,7 @@ def total_count

test 'the last page with default entry name' do
users = User.page(5).per(10)
assert_equal 'Displaying utilisateurs <b>41&nbsp;-&nbsp;50</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'utilisateur')
assert_equal 'Displaying utilisateurs <b>4150</b> of <b>50</b> in total', view.page_entries_info(users, entry_name: 'utilisateur')
end
end
end
Expand Down Expand Up @@ -450,24 +450,24 @@ def total_count
sub_test_case 'the first page' do
test 'with default entry name' do
addresses = User::Address.page(1).per(25)
assert_equal 'Displaying addresses <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total', view.page_entries_info(addresses)
assert_equal 'Displaying addresses <b>125</b> of <b>50</b> in total', view.page_entries_info(addresses)
end

test 'setting the entry name option to "place"' do
addresses = User::Address.page(1).per(25)
assert_equal 'Displaying places <b>1&nbsp;-&nbsp;25</b> of <b>50</b> in total', view.page_entries_info(addresses, entry_name: 'place')
assert_equal 'Displaying places <b>125</b> of <b>50</b> in total', view.page_entries_info(addresses, entry_name: 'place')
end
end

sub_test_case 'the next page' do
test 'with default entry name' do
addresses = User::Address.page(2).per(25)
assert_equal 'Displaying addresses <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total', view.page_entries_info(addresses)
assert_equal 'Displaying addresses <b>2650</b> of <b>50</b> in total', view.page_entries_info(addresses)
end

test 'setting the entry name option to "place"' do
addresses = User::Address.page(2).per(25)
assert_equal 'Displaying places <b>26&nbsp;-&nbsp;50</b> of <b>50</b> in total', view.page_entries_info(addresses, entry_name: 'place')
assert_equal 'Displaying places <b>2650</b> of <b>50</b> in total', view.page_entries_info(addresses, entry_name: 'place')
end
end
end
Expand Down

0 comments on commit 8cf327c

Please sign in to comment.