Fully internationalise the issues and reports interfaces.

This commit is contained in:
Andy Allan 2018-01-22 11:56:39 +00:00
parent ae44879213
commit 79bd1777ab
8 changed files with 79 additions and 43 deletions

View file

@ -8,6 +8,8 @@ class IssuesController < ApplicationController
before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore] before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore]
def index def index
@title = t ".title"
if current_user.moderator? if current_user.moderator?
@issue_types = @moderator_issues @issue_types = @moderator_issues
@users = User.joins(:roles).where(:user_roles => { :role => "moderator" }) @users = User.joins(:roles).where(:user_roles => { :role => "moderator" })
@ -24,7 +26,7 @@ class IssuesController < ApplicationController
if @find_user if @find_user
@issues = @issues.where(:reported_user_id => @find_user.id) @issues = @issues.where(:reported_user_id => @find_user.id)
else else
notice = t("issues.index.search.user_not_found") notice = t("issues.index.user_not_found")
end end
end end

View file

@ -8,7 +8,7 @@
<%= comment.body %> <%= comment.body %>
</div> </div>
<span class="deemphasize"> <span class="deemphasize">
On <%= l comment.created_at.to_datetime, :format => :friendly %> <%= t(".created_at", :datetime => l(comment.created_at.to_datetime, :format => :friendly)) %>
</span> </span>
<hr> <hr>
<% end %> <% end %>

View file

@ -3,13 +3,13 @@
<div style="float:left"> <div style="float:left">
<%= link_to user_thumbnail(report.user), :controller => :user, :action =>:view, :display_name => report.user.display_name %> <%= link_to user_thumbnail(report.user), :controller => :user, :action =>:view, :display_name => report.user.display_name %>
</div> </div>
Reported by <b><%= link_to report.user.display_name, :controller => :user, :action =>:view, :display_name => report.user.display_name %></b> <br/> <%= t(".reported_by_html", :user_name => report.user.display_name, :user_url => url_for(:controller => :user, :action => :view, :display_name => report.user.display_name)) %> <br/>
<span class="deemphasize"> <span class="deemphasize">
On <%= l report.updated_at.to_datetime, :format => :friendly %> <%= t(".updated_at", :datetime => l(report.updated_at.to_datetime, :format => :friendly)) %>
</span> </span>
<br/> <br/>
<span class="deemphasize"> <span class="deemphasize">
Category: <%= report.category %> <%= t ".category", category: report.category %>
</span> </span>
<br/> <br/>
<%= report.details %> <%= report.details %>

View file

@ -1,19 +1,19 @@
<% content_for :heading do %> <% content_for :heading do %>
<h1>List of issues:</h1> <h1><%= t ".title" %></h1>
<% end %> <% end %>
<%= form_tag(issues_path, :method => :get) do %> <%= form_tag(issues_path, :method => :get) do %>
Search for a particular issue(s): <br/> <p><%= t ".search_guidance" %></p>
<%= select :status, nil, [['open', 0],['resolved',2],['ignored',1]],{:include_blank => "Select status"},data: { behavior: 'category_dropdown' } %> <%= select :status, nil, [['open', 0], ['resolved', 2], ['ignored', 1]], { :include_blank => t(".select_status")}, data: { behavior: 'category_dropdown' } %>
<%= select :issue_type, nil, @issue_types,{:include_blank => "Select type"}, data: { behavior: 'category_dropdown' } %> <%= select :issue_type, nil, @issue_types, { :include_blank => t(".select_type")}, data: { behavior: 'category_dropdown' } %>
<%= text_field_tag :search_by_user, params[:search_by_user], placeholder: "Reported User" %> <%= text_field_tag :search_by_user, params[:search_by_user], placeholder: t(".reported_user") %>
<%= select :last_reported_by, nil, @users.all.collect {|f| [f.display_name, f.id]} << ['Not updated',"nil"], {:include_blank => "Select last updated by"}, data: { behavior: 'category_dropdown' } %> <%= select :last_reported_by, nil, @users.all.collect {|f| [f.display_name, f.id]} << [ t(".not_updated"), "nil"], { :include_blank => t(".select_last_updated_by")}, data: { behavior: 'category_dropdown' } %>
<%= submit_tag "Search" %> <%= submit_tag t(".search") %>
<% end %> <% end %>
<br/> <br/>
<% if @issues.length == 0 %> <% if @issues.length == 0 %>
<p><%= t ".search.issues_not_found" %></p> <p><%= t ".issues_not_found" %></p>
<% end %> <% end %>
<br/> <br/>
@ -21,13 +21,13 @@ Search for a particular issue(s): <br/>
<table> <table>
<thead> <thead>
<tr> <tr>
<td><b>Status</b></td> <td><b><%= t ".status" %></b></td>
<td><b>Number of Reports</b></td> <td><b><%= t ".number_of_reports" %></b></td>
<td><b>Last updated at</b></td> <td><b><%= t ".last_updated_at" %></b></td>
<td><b>Last updated by</b></td> <td><b><%= t ".last_updated_by" %></b></td>
<td><b>Link to reports</b></td> <td><b><%= t ".link_to_reports" %></b></td>
<td><b>Reported User</b></td> <td><b><%= t ".reported_user" %></b></td>
<td><b>Link to reported instance</b></td> <td><b><%= t ".link_to_reported_instance" %></b></td>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>

