Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

activeadmin-translate

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

activeadmin-translate

  • 0.2.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

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, mksoft.ch.

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.

FAQs

Package last updated on 16 Nov 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc