embedded_localization 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
data/README.textile
CHANGED
@@ -81,7 +81,7 @@ end
|
|
81
81
|
|
82
82
|
h4. NOTE:
|
83
83
|
|
84
|
-
EmbeddedLocalization implementations < 0.2.0
|
84
|
+
EmbeddedLocalization implementations < 0.2.0 had the drawback that you can not do SQL queries on translated attributes.
|
85
85
|
|
86
86
|
To eliminate this limitation, you can now define any translated attribute as a first-class database column in your migration. If you define a translated attribute as a column, EmbeddedLocalization will store the attribute value for I18n.default_locale in that column, so you can search for it. After defining the column, and running the migration, you need to populate the column initially. It will auto-update every time you write while you are using I18n.default_locale .
|
87
87
|
e.g.:
|
@@ -205,6 +205,9 @@ If your requirements are different, my approach might not work for you. In that
|
|
205
205
|
|
206
206
|
h2. Changes
|
207
207
|
|
208
|
+
h3. 0.2.3 (2012-03-02)
|
209
|
+
* Issue #4 : bugfix for attr_writer - no longer updates attributes if value didn't change => timestamps don't change in that case
|
210
|
+
|
208
211
|
h3. 0.2.2 (2012-02-06)
|
209
212
|
* bugfix for attr_writer
|
210
213
|
|
@@ -67,6 +67,12 @@ module EmbeddedLocalization
|
|
67
67
|
# define the setter method
|
68
68
|
#
|
69
69
|
define_method(attr_name.to_s+ '=') do |new_translation|
|
70
|
+
# first check if nothing changed - then we can just return, so that timestamps and other records don't get touched
|
71
|
+
if self.i18n.class == Hash && (self.i18n[I18n.locale]) && (self.i18n[I18n.locale][attr_name.to_sym] == new_translation)
|
72
|
+
return if (I18n.locale != I18n.default_locale)
|
73
|
+
return if (I18n.locale == I18n.default_locale) && (read_attribute(attr_name) == new_translation) # both i18n and attr_name need to be equal to new_translation
|
74
|
+
end
|
75
|
+
|
70
76
|
self.i18n_will_change! # for ActiveModel Dirty tracking
|
71
77
|
if self.attributes.has_key?(attr_name.to_s) # if user has defined DB field with that name
|
72
78
|
write_attribute(attr_name , new_translation) if I18n.locale == I18n.default_locale
|
@@ -17,6 +17,12 @@ module EmbeddedLocalization
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def set_localized_attribute(attr_name, locale, new_translation)
|
20
|
+
# first check if nothing changed - then we can just return, so that timestamps and other records don't get touched
|
21
|
+
if self.i18n.class == Hash && (self.i18n[I18n.locale]) && (self.i18n[I18n.locale][attr_name.to_sym] == new_translation)
|
22
|
+
return if (I18n.locale != I18n.default_locale)
|
23
|
+
return if (I18n.locale == I18n.default_locale) && (read_attribute(attr_name) == new_translation) # both i18n and attr_name need to be equal to new_translation
|
24
|
+
end
|
25
|
+
|
20
26
|
self.i18n_will_change! # for ActiveModel Dirty tracking
|
21
27
|
if self.attributes.has_key?(attr_name.to_s) # if user has defined DB field with that name
|
22
28
|
write_attribute(attr_name , new_translation) if locale == I18n.default_locale
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: embedded_localization
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Tilo Sloboda
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-02
|
13
|
+
date: 2012-03-02 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: "Rails I18n: Embedded_Localization for ActiveRecord 3 is very lightweight, and allows you to transparently store translations of attributes right inside each record -- no extra database tables needed to store the localization data!"
|