OSDN Git Service

t#30199:update i18n error caption
authoryasushiito <yas@pen-chan.jp>
Tue, 27 Nov 2012 09:33:09 +0000 (18:33 +0900)
committeryasushiito <yas@pen-chan.jp>
Tue, 27 Nov 2012 09:33:09 +0000 (18:33 +0900)
app/helpers/application_helper.rb
app/views/artists/_form.html.erb
app/views/authors/_form.html.erb
app/views/comics/_form.html.erb
app/views/original_picture_license_groups/_form.html.erb
app/views/panels/_form.html.erb
app/views/stories/_editform.html.erb
app/views/stories/_newform.html.erb
app/views/system/_error_explanation.html.erb [new file with mode: 0644]

index e416327..9b27e32 100644 (file)
@@ -23,4 +23,5 @@ module ApplicationHelper
   def t_selected_item(name, index)
     t(MagicNumber[name][index][0])
   end
+  
 end
index 74802c0..ae35d64 100644 (file)
@@ -1,15 +1,5 @@
 <%= form_for(@artist) do |f| %>
-  <% if @artist.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@artist.errors.count, "error") %> prohibited this artist from being saved:</h2>
-
-      <ul>
-      <% @artist.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
+  <%= render 'system/error_explanation', :obj => @artist %>
 
   <div class="field">
     <%= f.label :name %><br />
index d15a03d..f4a8a3f 100644 (file)
@@ -1,15 +1,5 @@
 <%= form_for(@au) do |f| %>
-  <% if @au.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@au.errors.count, "error") %> prohibited this author from being saved:</h2>
-
-      <ul>
-      <% @au.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
+  <%= render 'system/error_explanation', :obj => @au %>
 
   <div class="field">
     <%= f.label :name %><br />
index 8a7ab69..8f4ca29 100644 (file)
@@ -1,15 +1,5 @@
 <%= form_for(@comic) do |f| %>
-  <% if @comic.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@comic.errors.count, "error") %> prohibited this comic from being saved:</h2>
-
-      <ul>
-      <% @comic.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
+  <%= render 'system/error_explanation', :obj => @comic %>
 
   <div class="field">
     <%= f.label :author_id %><br />
index e3413f1..b9b850c 100644 (file)
@@ -1,15 +1,5 @@
 <%= form_for(@original_picture_license_group) do |f| %>
-  <% if @original_picture_license_group.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@original_picture_license_group.errors.count, "error") %> prohibited this comic from being saved:</h2>
-
-      <ul>
-      <% @original_picture_license_group.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
+  <%= render 'system/error_explanation', :obj => @original_picture_license_group %>
 
   <table class="no-border">
     <tr>
index 08e6d60..81965fd 100644 (file)
@@ -1,15 +1,5 @@
 <%= form_tag( {:controller => 'panels',:action => "create"}) do %>
-  <% if @panel.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@panel.errors.count, "error") %> prohibited this panel from being saved:</h2>
-
-      <ul>
-      <% @panel.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
+  <%= render 'system/error_explanation', :obj => @panel %>
   <label for="json">json data</label> <%= text_field_tag "json" %>
   <%= submit_tag 'upload' -%>
 <% end -%>
index 9cc6dd4..73f55bf 100644 (file)
@@ -1,15 +1,5 @@
 <%= form_for(@story) do |f| %>
-  <% if @story.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@story.errors.count, "error") %> prohibited this comic from being saved:</h2>
-
-      <ul>
-      <% @story.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
+  <%= render 'system/error_explanation', :obj => @story %>
 
   <div class="field">
     <%= f.hidden_field :comic_id %>
index f7b5749..7ec5e4a 100644 (file)
@@ -1,15 +1,5 @@
 <%= form_for(@story) do |f| %>
-  <% if @story.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@story.errors.count, "error") %> prohibited this comic from being saved:</h2>
-
-      <ul>
-      <% @story.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
-    </div>
-  <% end %>
+  <%= render 'system/error_explanation', :obj => @story %>
 
   <div class="field">
     <%= f.number_field :comic_id %>
diff --git a/app/views/system/_error_explanation.html.erb b/app/views/system/_error_explanation.html.erb
new file mode 100644 (file)
index 0000000..2043c07
--- /dev/null
@@ -0,0 +1,18 @@
+<% if obj.errors.any? %>
+  <div id="error_explanation">
+    <h2>
+    <%= 
+      if obj.errors.size == 1
+        t('activerecord.errors.template.header.one', :model => obj.class.model_name.human)
+      else
+        t('activerecord.errors.template.header.other', :model => obj.class.model_name.human, :count => obj.errors.size)
+      end 
+    %>
+    </h2>
+    <ul>
+      <% obj.errors.full_messages.each do |msg| %>
+        <li><%= msg %></li>
+      <% end %>
+    </ul>
+  </div>
+<% end %>