Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Repository that contains a copy of the twintags/activeadmin-translate repo, required for the onrunning/on main app

License

Notifications You must be signed in to change notification settings

onrunning/activeadmin-translate

Repository files navigation

ActiveAdmin Translate

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

Installation

Add the gem to your Gemfile

gem 'activeadmin-translate', github: 'twintags/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, :es, :ca]

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. Globalize 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.

About

Repository that contains a copy of the twintags/activeadmin-translate repo, required for the onrunning/on main app

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published