Fully internationalise the issues and reports interfaces.
authorAndy Allan <git@gravitystorm.co.uk>
Mon, 22 Jan 2018 11:56:39 +0000 (11:56 +0000)
committerAndy Allan <git@gravitystorm.co.uk>
Mon, 22 Jan 2018 11:57:08 +0000 (11:57 +0000)
app/controllers/issues_controller.rb
app/views/issues/_comments.html.erb
app/views/issues/_reports.html.erb
app/views/issues/index.html.erb
app/views/issues/show.html.erb
app/views/reports/new.html.erb
config/locales/en.yml
test/system/issues_test.rb

index b46794d..75eb3dd 100644 (file)
@@ -8,6 +8,8 @@ class IssuesController < ApplicationController
   before_action :find_issue, :only => [:show, :resolve, :reopen, :ignore]
 
   def index
+    @title = t ".title"
+
     if current_user.moderator?
       @issue_types = @moderator_issues
       @users = User.joins(:roles).where(:user_roles => { :role => "moderator" })
@@ -24,7 +26,7 @@ class IssuesController < ApplicationController
       if @find_user
         @issues = @issues.where(:reported_user_id => @find_user.id)
       else
-        notice = t("issues.index.search.user_not_found")
+        notice = t("issues.index.user_not_found")
       end
     end
 
index d49ae86..ec885aa 100644 (file)
@@ -8,7 +8,7 @@
       <%= comment.body %>
     </div>
     <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>
     <hr>
   <% end %>
index 9f180d1..5303ae0 100644 (file)
@@ -3,13 +3,13 @@
     <div style="float:left">
       <%= link_to user_thumbnail(report.user), :controller => :user, :action =>:view, :display_name => report.user.display_name %>
     </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">
-      On <%= l report.updated_at.to_datetime, :format => :friendly %>
+      <%= t(".updated_at", :datetime => l(report.updated_at.to_datetime, :format => :friendly)) %>
     </span>
     <br/>
     <span class="deemphasize">
-      Category: <%= report.category %>
+      <%= t ".category", category: report.category %>
     </span>
     <br/>
     <%= report.details %>
index 431158c..4a6cf3c 100644 (file)
@@ -1,19 +1,19 @@
 <% content_for :heading do %>
-  <h1>List of issues:</h1>
+  <h1><%= t ".title" %></h1>
 <% end %>
 
 <%= form_tag(issues_path, :method => :get) do %>
-Search for a particular issue(s):  <br/>
-<%= select :status, nil, [['open', 0],['resolved',2],['ignored',1]],{:include_blank => "Select status"},data: { behavior: 'category_dropdown' } %>
-<%= select :issue_type, nil, @issue_types,{:include_blank => "Select type"}, data: { behavior: 'category_dropdown' } %>
-<%= text_field_tag :search_by_user, params[:search_by_user], placeholder: "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' } %>
-<%= submit_tag "Search" %>
+<p><%= t ".search_guidance" %></p>
+<%= 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 => t(".select_type")}, data: { behavior: 'category_dropdown' } %>
+<%= 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]} << [ t(".not_updated"), "nil"], { :include_blank => t(".select_last_updated_by")}, data: { behavior: 'category_dropdown' } %>
+<%= submit_tag t(".search") %>
 <% end %>
 <br/>
 
 <% if @issues.length == 0 %>
-  <p><%= t ".search.issues_not_found" %></p>
+  <p><%= t ".issues_not_found" %></p>
 <% end %>
 
 <br/>
@@ -21,13 +21,13 @@ Search for a particular issue(s):  <br/>
 <table>
   <thead>
     <tr>
-      <td><b>Status</b></td>
-      <td><b>Number of Reports</b></td>
-      <td><b>Last updated at</b></td>
-      <td><b>Last updated by</b></td>
-      <td><b>Link to reports</b></td>
-      <td><b>Reported User</b></td>
-      <td><b>Link to reported instance</b></td>
+      <td><b><%= t ".status" %></b></td>
+      <td><b><%= t ".number_of_reports" %></b></td>
+      <td><b><%= t ".last_updated_at" %></b></td>
+      <td><b><%= t ".last_updated_by" %></b></td>
+      <td><b><%= t ".link_to_reports" %></b></td>
+      <td><b><%= t ".reported_user" %></b></td>
+      <td><b><%= t ".link_to_reported_instance" %></b></td>
     </tr>
   </thead>
   <tbody>
index 5ce3bf1..3bef038 100644 (file)
@@ -1,13 +1,13 @@
 <% 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 class="deemphasize">
   <small>
     <%= @issue.assigned_role %>
-    | <%= @issue.reports.count %> reports
-    | First reported: <%= l @issue.created_at.to_datetime, :format => :friendly %>
-    <%= "| Last resolved at #{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 ".reports", :count => @issue.reports.count %>
+    | <%= 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 %>
   </small>
 </p>
 <p>
 <div class="report-related-block">
 
   <div class="report-block">
-    <h3>Reports under this issue:</h3>
+    <h3><%= t ".reports_of_this_issue" %></h3>
 
     <% if @read_reports.present? %>
     <div class="read-reports">
-      <h4>Read Reports:</h4>
-      <br/>
-      <%= render 'reports',reports: @read_reports %>
+      <h4><%= t ".read_reports" %></h4>
+      <%= render 'reports', reports: @read_reports %>
     </div>
     <% end %>
 
     <% if @unread_reports.any? %>
     <div class="unread-reports">
-      <h4>New Reports:</h4>
-      <br/>
-      <%= render 'reports',reports: @unread_reports %>
+      <h4><%= t ".new_reports" %></h4>
+      <%= render 'reports', reports: @unread_reports %>
     </div>
     <% end %>
     <br/>
   </div>
 
   <div class="related-block">
-    <h3> Other issues against this user: </h3>
+    <h3><%= t ".other_issues_against_this_user" %></h3>
     <div class="unread-reports">
       <% if @related_issues.count > 1 %>
         <% @related_issues.each do |issue| %>
           <% end %>
         <% end %>
       <% else %>
-        <p>No other reports against this user!</p>
+        <p><%= t ".no_other_issues" %></p>
       <% end %>
     </div>
   </div>
 </div>
 
-<h3>Comments on this issue:</h3>
+<h3><%= t ".comments_on_this_issue" %></h3>
 <div class="unread-reports">
   <%= render 'comments', comments: @comments %>
 </div>
index a39b5b1..705457c 100644 (file)
@@ -1,5 +1,5 @@
 <% content_for :heading do %>
-  <h1>Report <%= reportable_url(@report.issue.reportable) %></h1>
+  <h1><%= t ".title_html", :link => reportable_url(@report.issue.reportable) %></h1>
 <% end %>
 
 <div class="disclaimer">
index e68d445..fefa5a4 100644 (file)
@@ -914,9 +914,23 @@ en:
     ignore: Ignore
     reopen: Reopen
     index:
-      search:
-        user_not_found: User does not exist
-        issues_not_found: No such issues found
+      title: Issues
+      select_status: Select Status
+      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:
       successful_report: Your report has been registered sucessfully
       provide_details: Please provide the required details
@@ -933,15 +947,37 @@ en:
         unable_to_fix: You are unable to fix the problem yourself
         resolve_with_user: You have tried to resolve the problem with the user
     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:
         reassign_param: Reassign Issue?
     comment:
       provide_details: Please provide the required details
       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'
     ignored: Issue status has been set to 'Ignored'
     reopened: Issue status has been set to 'Open'
   reports:
+    new:
+      title_html: "Report %{link}"
     categories:
       DiaryEntry:
         spam: This Diary Entry is/contains spam
index 545074c..efe5236 100644 (file)
@@ -12,7 +12,7 @@ class IssuesTest < ApplicationSystemTestCase
     sign_in_as(create(:moderator_user))
 
     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
 
   def test_view_issues
@@ -34,19 +34,19 @@ class IssuesTest < ApplicationSystemTestCase
     visit issues_path
     fill_in "search_by_user", :with => good_user.display_name
     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
     visit issues_path
     fill_in "search_by_user", :with => "Nonexistant User"
     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
     visit issues_path
     fill_in "search_by_user", :with => bad_user.display_name
     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
 
   def test_commenting