Search code examples
ruby-on-rails-3internationalizationformtastic

How to add internationalization in a formtastic page


I tried to use default internationalization of formtastic and failed. I tried it as given in

https://github.com/justinfrench/formtastic/wiki/6.2-Customize:-Internationalization

So now i want to introduce internationalization using i18ln gem of rails in formtastic.

How can i do it?

This is the proposed form page

<%= semantic_form_for @detail do |f| %>
  <%= f.inputs do %>

    <%= f.input :name %>

    <%= f.input :dob  %> 
    <%= f.input :gender, :as => :radio, :label => "Gender", :collection => [["Male", 'male'], ["Female", 'female']] %>  
  <% end %>
  <%= f.actions do %>
    <%= f.action :submit, :as => :input %>
  <% end %>
<% end %>

This is wk.yml file

en: 
formtastic:
  dob: Date of Birth
  name: Your Name
  Gender: gender

How to integrate both together?


Solution

  • First off, have you added Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true in formtastic.rb initializer?

    Try with:

    wk: 
      formtastic:
        labels:
          detail:
            dob: "Date of Birth"
            name: "Your Name"
            gender: "gender"