I18n moderations (#301)
* translate moderation view, controller and model * support for i18n in the moderation controller * support for i18n in the moderation model - use interpolation for variables inside strings * support for i18n in controller model - localize time and date string format for printing time and date of the moderation action
This commit is contained in:
parent
a5d880f431
commit
9506b1ce10
|
@ -1,6 +1,6 @@
|
||||||
class ModerationsController < ApplicationController
|
class ModerationsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
@title = "Moderation Log"
|
@title = t('.moderationlogtitle')
|
||||||
|
|
||||||
@page = params[:page] ? params[:page].to_i : 0
|
@page = params[:page] ? params[:page].to_i : 0
|
||||||
@pages = (Moderation.count / 50).ceil
|
@pages = (Moderation.count / 50).ceil
|
||||||
|
|
|
@ -17,32 +17,29 @@ class Moderation < ActiveRecord::Base
|
||||||
|
|
||||||
if self.story
|
if self.story
|
||||||
m.recipient_user_id = self.story.user_id
|
m.recipient_user_id = self.story.user_id
|
||||||
m.subject = "Your story has been edited by " <<
|
m.subject = I18n.t('models.moderation.storyeditedby') <<
|
||||||
(self.is_from_suggestions? ? "user suggestions" : "a moderator")
|
(self.is_from_suggestions? ? I18n.t('models.moderation.usersuggestions') : I18n.t('models.moderation.amoderator'))
|
||||||
m.body = "Your story [#{self.story.title}](" <<
|
m.body = I18n.t('models.moderation.storyeditedfor', :title=> "#{self.story.title}", :url=> "#{self.story.comments_url}") <<
|
||||||
"#{self.story.comments_url}) has been edited with the following " <<
|
|
||||||
"changes:\n" <<
|
|
||||||
"\n" <<
|
"\n" <<
|
||||||
"> *#{self.action}*\n"
|
"> *#{self.action}*\n"
|
||||||
|
|
||||||
if self.reason.present?
|
if self.reason.present?
|
||||||
m.body << "\n" <<
|
m.body << "\n" <<
|
||||||
"The reason given:\n" <<
|
I18n.t('models.moderation.reasongiven') <<
|
||||||
"\n" <<
|
"\n" <<
|
||||||
"> *#{self.reason}*\n"
|
"> *#{self.reason}*\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
elsif self.comment
|
elsif self.comment
|
||||||
m.recipient_user_id = self.comment.user_id
|
m.recipient_user_id = self.comment.user_id
|
||||||
m.subject = "Your comment has been moderated"
|
m.subject = I18n.t('models.moderation.commentmoderated')
|
||||||
m.body = "Your comment on [#{self.comment.story.title}](" <<
|
m.body = I18n.t('models.moderation.commentmoderatedwhy', :title=> "#{self.comment.story.title}", :url=> "#{self.comment.story.comments_url}") <<
|
||||||
"#{self.comment.story.comments_url}) has been moderated:\n" <<
|
|
||||||
"\n" <<
|
"\n" <<
|
||||||
"> *#{self.comment.comment}*\n"
|
"> *#{self.comment.comment}*\n"
|
||||||
|
|
||||||
if self.reason.present?
|
if self.reason.present?
|
||||||
m.body << "\n" <<
|
m.body << "\n" <<
|
||||||
"The reason given:\n" <<
|
I18n.t('models.moderation.reasongiven') <<
|
||||||
"\n" <<
|
"\n" <<
|
||||||
"> *#{self.reason}*\n"
|
"> *#{self.reason}*\n"
|
||||||
end
|
end
|
||||||
|
@ -53,7 +50,7 @@ class Moderation < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
m.body << "\n" <<
|
m.body << "\n" <<
|
||||||
"*This is an automated message.*"
|
I18n.t('models.moderation.automatedmessage')
|
||||||
|
|
||||||
m.save
|
m.save
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
<div class="box wide">
|
<div class="box wide">
|
||||||
<div class="legend">
|
<div class="legend">
|
||||||
Moderation Log
|
<%= t('.moderationlogtitle') %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table class="data" width="100%" cellspacing=0>
|
<table class="data" width="100%" cellspacing=0>
|
||||||
<tr>
|
<tr>
|
||||||
<th style="min-width: 130px;">Date/Time</th>
|
<th style="min-width: 130px;"><%= t('.datecolumn') %></th>
|
||||||
<th>Moderator</th>
|
<th><%= t('.moderatorcolumn') %></th>
|
||||||
<th>Story/Comment/User, Action, Reason</th>
|
<th><%= t('.reasoncolumn') %></th>
|
||||||
</tr>
|
</tr>
|
||||||
<% bit = 0 %>
|
<% bit = 0 %>
|
||||||
<% @moderations.each do |mod| %>
|
<% @moderations.each do |mod| %>
|
||||||
<tr class="row<%= bit %> nobottom">
|
<tr class="row<%= bit %> nobottom">
|
||||||
<td><%= mod.created_at.strftime("%Y-%m-%d %H:%M:%S") %></td>
|
<td><%= l mod.created_at %></td>
|
||||||
<td><% if mod.moderator %>
|
<td><% if mod.moderator %>
|
||||||
<a href="/messages?to=<%= mod.moderator.try(:username) %>"><%=
|
<a href="/messages?to=<%= mod.moderator.try(:username) %>"><%=
|
||||||
mod.moderator.try(:username) %></a>
|
mod.moderator.try(:username) %></a>
|
||||||
<% elsif mod.is_from_suggestions? %>
|
<% elsif mod.is_from_suggestions? %>
|
||||||
<em>(users)</em>
|
<em>(<%= t('.users') %>)</em>
|
||||||
<% end %></td>
|
<% end %></td>
|
||||||
<td><% if mod.story %>
|
<td><% if mod.story %>
|
||||||
<a href="<%= mod.story.comments_path %>">Story: <%= mod.story.title
|
<a href="<%= mod.story.comments_path %>"><%= t('.storyline') %>: <%= mod.story.title
|
||||||
%></a>
|
%></a>
|
||||||
<% elsif mod.comment %>
|
<% elsif mod.comment %>
|
||||||
<a href="<%= mod.comment.url %>">Comment by
|
<a href="<%= mod.comment.url %>"><%= t('.commentline') %>
|
||||||
<%= mod.comment.user.username %>
|
<%= mod.comment.user.username %>
|
||||||
on
|
<%= t('.commenton') %>
|
||||||
<%= mod.comment.story.title %></a>
|
<%= mod.comment.story.title %></a>
|
||||||
<% elsif mod.user_id %>
|
<% elsif mod.user_id %>
|
||||||
<% if mod.user %>
|
<% if mod.user %>
|
||||||
<a href="/u/<%= mod.user.username %>">User
|
<a href="/u/<%= mod.user.username %>"><%= t('.user') %>
|
||||||
<%= mod.user.username %></a>
|
<%= mod.user.username %></a>
|
||||||
<% else %>
|
<% else %>
|
||||||
User <%= mod.user_id %> (Deleted)
|
<%= t('.user') %> <%= mod.user_id %> (<%= t('.deleted') %>)
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %></td>
|
<% end %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr class="row<%= bit %> <%= mod.reason.present?? "nobottom" : "" %>">
|
<tr class="row<%= bit %> <%= mod.reason.present?? "nobottom" : "" %>">
|
||||||
<td colspan=2></td>
|
<td colspan=2></td>
|
||||||
<td>Action: <em><%= mod.action %></em></td>
|
<td><%= t('.actionline') %>: <em><%= mod.action %></em></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% if mod.reason.present? %>
|
<% if mod.reason.present? %>
|
||||||
<tr class="row<%= bit %>">
|
<tr class="row<%= bit %>">
|
||||||
<td colspan=2></td>
|
<td colspan=2></td>
|
||||||
<td>Reason: <em><%= mod.reason %></em></td>
|
<td><%= t('.reasonline') %>: <em><%= mod.reason %></em></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% bit = (bit == 1 ? 0 : 1) %>
|
<% bit = (bit == 1 ? 0 : 1) %>
|
||||||
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
<div class="morelink">
|
<div class="morelink">
|
||||||
<% if @page > 1 %>
|
<% if @page > 1 %>
|
||||||
<a href="/moderations/page/<%= @page - 1 %>"><< Page
|
<a href="/moderations/page/<%= @page - 1 %>"><< <%= t('.page') %>
|
||||||
<%= @page - 1 %></a>
|
<%= @page - 1 %></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@
|
||||||
<% if @page > 1 %>
|
<% if @page > 1 %>
|
||||||
|
|
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<a href="/moderations/page/<%= @page + 1 %>">Page <%= @page + 1
|
<a href="/moderations/page/<%= @page + 1 %>"><%= t('.page') %> <%= @page + 1
|
||||||
%> >></a>
|
%> >></a>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,19 @@
|
||||||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||||
|
|
||||||
en:
|
en:
|
||||||
|
time:
|
||||||
|
formats:
|
||||||
|
default: "%Y-%m-%d %H:%M:%S"
|
||||||
|
models:
|
||||||
|
moderation:
|
||||||
|
storyeditedby: "Your story has been edited by "
|
||||||
|
usersuggestions: "user suggestions"
|
||||||
|
amoderator: "a moderator"
|
||||||
|
storyeditedfor: "Your story [%{title}](%{url}) has been edited with the following changes:\n"
|
||||||
|
reasongiven: "The reason given:\n"
|
||||||
|
commentmoderated: "Your comment has been moderated"
|
||||||
|
commentmoderatedwhy: "Your comment on [%{title}](%{url}) has been moderated:\n"
|
||||||
|
automatedmessage: "*This is an automated message.*"
|
||||||
layouts:
|
layouts:
|
||||||
application:
|
application:
|
||||||
homelink: "Home"
|
homelink: "Home"
|
||||||
|
@ -24,3 +37,19 @@ en:
|
||||||
hatrequestlink: "Hat Requests"
|
hatrequestlink: "Hat Requests"
|
||||||
privacylink: "Privacy"
|
privacylink: "Privacy"
|
||||||
aboutlink: "About"
|
aboutlink: "About"
|
||||||
|
moderations:
|
||||||
|
index:
|
||||||
|
moderationlogtitle: "Moderation Log"
|
||||||
|
datecolumn: "Date/Time"
|
||||||
|
moderatorcolumn: "Moderator"
|
||||||
|
reasoncolumn: "Story/Comment/User, Action, Reason"
|
||||||
|
storyline: "Story"
|
||||||
|
commentline: "Comment by"
|
||||||
|
commenton: "on"
|
||||||
|
user: "User"
|
||||||
|
users: "Users"
|
||||||
|
deleted: "Deleted"
|
||||||
|
actionline: "Action"
|
||||||
|
reasonline: "Reason"
|
||||||
|
page: "Page"
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,19 @@
|
||||||
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
|
||||||
|
|
||||||
fr:
|
fr:
|
||||||
|
time:
|
||||||
|
formats:
|
||||||
|
default: "%d-%m-%Y %H:%M:%S"
|
||||||
|
models:
|
||||||
|
moderation:
|
||||||
|
storyeditedby: "Votre info a été éditée par "
|
||||||
|
usersuggestions: "suggestions d'utilisateur"
|
||||||
|
amoderator: "un modérateur"
|
||||||
|
storyeditedfor: "Votre info [%{title}](%{url}) a été éditée avec les changements suivants :\n"
|
||||||
|
reasongiven: "La raison donnée :\n"
|
||||||
|
commentmoderated: "Votre commentaire a été modéré"
|
||||||
|
commentmoderatedwhy: "Votre commentaire sur [%{title}](%{url}) a été modéré :\n"
|
||||||
|
automatedmessage: "*Ceci est un message automatique.*"
|
||||||
layouts:
|
layouts:
|
||||||
application:
|
application:
|
||||||
homelink: "Accueil"
|
homelink: "Accueil"
|
||||||
|
@ -24,3 +37,18 @@ fr:
|
||||||
hatrequestlink: "Porter le chapeau"
|
hatrequestlink: "Porter le chapeau"
|
||||||
privacylink: "Confidentialité"
|
privacylink: "Confidentialité"
|
||||||
aboutlink: "À propos"
|
aboutlink: "À propos"
|
||||||
|
moderations:
|
||||||
|
index:
|
||||||
|
moderationlogtitle: "Journal de modération"
|
||||||
|
datecolumn: "Date/Heure"
|
||||||
|
moderatorcolumn: "Moderateur"
|
||||||
|
reasoncolumn: "Histoire/Commentaire/Utilisateur, Action, Raison"
|
||||||
|
storyline: "Info"
|
||||||
|
commentline: "Commentaire par"
|
||||||
|
commenton: "sur"
|
||||||
|
user: "Utilisateur"
|
||||||
|
users: "Utilisateurs"
|
||||||
|
deleted: "Supprimé"
|
||||||
|
actionline: "Action"
|
||||||
|
reasonline: "Raison"
|
||||||
|
page: "Page"
|
||||||
|
|
Loading…
Reference in a new issue