View file

@ -1,13 +1,13 @@
<% content_for :heading do %> <% content_for :heading do %>
<h2> <%= @issue.status.humanize %> Issue #<%= @issue.id %> <br/></h2> <h2><%= t ".title", :status => @issue.status.humanize, :issue_id => @issue.id %></h2>
<p><%= report_type(@issue.reportable_type) %> : <%= reportable_url(@issue.reportable) %></p> <p><%= report_type(@issue.reportable_type) %> : <%= reportable_url(@issue.reportable) %></p>
<p class="deemphasize"> <p class="deemphasize">
<small> <small>
<%= @issue.assigned_role %> <%= @issue.assigned_role %>
| <%= @issue.reports.count %> reports | <%= t ".reports", :count => @issue.reports.count %>
| First reported: <%= l @issue.created_at.to_datetime, :format => :friendly %> | <%= t ".report_created_at", :datetime => l(@issue.created_at.to_datetime, :format => :friendly) %>
<%= "| Last resolved at #{l(@issue.resolved_at.to_datetime, :format =>:friendly)}" if @issue.resolved_at? %> <%= " | " + t(".last_resolved_at", :datetime => l(@issue.resolved_at.to_datetime, :format =>:friendly)) if @issue.resolved_at? %>
<%= "| Last updated at #{l(@issue.updated_at.to_datetime, :format => :friendly)} by #{@issue.user_updated.display_name}" if @issue.user_updated %> <%= " | " + t(".last_updated_at", :datetime => l(@issue.updated_at.to_datetime, :format => :friendly), :displayname => @issue.user_updated.display_name ) if @issue.user_updated %>
</small> </small>
</p> </p>
<p> <p>
@ -22,28 +22,26 @@
<div class="report-related-block"> <div class="report-related-block">
<div class="report-block"> <div class="report-block">
<h3>Reports under this issue:</h3> <h3><%= t ".reports_of_this_issue" %></h3>
<% if @read_reports.present? %> <% if @read_reports.present? %>
<div class="read-reports"> <div class="read-reports">
<h4>Read Reports:</h4> <h4><%= t ".read_reports" %></h4>
<br/> <%= render 'reports', reports: @read_reports %>
<%= render 'reports',reports: @read_reports %>
</div> </div>
<% end %> <% end %>
<% if @unread_reports.any? %> <% if @unread_reports.any? %>
<div class="unread-reports"> <div class="unread-reports">
<h4>New Reports:</h4> <h4><%= t ".new_reports" %></h4>
<br/> <%= render 'reports', reports: @unread_reports %>
<%= render 'reports',reports: @unread_reports %>
</div> </div>
<% end %> <% end %>
<br/> <br/>
</div> </div>
<div class="related-block"> <div class="related-block">
<h3> Other issues against this user: </h3> <h3><%= t ".other_issues_against_this_user" %></h3>
<div class="unread-reports"> <div class="unread-reports">
<% if @related_issues.count > 1 %> <% if @related_issues.count > 1 %>
<% @related_issues.each do |issue| %> <% @related_issues.each do |issue| %>
@ -52,13 +50,13 @@
<% end %> <% end %>
<% end %> <% end %>
<% else %> <% else %>
<p>No other reports against this user!</p> <p><%= t ".no_other_issues" %></p>
<% end %> <% end %>
</div> </div>
</div> </div>
</div> </div>
<h3>Comments on this issue:</h3> <h3><%= t ".comments_on_this_issue" %></h3>
<div class="unread-reports"> <div class="unread-reports">
<%= render 'comments', comments: @comments %> <%= render 'comments', comments: @comments %>
</div> </div>

View file

