i18n of flash error for blank comment. fixes #30

This commit is contained in:
Carl Chenet 2016-12-07 10:51:18 +01:00
parent b2f4156ab8
commit 6c39cb4784
3 changed files with 9 additions and 3 deletions

View file

@ -31,13 +31,13 @@ class Comment < ActiveRecord::Base
validate do
self.comment.to_s.strip == "" &&
errors.add(:comment, "cannot be blank.")
errors.add(" ", I18n.t( 'models.comment.commentcannotbeblank'))
self.user_id.blank? &&
errors.add(:user_id, "cannot be blank.")
errors.add(" ", I18n.t( 'models.comment.useridcannotbeblank'))
self.story_id.blank? &&
errors.add(:story_id, "cannot be blank.")
errors.add(" ", I18n.t( 'models.comment.storyidcannotbeblank'))
(m = self.comment.to_s.strip.match(/\A(t)his([\.!])?$\z/i)) &&
errors.add(:base, (m[1] == "T" ? "N" : "n") + "ope" + m[2].to_s)

View file

@ -10,6 +10,9 @@ en:
subject: "[%{appname}] You have been invited to %{appname}"
models:
comment:
commentcannotbeblank: "A comment cannot be blank."
useridcannotbeblank: "A user ID cannot be blank."
storyidcannotbeblank: "A story ID cannot be blank."
deletedcomment: "deleted comment"
threadremovedby: "Thread removed by moderator %{modoname} : %{modreason}"
moderation:

View file

@ -22,6 +22,9 @@ fr:
subject: "[%{appname}] Vous avez été invité au %{appname}"
models:
comment:
commentcannotbeblank: "Un commentaire ne peut pas être vide."
useridcannotbeblank: "Un ID utilisateur ne peut pas être vide."
storyidcannotbeblank: "Un ID d'info ne peut pas être vide."
deletedcomment: "commentaire supprimé"
threadremovedby: "Fil supprimé par le modérateur %{modoname} : %{modreason}"
moderation: