diff options
| author | hukl <contact@smyck.org> | 2009-07-19 19:02:31 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-07-19 19:02:31 +0200 |
| commit | 7c9f0d0823bdce9a011d3bdd2823e15ffb7c1311 (patch) | |
| tree | b82854becc5437517180aa6406a0baebdad7e71b /vendor/plugins/globalize2/lib | |
| parent | 0d8879354fbd251e4509a0ab5c6b6e47aa3fa47d (diff) | |
updated globalize2 plugin
Diffstat (limited to 'vendor/plugins/globalize2/lib')
| -rw-r--r-- | vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb | 2 | ||||
| -rw-r--r-- | vendor/plugins/globalize2/lib/globalize/model/active_record/translated.rb | 23 |
2 files changed, 20 insertions, 5 deletions
diff --git a/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb b/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb index 71faebd..93355b8 100644 --- a/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb +++ b/vendor/plugins/globalize2/lib/globalize/model/active_record/adapter.rb | |||
| @@ -73,7 +73,7 @@ module Globalize | |||
| 73 | translations = @record.globalize_translations | 73 | translations = @record.globalize_translations |
| 74 | end | 74 | end |
| 75 | result, requested_locale = nil, locale | 75 | result, requested_locale = nil, locale |
| 76 | 76 | ||
| 77 | # Walk through the fallbacks, starting with the current locale itself, and moving | 77 | # Walk through the fallbacks, starting with the current locale itself, and moving |
| 78 | # to the next best choice, until we find a match. | 78 | # to the next best choice, until we find a match. |
| 79 | # Check the @globalize_set_translations cache first to see if we've just changed the | 79 | # Check the @globalize_set_translations cache first to see if we've just changed the |
diff --git a/vendor/plugins/globalize2/lib/globalize/model/active_record/translated.rb b/vendor/plugins/globalize2/lib/globalize/model/active_record/translated.rb index c7ae9e9..f8fb230 100644 --- a/vendor/plugins/globalize2/lib/globalize/model/active_record/translated.rb +++ b/vendor/plugins/globalize2/lib/globalize/model/active_record/translated.rb | |||
| @@ -23,10 +23,15 @@ module Globalize | |||
| 23 | 23 | ||
| 24 | include InstanceMethods | 24 | include InstanceMethods |
| 25 | extend ClassMethods | 25 | extend ClassMethods |
| 26 | alias_method_chain :reload, :globalize | ||
| 27 | 26 | ||
| 28 | self.globalize_proxy = Globalize::Model::ActiveRecord.create_proxy_class(self) | 27 | self.globalize_proxy = Globalize::Model::ActiveRecord.create_proxy_class(self) |
| 29 | has_many :globalize_translations, :class_name => globalize_proxy.name, :extend => Extensions | 28 | has_many( |
| 29 | :globalize_translations, | ||
| 30 | :class_name => globalize_proxy.name, | ||
| 31 | :extend => Extensions, | ||
| 32 | :dependent => :delete_all, | ||
| 33 | :foreign_key => class_name.foreign_key | ||
| 34 | ) | ||
| 30 | 35 | ||
| 31 | after_save :update_globalize_record | 36 | after_save :update_globalize_record |
| 32 | end | 37 | end |
| @@ -109,7 +114,7 @@ module Globalize | |||
| 109 | end | 114 | end |
| 110 | 115 | ||
| 111 | module InstanceMethods | 116 | module InstanceMethods |
| 112 | def reload_with_globalize | 117 | def reload(options = nil) |
| 113 | globalize.clear | 118 | globalize.clear |
| 114 | 119 | ||
| 115 | # clear all globalized attributes | 120 | # clear all globalized attributes |
| @@ -118,7 +123,7 @@ module Globalize | |||
| 118 | @attributes.delete attr.to_s | 123 | @attributes.delete attr.to_s |
| 119 | end | 124 | end |
| 120 | 125 | ||
| 121 | reload_without_globalize | 126 | super options |
| 122 | end | 127 | end |
| 123 | 128 | ||
| 124 | def globalize | 129 | def globalize |
| @@ -132,6 +137,16 @@ module Globalize | |||
| 132 | def translated_locales | 137 | def translated_locales |
| 133 | globalize_translations.scoped(:select => 'DISTINCT locale').map {|gt| gt.locale.to_sym } | 138 | globalize_translations.scoped(:select => 'DISTINCT locale').map {|gt| gt.locale.to_sym } |
| 134 | end | 139 | end |
| 140 | |||
| 141 | def set_translations options | ||
| 142 | options.keys.each do |key| | ||
| 143 | |||
| 144 | translation = globalize_translations.find_by_locale(key.to_s) || | ||
| 145 | globalize_translations.build(:locale => key.to_s) | ||
| 146 | translation.update_attributes!(options[key]) | ||
| 147 | end | ||
| 148 | end | ||
| 149 | |||
| 135 | end | 150 | end |
| 136 | end | 151 | end |
| 137 | end | 152 | end |
