]> git.openstreetmap.org Git - rails.git/commitdiff
Use lazy lookups for translations in issues
authorTom Hughes <tom@compton.nu>
Sun, 10 Jun 2018 15:03:38 +0000 (16:03 +0100)
committerTom Hughes <tom@compton.nu>
Sun, 10 Jun 2018 15:59:58 +0000 (16:59 +0100)
13 files changed:
app/controllers/issue_comments_controller.rb
app/controllers/issues_controller.rb
app/controllers/reports_controller.rb
app/views/issues/_comments.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
test/system/report_diary_comment_test.rb
test/system/report_diary_entry_test.rb
test/system/report_note_test.rb
test/system/report_user_test.rb

index 42ae850ba24a039594ee3a9cb9cc6bccea4c5270..52904d5b2b869550d6c0cc2c254c033b8277c573 100644 (file)
@@ -10,7 +10,7 @@ class IssueCommentsController < ApplicationController
     comment = @issue.comments.build(issue_comment_params)
     comment.user = current_user
     comment.save!
-    notice = t("issues.comment.comment_created")
+    notice = t(".comment_created")
     reassign_issue(@issue) if params[:reassign]
     redirect_to @issue, :notice => notice
   end
index a8eeee8b383f43889a21d7787d3f00488b991ad3..72952894624195f734efc61925c363492a458c22 100644 (file)
@@ -23,7 +23,7 @@ class IssuesController < ApplicationController
         @issues = @issues.where(:reported_user_id => @find_user.id)
       else
         @issues = @issues.none
-        flash.now[:warning] = t("issues.index.user_not_found")
+        flash.now[:warning] = t(".user_not_found")
       end
     end
 
@@ -49,7 +49,7 @@ class IssuesController < ApplicationController
   def resolve
     if @issue.resolve
       @issue.save!
-      redirect_to @issue, :notice => t("issues.resolved")
+      redirect_to @issue, :notice => t(".resolved")
     else
       render :show
     end
@@ -59,7 +59,7 @@ class IssuesController < ApplicationController
     if @issue.ignore
       @issue.updated_by = current_user.id
       @issue.save!
-      redirect_to @issue, :notice => t("issues.ignored")
+      redirect_to @issue, :notice => t(".ignored")
     else
       render :show
     end
@@ -69,7 +69,7 @@ class IssuesController < ApplicationController
     if @issue.reopen
       @issue.updated_by = current_user.id
       @issue.save!
-      redirect_to @issue, :notice => t("issues.reopened")
+      redirect_to @issue, :notice => t(".reopened")
     else
       render :show
     end
index 8a1bed50848785510dadb6e902e0441430ef7caf..95c9343e63685dea0d49ad21bccc29e9bc98a98b 100644 (file)
@@ -9,7 +9,7 @@ class ReportsController < ApplicationController
       @report = Report.new
       @report.issue = Issue.find_or_initialize_by(create_new_report_params)
     else
-      redirect_to root_path, :notice => t("reports.new.missing_params")
+      redirect_to root_path, :notice => t(".missing_params")
     end
   end
 
@@ -20,9 +20,9 @@ class ReportsController < ApplicationController
     if @report.save
       @report.issue.save
       @report.issue.reopen! unless @report.issue.open?
-      redirect_to helpers.reportable_url(@report.issue.reportable), :notice => t("issues.create.successful_report")
+      redirect_to helpers.reportable_url(@report.issue.reportable), :notice => t(".successful_report")
     else
-      redirect_to new_report_path(:reportable_type => @report.issue.reportable_type, :reportable_id => @report.issue.reportable_id), :notice => t("issues.create.provide_details")
+      redirect_to new_report_path(:reportable_type => @report.issue.reportable_type, :reportable_id => @report.issue.reportable_id), :notice => t(".provide_details")
     end
   end
 
