Add MongoMapper key_i18n support

This commit is contained in:
Wen-Tien Chang committed 2010-01-08 15:32:44 +08:00
1 parent a674e46c91
commit 5ab32baf88
7 files changed
+23 -36

No files matched your search

+3 -13
View File
@@ -2,21 +2,11 @@ class Announcement
include MongoMapper::Document
key :title_en, String
key :title_zh_tw, String
key :content_en, String
key :content_zh_tw, String
key_i18n :title, String
key_i18n :content, String
def to_liquid
{ "id" => self.id, "title" => self.send("title_#{I18n.locale}"), "content" => self.send("content_#{I18n.locale}") }
end
def title
self.send("title_#{I18n.locale}")
end
def content
self.send("content_#{I18n.locale}")
{ "id" => self.id, "title" => self.title, "content" => self.content }
end
end
+1 -2
View File
@@ -3,8 +3,7 @@ class Layout
include MongoMapper::Document
key :name, String
key :content_en, String
key :content_zh_tw, String
key_i18n :content, String
validates_presence_of :name
+2 -3
View File
@@ -3,9 +3,8 @@ class Page
key :name, String
key :parent_page_id, String
key :content_en, String
key :content_zh_tw, String
key_i18n :content, String
key :layout_id, String
key :layout_name, String
+1 -2
View File
@@ -3,8 +3,7 @@ class Snippet
include MongoMapper::Document
key :name, String
key :content_en, String
key :content_zh_tw, String
key_i18n :content, String
validates_presence_of :name
+1 -1
View File
@@ -4,7 +4,7 @@ module SnippetFilter
snippet = Snippet.find_by_name(snippet_name)
if snippet
return Liquid::Template.parse( snippet.send( "content_#{I18n.locale}" ) ).render
return Liquid::Template.parse( snippet.content ).render
else
return "nothing"
end