ad_localize 3.3.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4a46683de0e489838b53aae0ddd3a4e7e52a0089013fac5b49a07a558bfd322
|
4
|
+
data.tar.gz: 11523ebff556f015ae9e0a7ec76bf50f75d9317b9fd272e2f0b28e84ae0a070d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7432f6a5dd72d4635b3c07215ffb2d7afe357a5f93aca0d04635c20c15494571d580af9572ce38b0805afb1762d714dc73ef71ae8f5bd855ebfdfb8dbe9eef0d
|
7
|
+
data.tar.gz: 5e726801cb6f26bf2c58787297a1e0639cd403f7d9d22c3a8ce82d04fb65a8e3d8cd3b6a94cf1057f9d0b32ebcab9d79ba00867f50d3add3815cd450b945b097
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
+
## [3.4.0] - 2019-02-10
|
8
|
+
### Added
|
9
|
+
- Rails folks, [@epaillous](https://github.com/epaillous) has improved the YAML support. You can now have multi-level wording.
|
10
|
+
|
11
|
+
## [3.3.0] - 2019-02-10
|
12
|
+
### Added
|
13
|
+
- improve React support using keys with dots to generate nested JSON files by [@epaillous](https://github.com/epaillous)
|
14
|
+
|
7
15
|
## [3.2.0] - 2019-12-10
|
8
16
|
### Added
|
9
17
|
- Add tests to compare reference exports by [@felginep](https://github.com/felginep)
|
@@ -6,43 +6,12 @@ module AdLocalize::Platform
|
|
6
6
|
|
7
7
|
def export(locale, data, export_extension = "json", substitution_format = "react")
|
8
8
|
locale = locale.to_sym
|
9
|
-
json_data =
|
10
|
-
hash_acc[locale.to_s] = {} unless hash_acc.key? locale.to_s
|
11
|
-
keys = key.to_s.split('.')
|
12
|
-
hash = hash_acc[locale.to_s]
|
13
|
-
keys.each_with_index do |inner_key, index|
|
14
|
-
if index === keys.count - 1
|
15
|
-
fill_hash(wording, locale, hash, inner_key)
|
16
|
-
else
|
17
|
-
if hash[inner_key].nil?
|
18
|
-
hash[inner_key] = {}
|
19
|
-
end
|
20
|
-
hash = hash[inner_key]
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
9
|
+
json_data = build_platform_data_splitting_on_dots(locale, data)
|
25
10
|
platform_dir.join("#{locale.to_s}.#{export_extension}").open("w") do |file|
|
26
11
|
file.puts json_data.to_json
|
27
12
|
end
|
28
13
|
|
29
14
|
AdLocalize::LOGGER.log(:debug, :green, "JSON [#{locale}] ---> DONE!")
|
30
15
|
end
|
31
|
-
|
32
|
-
protected
|
33
|
-
|
34
|
-
def fill_hash(wording, locale, hash, key)
|
35
|
-
if wording.dig(locale)&.key? :singular
|
36
|
-
value = wording.dig(locale, :singular)
|
37
|
-
hash[key.to_s] = value
|
38
|
-
end
|
39
|
-
if wording.dig(locale)&.key? :plural
|
40
|
-
hash[key.to_s] = {}
|
41
|
-
wording.dig(locale, :plural).each do |plural_type, plural_text|
|
42
|
-
value = plural_text
|
43
|
-
hash[key.to_s][plural_type.to_s] = value
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
16
|
end
|
48
17
|
end
|
@@ -72,5 +72,37 @@ module AdLocalize::Platform
|
|
72
72
|
export_dir(locale).mkdir
|
73
73
|
end
|
74
74
|
end
|
75
|
+
|
76
|
+
def build_platform_data_splitting_on_dots(locale, data)
|
77
|
+
data.each_with_object({}) do |(key, wording), hash_acc|
|
78
|
+
hash_acc[locale.to_s] = {} unless hash_acc.key? locale.to_s
|
79
|
+
keys = key.to_s.split('.')
|
80
|
+
hash = hash_acc[locale.to_s]
|
81
|
+
keys.each_with_index do |inner_key, index|
|
82
|
+
if index === keys.count - 1
|
83
|
+
fill_hash(wording, locale, hash, inner_key)
|
84
|
+
else
|
85
|
+
if hash[inner_key].nil?
|
86
|
+
hash[inner_key] = {}
|
87
|
+
end
|
88
|
+
hash = hash[inner_key]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
def fill_hash(wording, locale, hash, key)
|
95
|
+
if wording.dig(locale)&.key? :singular
|
96
|
+
value = wording.dig(locale, :singular)
|
97
|
+
hash[key.to_s] = value
|
98
|
+
end
|
99
|
+
if wording.dig(locale)&.key? :plural
|
100
|
+
hash[key.to_s] = {}
|
101
|
+
wording.dig(locale, :plural).each do |plural_type, plural_text|
|
102
|
+
value = plural_text
|
103
|
+
hash[key.to_s][plural_type.to_s] = value
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
75
107
|
end
|
76
108
|
end
|
@@ -5,14 +5,15 @@ module AdLocalize::Platform
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def export(locale, data, export_extension = "yml", substitution_format = "yml")
|
8
|
-
|
8
|
+
locale = locale.to_sym
|
9
|
+
yml_data = build_platform_data_splitting_on_dots(locale, data)
|
10
|
+
|
11
|
+
platform_dir.join("#{locale.to_s}.#{export_extension}").open("w") do |file|
|
9
12
|
file.puts yml_data.to_yaml
|
10
13
|
end
|
11
|
-
end
|
12
14
|
|
13
|
-
|
14
|
-
def ios_converter(value)
|
15
|
-
value.gsub(/(%(?!)?(\d+\$)?[@isd])/, "VARIABLE_TO_SET")
|
15
|
+
AdLocalize::LOGGER.log(:debug, :green, "YAML [#{locale}] ---> DONE!")
|
16
16
|
end
|
17
|
+
|
17
18
|
end
|
18
19
|
end
|
data/lib/ad_localize/version.rb
CHANGED