Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/pull/4077'
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Jul 5, 2023
2 parents 817cd69 + d58cae6 commit 62c68b9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
8 changes: 7 additions & 1 deletion app/views/diary_entries/_diary_entry.html.erb
Expand Up @@ -35,7 +35,13 @@
<% if params[:action] == 'index' %>
<li><%= link_to t(".comment_link"), diary_entry_path(diary_entry.user, diary_entry, :anchor => "newcomment") %></li>
<li><%= link_to t(".reply_link"), new_message_path(diary_entry.user, :message => { :title => "Re: #{diary_entry.title}" }) %></li>
<li><%= link_to t(".comment_count", :count => diary_entry.visible_comments.count), diary_entry_path(diary_entry.user, diary_entry, :anchor => "comments") %></li>
<li>
<% if diary_entry.visible_comments.count > 0 %>
<%= link_to t(".comment_count", :count => diary_entry.visible_comments.count), diary_entry_path(diary_entry.user, diary_entry, :anchor => "comments") %>
<% else %>
<%= link_to t(".no_comments"), diary_entry_path(diary_entry.user, diary_entry, :anchor => "comments") %>
<% end %>
</li>
<% end %>
<% if current_user && current_user == diary_entry.user %>
Expand Down
6 changes: 5 additions & 1 deletion app/views/issues/show.html.erb
Expand Up @@ -4,7 +4,11 @@
<p class="text-muted">
<small>
<%= @issue.assigned_role %>
| <%= t ".reports", :count => @issue.reports.count %>
<% if @issue.reports.count > 0 %>
| <%= t ".reports", :count => @issue.reports.count %>
<% else %>
| <%= t ".no_reports" %>
<% end %>
| <%= t ".report_created_at", :datetime => l(@issue.created_at.to_datetime, :format => :friendly) %>
<%= " | #{t('.last_resolved_at', :datetime => l(@issue.resolved_at.to_datetime, :format => :friendly))}" if @issue.resolved_at? %>
<%= " | #{t('.last_updated_at', :datetime => l(@issue.updated_at.to_datetime, :format => :friendly), :displayname => @issue.user_updated.display_name)}" if @issue.user_updated %>
Expand Down
4 changes: 2 additions & 2 deletions config/locales/en.yml
Expand Up @@ -515,9 +515,9 @@ en:
comment_link: Comment on this entry
reply_link: Send a message to the author
comment_count:
zero: No comments
one: "%{count} comment"
other: "%{count} comments"
no_comments: No comments
edit_link: Edit this entry
hide_link: Hide this entry
unhide_link: Unhide this entry
Expand Down Expand Up @@ -1403,9 +1403,9 @@ en:
show:
title: "%{status} Issue #%{issue_id}"
reports:
zero: No reports
one: "%{count} report"
other: "%{count} reports"
no_reports: No reports
report_created_at: "First reported at %{datetime}"
last_resolved_at: "Last resolved at %{datetime}"
last_updated_at: "Last updated at %{datetime} by %{displayname}"
Expand Down
19 changes: 19 additions & 0 deletions test/lib/i18n_test.rb
Expand Up @@ -72,6 +72,15 @@ def test_en_for_nil_values
end
end

# We should avoid using the key `zero:` in English, since that key
# is used for "numbers ending in zero" in other languages.
def test_en_for_zero_key
en = YAML.load_file(Rails.root.join("config/locales/en.yml"))
assert_nothing_raised do
check_keys_for_zero(en)
end
end

private

def translation_keys(scope = nil)
Expand Down Expand Up @@ -119,4 +128,14 @@ def check_values_for_nil(hash)
end
end
end

def check_keys_for_zero(hash)
hash.each_pair do |k, v|
if v.is_a? Hash
check_keys_for_zero(v)
else
raise "Avoid using 'zero' key in '#{k}: #{v}'" if k.to_s == "zero"
end
end
end
end

0 comments on commit 62c68b9

Please sign in to comment.