zlocalize 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd7d0e00b29df94e177bcc0846a7baf7ad47b7e8
|
4
|
+
data.tar.gz: 5ba24f8718b66e38f85816fdbc26fa5e6390bae9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e608ee25898b040885ee9fd9bfd238613ab354fe555211e86b5376bee673089824e3d84ce72ca54e8c37ec7a6e5c0921528532bb2ad90b72dc6f75bdac78abe
|
7
|
+
data.tar.gz: 40836d8344fc7172bcbc7d023d934235b1a1fd75b869593b13770212e4ea3154e673fd0994329b239d8d191e67496643f27a1c677af6d73e1b6c2b963399ebe2
|
@@ -9,3 +9,5 @@ ActiveRecord::Base.send(:include, ZLocalize::Translatable::TranslatedColumns)
|
|
9
9
|
require 'zlocalize/rails/decimal_attributes'
|
10
10
|
ActiveRecord::Base.send(:include, ZLocalize::Translatable::LocalizedDecimalAttributes)
|
11
11
|
|
12
|
+
require 'zlocalize/rails/translated_attributes_serializer'
|
13
|
+
ActiveRecord::Base.send(:include, ZLocalize::Translatable::TranslatedAttributesSerializer)
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- encoding : utf-8 -*-
|
2
|
+
|
3
|
+
module ZLocalize
|
4
|
+
module Translatable #:nodoc:
|
5
|
+
|
6
|
+
module TranslatedAttributesSerializer #:nodoc:
|
7
|
+
|
8
|
+
def self.included(base)
|
9
|
+
base.extend(ClassMethods)
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
|
14
|
+
def serialize_translations(attribute_names,options = {})
|
15
|
+
|
16
|
+
serialize :translated_attributes, HashWithIndifferentAccess
|
17
|
+
|
18
|
+
[attribute_names].flatten.each do |attr_name|
|
19
|
+
class_eval "def #{attr_name}(options = {})
|
20
|
+
read_translated_attribute('#{attr_name}',(options[:locale] || ZLocalize.locale).to_s)
|
21
|
+
end"
|
22
|
+
end
|
23
|
+
|
24
|
+
class_eval "after_initialize do
|
25
|
+
self.translated_attributes ||= HashWithIndifferentAccess.new
|
26
|
+
end
|
27
|
+
|
28
|
+
def translated_attributes=(value)
|
29
|
+
self.translations = value
|
30
|
+
end"
|
31
|
+
|
32
|
+
include ZLocalize::Translatable::TranslatedAttributesSerializer::InstanceMethods
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module InstanceMethods
|
37
|
+
|
38
|
+
def read_translated_attribute(attr_name,locale)
|
39
|
+
s = self.translated_attributes[locale]
|
40
|
+
s.is_a?(Hash) ? s[attr_name] : nil
|
41
|
+
end
|
42
|
+
|
43
|
+
alias :translate :read_translated_attribute
|
44
|
+
|
45
|
+
def translations=(locales)
|
46
|
+
locales.each do |locale,terms|
|
47
|
+
self.translated_attributes[locale] ||= HashWithIndifferentAccess.new
|
48
|
+
terms.each do |name,value|
|
49
|
+
self.translated_attributes[locale][name] = value
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end # module InstanceMethods
|
55
|
+
|
56
|
+
end # module TranslatedAttributesSerializer
|
57
|
+
end # module Translatable
|
58
|
+
end # module ZLocalize
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zlocalize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Bedard
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-04-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -68,7 +68,9 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 0.5.0
|
70
70
|
description:
|
71
|
-
email:
|
71
|
+
email:
|
72
|
+
- zzeligg@gmail.com
|
73
|
+
- steph@zboing.ca
|
72
74
|
executables: []
|
73
75
|
extensions: []
|
74
76
|
extra_rdoc_files: []
|
@@ -85,6 +87,7 @@ files:
|
|
85
87
|
- lib/zlocalize/rails/generators/translations_migration.rb
|
86
88
|
- lib/zlocalize/rails/railtie.rb
|
87
89
|
- lib/zlocalize/rails/tasks/harvest.rake
|
90
|
+
- lib/zlocalize/rails/translated_attributes_serializer.rb
|
88
91
|
- lib/zlocalize/rails/translated_columns.rb
|
89
92
|
- lib/zlocalize/rails/translation.rb
|
90
93
|
- lib/zlocalize/rails/translation_validator.rb
|