index e423714659a80285d6508059861e63b2d8301aac..4b5ae4a8f471c3fb44a178b32f5a3224805a656b 100644 (file)
@@ -17,7 +17,7 @@
 <div class="comment">
   <%= form_for @new_comment, url: issue_comments_path(@issue) do |f| %>
   <%= richtext_area :issue_comment, :body, :cols => 10, :rows => 8, :required => true %>
-  <%= label_tag :reassign, t('issues.show.comments.reassign_param') %> <%= check_box_tag :reassign, true %>
+  <%= label_tag :reassign, t('.reassign_param') %> <%= check_box_tag :reassign, true %>
   <br/>
   <br/>
   <%= submit_tag 'Submit' %>
index 510cb4e0d13b1b60c9a09ead2bfdd36a92ad8f93..e5e7ebc001113fa7b0ed266f4f2949c73a7e771d 100644 (file)
@@ -4,7 +4,7 @@
 
 <%= form_tag(issues_path, :method => :get) do %>
 <p><%= t ".search_guidance" %></p>
-<%= select_tag :status, options_for_select(Issue.aasm.states.map(&:name).map{|state| [t("issues.states.#{state}"), state]}, params[:status]), :include_blank => t(".select_status"), :data => { :behavior => 'category_dropdown' } %>
+<%= select_tag :status, options_for_select(Issue.aasm.states.map(&:name).map{|state| [t(".states.#{state}"), state]}, params[:status]), :include_blank => t(".select_status"), :data => { :behavior => 'category_dropdown' } %>
 <%= select_tag :issue_type, options_for_select(@issue_types, params[:issue_type]), :include_blank => t(".select_type"), :data => { :behavior => 'category_dropdown' } %>
 <%= text_field_tag :search_by_user, params[:search_by_user], placeholder: t(".reported_user") %>
 <%= select_tag :last_updated_by, options_for_select(@users.all.collect{|f| [f.display_name, f.id]} << [ t(".not_updated"), "nil"], params[:last_updated_by]), :include_blank => t(".select_last_updated_by"), :data => { :behavior => 'category_dropdown' } %>
@@ -31,7 +31,7 @@
   <tbody>
     <% @issues.each do |issue| %>
       <tr>
-        <td><%= t "issues.states.#{issue.status}" %></td>
+        <td><%= t ".states.#{issue.status}" %></td>
         <td><%= link_to t(".reports_count", :count => issue.reports_count), issue %></td>
         <td><%= link_to reportable_title(issue.reportable), reportable_url(issue.reportable) %></td>
         <td><%= link_to issue.reported_user.display_name, user_path(issue.reported_user.display_name) if issue.reported_user %></td>
index 44b39c927900e31a23338e417ec9bc9171423e8a..6612f069b24d6b01e36c7c6ef814ac36786e834d 100644 (file)
   </small>
 </p>
 <p>