@ -1,5 +1,5 @@
<% content_for :heading do %> <% content_for :heading do %>
<h1>Report <%= reportable_url(@report.issue.reportable) %></h1> <h1><%= t ".title_html", :link => reportable_url(@report.issue.reportable) %></h1>
<% end %> <% end %>
<div class="disclaimer"> <div class="disclaimer">

View file

@ -914,9 +914,23 @@ en:
ignore: Ignore ignore: Ignore
reopen: Reopen reopen: Reopen
index: index:
search: title: Issues
user_not_found: User does not exist select_status: Select Status
issues_not_found: No such issues found select_type: Select Type
select_last_updated_by: Select Last Updated By
reported_user: Reported User
not_updated: Not Updated
search: Search
search_guidance: "Search Issues:"
user_not_found: User does not exist
issues_not_found: No such issues found
status: Status
number_of_reports: Number of Reports
last_updated_at: Last Updated At
last_updated_by: Last Updated By
link_to_reports: Link to Reports
reported_user: Reported User
link_to_reported_instance: Link to Reported Instance
create: create:
successful_report: Your report has been registered sucessfully successful_report: Your report has been registered sucessfully
provide_details: Please provide the required details provide_details: Please provide the required details
@ -933,15 +947,37 @@ en:
unable_to_fix: You are unable to fix the problem yourself unable_to_fix: You are unable to fix the problem yourself
resolve_with_user: You have tried to resolve the problem with the user resolve_with_user: You have tried to resolve the problem with the user
show: show:
title: "%{status} Issue #%{issue_id}"
reports:
zero: No reports
one: 1 report
other: "%{count} reports"
report_created_at: "First reported at %{datetime}"
last_resolved_at: "Last resolved at %{datetime}"
last_updated_at: "Last updated at %{datetime} by %{displayname}"
reports_of_this_issue: Reports of this Issue
read_reports: Read Reports
new_reports: New Reports
other_issues_against_this_user: Other issues against this user
no_other_issues: No other issues against this user.
comments_on_this_issue: Comments on this issue
comments: comments:
reassign_param: Reassign Issue? reassign_param: Reassign Issue?
comment: comment:
provide_details: Please provide the required details provide_details: Please provide the required details
comment_created: Your comment was successfully created comment_created: Your comment was successfully created
comments:
created_at: "On %{datetime}"
reports:
category: "Category: %{category}"
updated_at: "On %{datetime}"
reported_by_html: "Reported by <a href=\"%{user_url}\">%{user_name}</a>"
resolved: Issue status has been set to 'Resolved' resolved: Issue status has been set to 'Resolved'
ignored: Issue status has been set to 'Ignored' ignored: Issue status has been set to 'Ignored'
reopened: Issue status has been set to 'Open' reopened: Issue status has been set to 'Open'
reports: reports:
new:
title_html: "Report %{link}"
categories: categories:
DiaryEntry: DiaryEntry:
spam: This Diary Entry is/contains spam spam: This Diary Entry is/contains spam

View file

@ -12,7 +12,7 @@ class IssuesTest < ApplicationSystemTestCase
sign_in_as(create(:moderator_user)) sign_in_as(create(:moderator_user))
visit issues_path visit issues_path
assert page.has_content?(I18n.t(".issues.index.search.issues_not_found")) assert page.has_content?(I18n.t(".issues.index.issues_not_found"))
end end
def test_view_issues def test_view_issues
@ -34,19 +34,19 @@ class IssuesTest < ApplicationSystemTestCase
visit issues_path visit issues_path
fill_in "search_by_user", :with => good_user.display_name fill_in "search_by_user", :with => good_user.display_name
click_on "Search" click_on "Search"
assert page.has_content?(I18n.t(".issues.index.search.issues_not_found")) assert page.has_content?(I18n.t(".issues.index.issues_not_found"))
# User doesn't exist # User doesn't exist
visit issues_path visit issues_path
fill_in "search_by_user", :with => "Nonexistant User" fill_in "search_by_user", :with => "Nonexistant User"
click_on "Search" click_on "Search"
assert page.has_content?(I18n.t(".issues.index.search.user_not_found")) assert page.has_content?(I18n.t(".issues.index.user_not_found"))
# Find Issue against bad_user # Find Issue against bad_user
visit issues_path visit issues_path
fill_in "search_by_user", :with => bad_user.display_name fill_in "search_by_user", :with => bad_user.display_name
click_on "Search" click_on "Search"
assert !page.has_content?(I18n.t(".issues.index.search.issues_not_found")) assert !page.has_content?(I18n.t(".issues.index.issues_not_found"))
end end
def test_commenting def test_commenting