diff options
Diffstat (limited to 'app')
| -rw-r--r-- | app/models/node.rb | 16 | ||||
| -rw-r--r-- | app/models/page.rb | 7 |
2 files changed, 15 insertions, 8 deletions
diff --git a/app/models/node.rb b/app/models/node.rb index 31cc347..81d61a8 100644 --- a/app/models/node.rb +++ b/app/models/node.rb | |||
| @@ -69,19 +69,19 @@ class Node < ActiveRecord::Base | |||
| 69 | 69 | ||
| 70 | p.tag_list = self.head.tag_list.join(", ") | 70 | p.tag_list = self.head.tag_list.join(", ") |
| 71 | 71 | ||
| 72 | locale_before = I18n.locale.dup | 72 | #locale_before = I18n.locale |
| 73 | 73 | ||
| 74 | I18n.available_locales.each do |l| | 74 | I18n.available_locales.each do |l| |
| 75 | next if l == :root | 75 | next if l == :root |
| 76 | I18n.locale = l | 76 | Page.with_locale l do |
| 77 | 77 | p.title = self.head.title | |
| 78 | p.title = self.head.title | 78 | p.abstract = self.head.abstract |
| 79 | p.abstract = self.head.abstract | 79 | p.body = self.head.body |
| 80 | p.body = self.head.body | 80 | end |
| 81 | end | 81 | end |
| 82 | 82 | ||
| 83 | I18n.locale = locale_before | 83 | #Page.locale = locale_before |
| 84 | p.reload | 84 | |
| 85 | p.user = user | 85 | p.user = user |
| 86 | p.save | 86 | p.save |
| 87 | p | 87 | p |
diff --git a/app/models/page.rb b/app/models/page.rb index aba974a..ea481a6 100644 --- a/app/models/page.rb +++ b/app/models/page.rb | |||
| @@ -38,5 +38,12 @@ class Page < ActiveRecord::Base | |||
| 38 | :order => "#{options[:order_by]} #{options[:order_direction]}") | 38 | :order => "#{options[:order_by]} #{options[:order_direction]}") |
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | def self.with_locale l, &block | ||
| 42 | old_locale = self.locale | ||
| 43 | self.locale = l | ||
| 44 | yield | ||
| 45 | self.locale = old_locale | ||
| 46 | end | ||
| 47 | |||
| 41 | # Instance Methods | 48 | # Instance Methods |
| 42 | end \ No newline at end of file | 49 | end \ No newline at end of file |
