Add MongoMapper key_i18n support
This commit is contained in:
1 parent
a674e46c91
commit
5ab32baf88
7 files changed
+23
-36
No files matched your search
+13
-13
@@ -50,18 +50,18 @@ VALID_LOCALES = ["en", "zh_tw"]
|
||||
MongoMapper.database = "r4-#{Rails.env}"
|
||||
|
||||
|
||||
#class CouchFoo::Base
|
||||
#
|
||||
# def self.property_i18n(property_name, property_type)
|
||||
# VALID_LOCALES.each do |locale|
|
||||
# property "#{property_name.to_s}_#{locale}".to_sym, property_type
|
||||
# end
|
||||
#
|
||||
# define_method( property_name ) do
|
||||
# self.read_attribute("#{property_name.to_s}_#{I18n.locale}")
|
||||
# end
|
||||
# end
|
||||
#
|
||||
#end
|
||||
module MongoMapper::Document::ClassMethods
|
||||
|
||||
def key_i18n(key, *options)
|
||||
VALID_LOCALES.each do |locale|
|
||||
key "#{key.to_s}_#{locale}".to_sym, *options
|
||||
end
|
||||
|
||||
define_method(key) do
|
||||
self.send("#{key.to_s}_#{I18n.locale}")
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user