No commit activity in last 3 years
No release in over 3 years
Adds tabbed interface and custom field type for globalize translations to Rails_admin
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.29
>= 0
>= 0

Runtime

>= 5.0
>= 5.0
 Project Readme

RailsAdminGlobalizeField

RailsAdminGlobalizeField adds tabbed interface to rails_admin for multilingual models (using globalize gem)

It adds custom field type that you can use for globalize's translations association.

Installation

Add and configure globalize first.

  gem 'globalize', '~> 5.0'

Add this gem and run bundle.

  gem 'rails_admin_globalize_field', '~> 1.0'

Usage

Don't forget to set I18n.available_locale, because it uses that to determine what tabs to show

Add translation models to config.included_models in initializers/rails_admin.rb:

  config.included_models = ['Model','Model::Translation']

Add accepts_nested_attributes_for for translations to your translated model.

  class Model < ActiveRecord::Base
    translates :title, :desc
    accepts_nested_attributes_for :translations, allow_destroy: true
  end

Add configuration to your translated model and associated translation model. :locale field is always required.

  config.model 'Post' do
    configure :translations, :globalize_tabs
  end

  config.model 'Model::Translation' do
    visible false
    configure :locale, :hidden do
      help ''
    end
    include_fields :locale, :title, :desc
  end

If you need to add validation to the translation class, you can add it on translation_class inside translated model:

  translation_class.validates :title, presence: true

Screenshot

Screenshot

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