No commit activity in last 3 years
No release in over 3 years
Fully customizable record translations for rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
 Dependencies

Development

~> 0.21

Runtime

~> 5.1
 Project Readme

Gem Version Code Climate Build Status Dependency Status

Translatable Records

Fully customizable record translations for rails.

Why

I did this gem to:

  • Have the freedom to customize the translation model.
  • Avoid duplication by delegate translatable attributes directly to translation model.
  • Use translations other than I18n.available_locales.

Install

Put this line in your Gemfile:

gem 'translatable_records'

Then bundle:

$ bundle

Configuration

Define wich attributes will be translated in the model:

class Product < ActiveRecord::Base
  translate :name
end

Generate the translation and migration:

$ bundle exec rails g translation product

Update your db:

$ bundle exec rake db:migrate

Usage

Accessors

By default will use I18n.locale but you can change it:

product.locale = :en

Accessor continue working the same:

product.name = 'Phone'

Views

If you want to save multiple translations:

<%= f.fields_for :translations do |ff| %>
  <%= ff.hidden_field :locale %>
  <%= ff.label :name %>
  <%= ff.text_field :name %>
<% end %>

Contributing

Any issue, pull request, comment of any kind is more than welcome!

I will mainly ensure compatibility to Rails, AWS, PostgreSQL, Redis, Elasticsearch and FreeBSD. 

Credits

This gem is maintained and funded by museways.

License

It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.