promethee 4.1.4 → 4.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/promethee/data/localization.rb +21 -5
- data/lib/promethee/rails/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7d821ae071c08da48380617b5ca9f0f601256a00dd8e27b553ede3475785217
|
4
|
+
data.tar.gz: c7eeabfdbfdcad6b7ef5fb2e19989e5bdb72c7dc75ec88cadfa90ef98e8315ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4562917821c9211f589d2a6dcd457e1af5451b8ccd1e00daf087f88464720e97e2b3ff35c1eb4f6b0b25150f256040dc739ef3f2260ad4f819df4c7f183bba8
|
7
|
+
data.tar.gz: 0a35e27bb871f285a213bae214f7c177e36028c3a86e94f8805f17aea4fba2104f33f9c6a9327a3f2e86253878a793c6ee8e17f9562840c51d206e4253bb1557
|
@@ -11,11 +11,13 @@ class Promethee::Data::Localization < Promethee::Data
|
|
11
11
|
|
12
12
|
# We want to be up to date with the master, so this method will:
|
13
13
|
# 1.take the master's components flattened
|
14
|
-
# 2 substitute what's already localized, based on the component id
|
14
|
+
# 2 substitute values of what's already localized, based on the component id
|
15
15
|
# Consequences of step 1 are:
|
16
16
|
# 1 it adds new components from the master
|
17
17
|
# 2 it removes components not in the master anymore
|
18
18
|
# 3 it takes the order from the master
|
19
|
+
# 4 use all translatable attributes from the master
|
20
|
+
# 5 merge them with translation values if they exist
|
19
21
|
def merge
|
20
22
|
@data_before_merge = @data.deep_dup
|
21
23
|
@data = {
|
@@ -23,11 +25,10 @@ class Promethee::Data::Localization < Promethee::Data
|
|
23
25
|
components: []
|
24
26
|
}
|
25
27
|
@master_data.flat.each do |master_component|
|
28
|
+
translatable_master_component = get_component_without_attributes_values(master_component)
|
26
29
|
localized_component = find_localized_component master_component[:id]
|
27
|
-
|
28
|
-
component = localized_component
|
29
|
-
component[:attributes] ||= {}
|
30
|
-
# We add it to the list of localized components
|
30
|
+
|
31
|
+
component = get_merged_translatable_component(translatable_master_component, localized_component)
|
31
32
|
@data[:components] << component
|
32
33
|
end
|
33
34
|
end
|
@@ -43,6 +44,21 @@ class Promethee::Data::Localization < Promethee::Data
|
|
43
44
|
clean_component
|
44
45
|
end
|
45
46
|
|
47
|
+
def get_merged_translatable_component(master_component, localized_component)
|
48
|
+
# Not found in translation, we use the prepared master component
|
49
|
+
return master_component if localized_component.nil?
|
50
|
+
|
51
|
+
master_component[:attributes] ||= {}
|
52
|
+
localized_component[:attributes] ||= {}
|
53
|
+
|
54
|
+
# Merge values with the prepared master, allowing to add missing attributes from translation
|
55
|
+
master_component[:attributes].each do |attr_key, attr_value|
|
56
|
+
attr_value[:value] = localized_component.dig(:attributes, attr_key, :value) || ''
|
57
|
+
end
|
58
|
+
|
59
|
+
master_component
|
60
|
+
end
|
61
|
+
|
46
62
|
def find_localized_component(id)
|
47
63
|
return unless @data_before_merge
|
48
64
|
return unless @data_before_merge.include? :components
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promethee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1.
|
4
|
+
version: 4.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sébastien Gaya
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2020-03
|
17
|
+
date: 2020-04-03 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: rails
|