netzpirat/activeadmin-translate


Translate your models in ActiveAdmin with Globalize3.

License: MIT

Language: Ruby


ActiveAdmin Translate

Translate your Globalize3 ActiveModel translations in ActiveAdmin, using jQueryUI tabs to switch between the locales.

Installation

Add the gem to your Gemfile

gem 'activeadmin-translate'

and install it with Bundler:

$ bundle

Configuration

Set available languages

ActiveAdmin Translate takes the available languages from I18n.available_locales, so you want to configure them in your application.rb like

config.i18n.available_locales = [:en, :de, :fr, :it]

Include ActiveAdmin Translate

You need to import the SASS for styling the tabs to app/assets/stylesheets/active_admin.css.scss:

@import "active_admin/translate";

Usage

Make your translations accessible

In order to access the translations of your model and be able to write them on save, you need to make attributes accessible in your model. Globalize3 stores the model translations in a separate table that is accessible as translations in your model:

class GlobalizedModel < ActiveRecord::Base
  attr_accessible :translations, :translations_attributes
  accepts_nested_attributes_for :translations
end

Translate your ActiveAdmin forms

To translate your form you need to use the translate_inputs form helper:

form do |f|
  f.translate_inputs do |t|
    t.input :title
    t.input :description
  end
end

Translate your ActiveAdmin attributes table

To show the attributes for all locales, you use the translate_attributes_table_for view helper:

show do |model|
  panel 'Globalized Model' do
    translate_attributes_table_for model do
      row :title
      row :description do |p|
        BlueCloth.new(p.teaser).to_html.html_safe
      end
    end
  end
end

Localize the languages

To localize your locale names, use the following I18n key structure per locale:

en:
  active_admin:
    translate:
      en: "English"

and add more translations with the registered locale symbol.

Author

Developed by Michael Kessler, FlinkFinger GmbH.

If you like ActiveAdmin Translate, you can watch the repository at GitHub and follow @netzpirat on Twitter for project updates.

Contribute to ActiveAdmin Translate

File an issue

You can report bugs and feature requests to GitHub Issues.

Please don't ask question in the issue tracker, instead ask them at Stackoverflow and use the activeadmin tag.

When you file a bug, please try to follow these simple rules if applicable:

  • Make sure you've read the README carefully.
  • Give as much information about your environment, like Ruby and ActiveAdmin version.
  • Make sure that the issue is reproducible with your description.

It's most likely that your bug gets resolved faster if you provide as much information as possible!

Development

Pull requests are very welcome! Please try to follow these simple rules if applicable:

  • Please create a topic branch for every separate change you make.
  • Update the Yard documentation.
  • Update the README.
  • Update the CHANGELOG for noteworthy changes.
  • Please do not change the version number.

Contributors

See the CHANGELOG and the GitHub list of contributors.

Acknowledgment

This project has taken some ideas and code from the following projects:

License

Copyright (c) 2012 Michael Kessler

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project Statistics

Sourcerank 5
Repository Size 269 KB
Stars 36
Forks 44
Watchers 6
Open issues 11
Dependencies 3
Contributors 1
Tags 4
Created
Last updated
Last pushed

Top Contributors See all

Michael Kessler

Packages Referencing this Repo

activeadmin-translate
Translate your models in ActiveAdmin with Globalize3.
Latest release 0.2.2 - Updated - 36 stars

Recent Tags See all

v0.2.2 November 16, 2012
v0.2.1 November 16, 2012
v0.2.0 November 15, 2012
v0.0.1 November 15, 2012

Interesting Forks See all

twintags/activeadmin-translate
Translate your models in ActiveAdmin (last version) with Globalize in Rails 4.0 (and above)
Ruby - MIT - Last pushed - 7 stars - 12 forks

Something wrong with this page? Make a suggestion

Last synced: 2016-05-27 16:15:45 UTC

Login to resync this repository