-  <%= link_to t('issues.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %>
+  <%= link_to t('.resolve'), resolve_issue_url(@issue), :method => :post if @issue.may_resolve? %>
   <% if @issue.may_ignore? %>
-  | <%= link_to t('issues.ignore'), ignore_issue_url(@issue), :method => :post %>
+  | <%= link_to t('.ignore'), ignore_issue_url(@issue), :method => :post %>
   <% end %>
 </p>
-<p><%= link_to t('issues.reopen'), reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %></p>
+<p><%= link_to t('.reopen'), reopen_issue_url(@issue), :method => :post if @issue.may_reopen? %></p>
 <% end %>
 
 <div class="report-related-block">
index e5ac6373fc7eb008d515b8b6466f7048d4e4cf8c..7023667fe7317737428ccbeb69ed7ce3cfbb82ec 100644 (file)
@@ -3,11 +3,11 @@
 <% end %>
 
 <div class="report-disclaimer">
-  <%= t('issues.new.disclaimer.intro') %>
+  <%= t('.disclaimer.intro') %>
   <ul>
-    <li> <%= t('issues.new.disclaimer.not_just_mistake') %> </li>
-    <li> <%= t('issues.new.disclaimer.unable_to_fix') %> </li>
-    <li> <%= t('issues.new.disclaimer.resolve_with_user') %> </li>
+    <li> <%= t('.disclaimer.not_just_mistake') %> </li>
+    <li> <%= t('.disclaimer.unable_to_fix') %> </li>
+    <li> <%= t('.disclaimer.resolve_with_user') %> </li>
   </ul>
 </div>
 
     <% end %>
 
     <div class='form-row'>
-      <p><%= t('issues.new.select') %></p>
+      <p><%= t('.select') %></p>
       <ul>
       <% Report.categories_for(@report.issue.reportable).each do |c| %>
         <li>
           <%= radio_button :report, :category, c %>
-          <%= label_tag "report_category_#{c}", t("reports.categories.#{@report.issue.reportable.class.name.underscore}.#{c}") %> <br/>
+          <%= label_tag "report_category_#{c}", t(".categories.#{@report.issue.reportable.class.name.underscore}.#{c}") %> <br/>
         </li>
       <% end %>
       </ul>
     </div>
 
     <div class='form-row'>
-      <%= text_area :report, :details, :cols => 20, :rows => 5, placeholder: t('issues.new.details'), required: true %>
+      <%= text_area :report, :details, :cols => 20, :rows => 5, placeholder: t('.details'), required: true %>
     </div>
 
     <div class='buttons'>
index 18ea59bf4f4638ca26015ad6382f3c558fec4594..9bb423857e8f02814dc3da5ea30b6e5efa64803a 100644 (file)
@@ -963,10 +963,6 @@ en:
       no_results: "No results found"
       more_results: "More results"
   issues:
-    report: Report
-    resolve: Resolve
-    ignore: Ignore
-    reopen: Reopen
     index:
       title: Issues
       select_status: Select Status
@@ -989,21 +985,14 @@ en:
         one: "1 Report"
         other: "%{count} Reports"
       reported_item: Reported Item
-    create:
-      successful_report: Your report has been registered sucessfully
-      provide_details: Please provide the required details
+      states:
+        ignored: Ignored
+        open: Open
+        resolved: Resolved
     update:
       new_report: Your report has been registered sucessfully
       successful_update: Your report has been updated successfully
       provide_details: Please provide the required details
-    new:
-      details: Please provide some more details about the problem (required).
-      select: "Select a reason for your report:"
-      disclaimer:
-        intro: "Before sending your report to the site moderators, please ensure that:"
-        not_just_mistake: You are certain that the problem is not just a mistake
-        unable_to_fix: You are unable to fix the problem yourself or with the help of your fellow community members
-        resolve_with_user: You have already tried to resolve the problem with the user concerned
     show:
       title: "%{status} Issue #%{issue_id}"
       reports:
@@ -1013,55 +1002,66 @@ en:
       report_created_at: "First reported at %{datetime}"
       last_resolved_at: "Last resolved at %{datetime}"
       last_updated_at: "Last updated at %{datetime} by %{displayname}"
+      resolve: Resolve
+      ignore: Ignore
+      reopen: Reopen
       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
+    resolve:
+      resolved: Issue status has been set to 'Resolved'
+    ignore:
+      ignored: Issue status has been set to 'Ignored'
+    reopen:
+      reopened: Issue status has been set to 'Open'
     comments:
       created_at: "On %{datetime}"
+      reassign_param: Reassign Issue?
     reports:
       updated_at: "On %{datetime}"
       reported_by_html: "Reported as %{category} by %{user}"
-    resolved: Issue status has been set to 'Resolved'
-    ignored: Issue status has been set to 'Ignored'
-    reopened: Issue status has been set to 'Open'
-    states:
-      ignored: Ignored
-      open: Open
-      resolved: Resolved
+  issue_comments:
+    create:
+      comment_created: Your comment was successfully created
   reports:
     new:
       title_html: "Report %{link}"
       missing_params: "Cannot create a new report"
-    categories:
-      diary_entry:
-        spam: This diary entry is/contains spam
-        offensive: This diary entry is obscene/offensive
-        threat: This diary entry contains a threat
-        other: Other
-      diary_comment:
-        spam: This diary comment is/contains spam
-        offensive: This diary comment is obscene/offensive
-        threat: This diary comment contains a threat
-        other: Other
-      user:
-        spam: This user profile is/contains spam
-        offensive: This user profile is obscene/offensive
-        threat: This user profile contains a threat
-        vandal: This user is a vandal
-        other: Other
-      note:
-        spam: This note is spam
-        personal: This note contains personal data
-        abusive: This note is abusive
-        other: Other
+      details: Please provide some more details about the problem (required).
+      select: "Select a reason for your report:"
+      disclaimer:
+        intro: "Before sending your report to the site moderators, please ensure that:"
+        not_just_mistake: You are certain that the problem is not just a mistake
+        unable_to_fix: You are unable to fix the problem yourself or with the help of your fellow community members
+        resolve_with_user: You have already tried to resolve the problem with the user concerned
+      categories:
+        diary_entry:
+          spam: This diary entry is/contains spam
+          offensive: This diary entry is obscene/offensive
+          threat: This diary entry contains a threat
+          other: Other
+        diary_comment:
+          spam: This diary comment is/contains spam
+          offensive: This diary comment is obscene/offensive
+          threat: This diary comment contains a threat
+          other: Other
+        user:
+          spam: This user profile is/contains spam
+          offensive: This user profile is obscene/offensive
+          threat: This user profile contains a threat
+          vandal: This user is a vandal
+          other: Other
+        note:
+          spam: This note is spam
+          personal: This note contains personal data
+          abusive: This note is abusive
+          other: Other
+    create:
+      successful_report: Your report has been registered sucessfully
+      provide_details: Please provide the required details      
   layouts:
     project_name:
       # in <title>
index 20002917680d70da8ceb0ad3fb89bca48acba4bc..5e60ee0f0c6f6b5448c43ee562cd5534b2fe7040 100644 (file)
@@ -19,7 +19,7 @@ class IssuesTest < ApplicationSystemTestCase
     sign_in_as(create(:moderator_user))
 
     visit issues_path
-    assert page.has_content?(I18n.t(".issues.index.issues_not_found"))
+    assert page.has_content?(I18n.t("issues.index.issues_not_found"))
   end
 
   def test_view_issues
@@ -53,19 +53,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.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.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.issues_not_found"))
+    assert !page.has_content?(I18n.t("issues.index.issues_not_found"))
   end
 
   def test_commenting
@@ -76,7 +76,7 @@ class IssuesTest < ApplicationSystemTestCase
 
     fill_in :issue_comment_body, :with => "test comment"
     click_on "Submit"
-    assert page.has_content?(I18n.t(".issues.comment.comment_created"))
+    assert page.has_content?(I18n.t("issue_comments.create.comment_created"))
     assert page.has_content?("test comment")
 
     issue.reload
@@ -110,7 +110,7 @@ class IssuesTest < ApplicationSystemTestCase
 
     visit issues_path
 
-    assert page.has_link?(I18n.t(".issues.index.reports_count", :count => issue1.reports_count), :href => issue_path(issue1))
-    assert page.has_link?(I18n.t(".issues.index.reports_count", :count => issue2.reports_count), :href => issue_path(issue2))
+    assert page.has_link?(I18n.t("issues.index.reports_count", :count => issue1.reports_count), :href => issue_path(issue1))
+    assert page.has_link?(I18n.t("issues.index.reports_count", :count => issue2.reports_count), :href => issue_path(issue2))
   end
 end
index 8b709195d81c12745270d4d112766b7741655ac5..05b76f695aeb6eaf230397b69567cf83b8d288f7 100644 (file)
@@ -21,9 +21,9 @@ class ReportDiaryCommentTest < ApplicationSystemTestCase
 
     click_on I18n.t("diary_entry.diary_comment.report")
     assert page.has_content? "Report"
-    assert page.has_content? I18n.t("issues.new.disclaimer.intro")
+    assert page.has_content? I18n.t("reports.new.disclaimer.intro")
 
-    choose I18n.t("reports.categories.diary_comment.spam")
+    choose I18n.t("reports.new.categories.diary_comment.spam")
     fill_in "report_details", :with => "This comment is spam"
     click_on "Create Report"
 
index 570fbb1de59503fc0f9c5c6b7085292d0d80bc65..86d301e3c5edfca2a157e0f15a742bbdc0148fae 100644 (file)
@@ -20,9 +20,9 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
 
     click_on I18n.t("diary_entry.diary_entry.report")
     assert page.has_content? "Report"
-    assert page.has_content? I18n.t("issues.new.disclaimer.intro")
+    assert page.has_content? I18n.t("reports.new.disclaimer.intro")
 
-    choose I18n.t("reports.categories.diary_entry.spam")
+    choose I18n.t("reports.new.categories.diary_entry.spam")
     fill_in "report_details", :with => "This is advertising"
     click_on "Create Report"
 
@@ -39,9 +39,9 @@ class ReportDiaryEntryTest < ApplicationSystemTestCase
 
     click_on I18n.t("diary_entry.diary_entry.report")
     assert page.has_content? "Report"
-    assert page.has_content? I18n.t("issues.new.disclaimer.intro")
+    assert page.has_content? I18n.t("reports.new.disclaimer.intro")
 
-    choose I18n.t("reports.categories.diary_entry.spam")
+    choose I18n.t("reports.new.categories.diary_entry.spam")
     fill_in "report_details", :with => "This is advertising"
     click_on "Create Report"
 
index c5a70b488fc8807c599916edfe8a2b80a801d207..f885888349a709a3c3c63d968ecd7ddf87273e57 100644 (file)
@@ -16,9 +16,9 @@ class ReportNoteTest < ApplicationSystemTestCase
 
     click_on I18n.t("browse.note.report")
     assert page.has_content? "Report"
-    assert page.has_content? I18n.t("issues.new.disclaimer.intro")
+    assert page.has_content? I18n.t("reports.new.disclaimer.intro")
 
-    choose I18n.t("reports.categories.note.spam")
+    choose I18n.t("reports.new.categories.note.spam")
     fill_in "report_details", :with => "This is spam"
     click_on "Create Report"
 
@@ -35,9 +35,9 @@ class ReportNoteTest < ApplicationSystemTestCase
 
     click_on I18n.t("browse.note.report")
     assert page.has_content? "Report"
-    assert page.has_content? I18n.t("issues.new.disclaimer.intro")
+    assert page.has_content? I18n.t("reports.new.disclaimer.intro")
 
-    choose I18n.t("reports.categories.note.spam")
+    choose I18n.t("reports.new.categories.note.spam")
     fill_in "report_details", :with => "This is spam"
     click_on "Create Report"
 
index dc6c511753af073555fd1a2458363508f652ce30..0331e3ad73a936d50c9dbf5690b0a4b81a20abea 100644 (file)
@@ -16,9 +16,9 @@ class ReportUserTest < ApplicationSystemTestCase
 
     click_on I18n.t("user.view.report")
     assert page.has_content? "Report"
-    assert page.has_content? I18n.t("issues.new.disclaimer.intro")
+    assert page.has_content? I18n.t("reports.new.disclaimer.intro")
 
-    choose I18n.t("reports.categories.user.vandal")
+    choose I18n.t("reports.new.categories.user.vandal")
     fill_in "report_details", :with => "This user is a vandal"
     click_on "Create Report"