Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rstgroup/active_i18n

Plugin for active admin which allows to easy modify I18n translations.
https://github.com/rstgroup/active_i18n

Last synced: 27 days ago
JSON representation

Plugin for active admin which allows to easy modify I18n translations.

Awesome Lists containing this project

README

        

# ActiveI18n

ActiveI18n is an translation panel designed to work inside an activeadmin.

[![Gem Version](https://badge.fury.io/rb/active_i18n.svg)](http://badge.fury.io/rb/active_i18n) [![Code Climate](https://codeclimate.com/github/rstgroup/active_i18n/badges/gpa.svg)](https://codeclimate.com/github/rstgroup/active_i18n) [![Build Status](https://travis-ci.org/rstgroup/active_i18n.svg?branch=master)](https://travis-ci.org/rstgroup/active_i18n) [![RST](http://rst-it.com/files/rstwithpassion.png)](http://rst-it.com) [![RST](http://rst-it.com/files/howwedoapps.png)](http://howwedoapps.com)

how it looks:

### ActiveAdmin and Rails version

This library was tested only on rails 3.2.x. with activeadmin 0.6.x. If you would like to use it with 4.x rails version - just let me know I will port it.

### Prerequisites

1. [activeadmin](http://activeadmin.info/) gem
2. [active_skin](https://github.com/rstgroup/active_skin) gem (optional for better looking)

### Installation

##### 0. make sure you have activeadmin installed

##### 1. add gems to your gemfile:

```ruby
# gemfile
gem "activeadmin", "~> 0.6.3"
gem "active_skin" #for better looking
gem "active_i18n"
gem "haml" # because aa views are in haml
gem "redis" # when you are using Redis as a translations store
```

and then run: `bundle install`

##### 2. add rails initializer

create file active_i18n.rb in config/initializers

```ruby
# config/initializers/active_i18n.rb
ActiveI18n.config(
store: I18n::Backend::KeyValue.new(Redis.new),
except: ["testtranslationkey", "date", "datetime"]
)
```

**store**: sets translation store (in this example redis database - required)
**except**: removes some of the keys from the sidebar menu (optional)

If you are using redis you also will need to run the redis server `redis-server` in console

##### 3. define languages to translate

now having everything set up you could narrow the list of available languages and select base locale (if you don't - your users will see in selectboxes list of all available locales). You will do this in application.rb

```ruby
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :pl, :de] #placing :en again allows users to change default texts on your website
```

##### 4. add translation to the active admin menu

in your app/admin folder create new file called translations.rb (or whatever)

```ruby
ActiveAdmin.register_translation "Translations",
:parent => "CMS",
:priority => 2,
:label => "Translations"
```
hash is the same as in menu function in ActiveAdmin.

##### 5. add css and js

inside active_admin.js add active_i18n:

```
...
//= require active_admin/base
...

//= require active_i18n

```

and inside active_admin.css.scss also add active_i18n:
```scss
...
@import "active_admin/mixins";
@import "active_admin/base";
@import "active_skin";
...

@import "active_i18n";

```

##### and you are ready to go

## Contributing

1. Fork it ( http://github.com/rstgroup/active_i18n/fork )
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