changeset 380:2ddd61aca2c8

I18n. And refactor paste privacy settings form.
author nanaya <me@myconan.net>
date Sun, 07 Jun 2015 02:45:49 +0900
parents 2ad092e60975
children bfc5ad3f7dc5
files app/helpers/pastes_helper.rb app/views/pastes/_form.html.erb config/locales/en.yml
diffstat 3 files changed, 21 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/app/helpers/pastes_helper.rb	Sun Jun 07 02:35:12 2015 +0900
+++ b/app/helpers/pastes_helper.rb	Sun Jun 07 02:45:49 2015 +0900
@@ -11,4 +11,8 @@
       end
     end
   end
+
+  def paste_privacy_options
+    { "public" => "0", "private" => "1" }
+  end
 end
--- a/app/views/pastes/_form.html.erb	Sun Jun 07 02:35:12 2015 +0900
+++ b/app/views/pastes/_form.html.erb	Sun Jun 07 02:45:49 2015 +0900
@@ -8,28 +8,26 @@
     <div class="inputs left">
 
       <div class="vertical-flex">
-        <%= f.label :key, "Deletion key", :class => "form-label" %>
+        <%= f.label :key, t(".deletion_key"), :class => "form-label" %>
         <%= f.text_field :key %>
       </div>
 
       <div class="vertical-flex">
-        <div class="form-label">Privacy</div>
-        <label class="radio">
-          <%= f.radio_button :is_private, "0" %>
-          <span>Public</span>
-        </label>
+        <div class="form-label"><%= t(".privacy.label") %></div>
 
-        <label class="radio">
-          <%= f.radio_button :is_private, "1" %>
-          <span>Private</span>
-        </label>
+        <% paste_privacy_options.each do |label, value| %>
+          <label class="radio">
+            <%= f.radio_button :is_private, value %>
+            <span><%= t(".privacy.#{label}") %></span>
+          </label>
+        <% end %>
       </div>
     </div>
 
     <div class="inputs right">
       <%= f.button %>
 
-      <%= button_tag "Clear", :type => "button", :id => "reset_paste" %>
+      <%= button_tag t(".clear"), :type => "button", :id => "reset_paste" %>
     </div>
   </div>
 <% end %>
--- a/config/locales/en.yml	Sun Jun 07 02:35:12 2015 +0900
+++ b/config/locales/en.yml	Sun Jun 07 02:45:49 2015 +0900
@@ -2,4 +2,11 @@
 # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
 
 en:
-  hello: "Hello world"
+  pastes:
+    form:
+      clear: Clear
+      deletion_key: Deletion key
+      privacy:
+        label: Privacy
+        private: Private
+        public: Public