简体   繁体   中英

Active admin input field with locale

I have built multi-language application.But at this point I see lot of trouble to edit my translations through ActiveAdmin interface. I want to be able add/edit translations through this interface. Because using seeds.rb is not an option for user.

Idea is to have 2 text fields when editing/creating product, where in the first one I could write product description in my native language and in second description in english. I don't to create new column for products table. I wan't to use built in Globalize3 structure.

Where is other table like category_translations .

If I try like this:

form :html => { :enctype => "multipart/form-data" } do |f|
  f.inputs "Content" do
    f.input :name
    f.input :condition, :collection => @condition,:hint=>"Select condition"
    f.input :sub_desc, :input_html => { :class => "tinymce" }
    f.input :description, :input_html => { :class => "tinymce" },:locale=>'en'
    f.input :description, :input_html => { :class => "tinymce" },:locale=>'lv'  
    f.input :technical_data, :input_html => {:class=>"tinymce" }
    f.input :intro_text
    f.input :category, :collection => @category
    f.input :slug
    f.input :manufacturer, :collection => @manufacturer,:hint=>"Choose manufacturer"
  end
  f.inputs "Image" do 
  f.input :photo, :as => :file, :hint=>"Select image to upload. Allowed file formats *jpg *png, Soft signs not Allowed"
     #form :partial => "form"
  end
  f.actions
  end

Where I am trying to set locale variable to input, but this gives me no errors at all. Somebody had similar problem ?

You should check the activeadmin-globalize gem. It gives you a nice interface to handle fields that has translations.

Gem for Globalize3: https://rubygems.org/gems/activeadmin-globalize3

I have not tested this version, because we are using Globalize in our project with the activeadmin-globalize taken from: https://github.com/stefanoverna/activeadmin-globalize .

There is a pull request that lowers the dependency of activeadmin-globalize so it can be used in a Rails 3.2 app: https://github.com/stefanoverna/activeadmin-globalize/pull/38

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM