[mongoid] I18n gem released

56 views
Skip to first unread message

Rodrigo Alvarez

unread,
May 2, 2010, 7:18:20 PM5/2/10
to Mongoid
hi all,

I've just released a testing version of my i18n gem for mongoid:

http://github.com/Papipo/mongoid_i18n

It only takes care of the fields persistence and querying. Nothing
about validations for example is done yet. Take a look at the README
if you want examples :-).

This is for Durran:

When a class includes the Mongoid::I18n module, this redefines its
criteria() method, in order to return a LocalizedCriteria object. The
thing is that the original Criteria class instantiates itself
bypassing the Document.criteria method, to be precise this happens in
Criteria.translate().

That's why I had to add a monkey patch to call klass.criteria()
instead of new(klass). Otherwise calls to translate() would yield a
Criteria instead of a LocalizedCriteria.

I think that this patch could be in mongoid master. As far as I know
it won't harm and I will make very easy to hook in custom Criteria
classes. You can see the code here
http://github.com/Papipo/mongoid_i18n/blob/master/lib/mongoid/i18n/patches.rb
lines 7 and 14.

Please test it, and tell me if you find any problems.

Thanks everybody.

Jacques Crocker

unread,
May 2, 2010, 8:19:28 PM5/2/10
to mon...@googlegroups.com
Rodrigo, this looks friggin awesome. Thanks a ton for your work on this!
Reply all
Reply to author
Forward
0 new messages