No commit activity in last 3 years
No release in over 3 years
Add support to CouchRest Model for localised properties.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 2.0.0

Runtime

~> 1.1.0.beta4
> 0.3.0
 Project Readme

CouchRest Localised Properties¶ ↑

Localise your CouchRest Model properties as if by magic!

Introduction¶ ↑

Storing translations of data is always a difficult problem.

CouchRest Localised Properties works by overwriting the normal attribute getters and setters with special localised versions that will magically replace the attribute with a hash. For each locale supported by your application there will be a key in the hash to store the real value. This approach allows you to apply any typecasting to the value being read as if you were working in just one locale.

While getting and setting values is quite considerably easier, you’ll still need to write your view methods manually.

Basic Usage¶ ↑

class Article < CouchRest::Model::Base
  localised_property :title, String
  localised_property :content, String

  property :published_at, DateTime
end

# set language to english and set title
I18n.default_locale = :en
I18n.locale = :en
@a = Article.new
@a.title = "Test Title"

# language changed to spanish:
I18n.locale = :es
# returns default text as no translation set
@a.title == "Test Title"  # true

# set the title for spanish
@a.title = "Título de prueba"

# Have a look at the raw data
@a['title'] == {
  'en' => "Test Title",
  'es' => "Título de prueba"
}

Updates¶ ↑

v0.1.1 - 20th April 2011¶ ↑

- Updated to use CouchRest Model 1.1.0.beta4 with dirty tracking

v0.1 - 25th March 2011¶ ↑

- First release

Todos / Bugs¶ ↑

- Please let me know!

License¶ ↑

Copyright © 2011 Samuel Lown <me (AT) samlown.com>

This Plugin is released under the MIT license, as Rails itself. Please see the attached LICENSE file for further details.

This document and plugin should be considered a work in progress until further notice!