No commit activity in last 3 years
No release in over 3 years
Include fields for multiple languages in your forms.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.5
>= 0

Runtime

~> 4.0.0
~> 3.1.0.rc1
 Project Readme

FormTranslation

Code Climate Build Status

It uses ActiveRecord::Store to store language specific values and adds tabs to your forms for each language.

Installation

Add this line to your application's Gemfile:

gem 'form_translation', github: 'Crunch09/form_translation'

And then execute:

$ bundle
$ rails g form_translation:install

Usage

  • In your model include `FormTranslation::ForModel* and specify which attributes should be translated.
class Article < ActiveRecord::Base
      include FormTranslation::ForModel

      translate_me :subject, :body
end
  • Within your simple_form-Form specify where to put your translation-tabs with a languagify block.
<%= simple_form_for(@article) do |f| %>
      <div class="form-inputs">
        <%= f.input :date %>
      </div>
      <div>
        <%= f.languagify do |l| %>
          <%= l.input :subject %>
          <%= l.input :body %>
        <% end %>
      </div>
      <div class="form-actions">
        <%= f.button :submit %>
      </div>
<% end %>

Lastly, make sure to add the translated attributes to your permitted parameters so they can be stored. The convention for the attribute name is as follows: language_shortname_attribute_name

def article_params
  params.require(:article).permit(:subject, :body, :de_subject, :de_body)
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request