i18n_kit 0.0.2 → 0.0.3
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.
- data/VERSION +1 -1
- data/i18n_kit.gemspec +1 -1
- data/lib/i18n_kit/document.rb +12 -17
- data/lib/i18n_kit/importer/excel_xml.rb +0 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/i18n_kit.gemspec
CHANGED
data/lib/i18n_kit/document.rb
CHANGED
@@ -66,8 +66,12 @@ module I18nKit
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def to_flat_hash
|
69
|
-
|
70
|
-
|
69
|
+
if @flat_hash.size == 0 and @hash.size > 1
|
70
|
+
# On demand flattening
|
71
|
+
each_pair(@hash) do |key, value|
|
72
|
+
@flat_hash[key] = value
|
73
|
+
end
|
74
|
+
end
|
71
75
|
@flat_hash
|
72
76
|
end
|
73
77
|
|
@@ -78,21 +82,12 @@ module I18nKit
|
|
78
82
|
def to_s
|
79
83
|
@name
|
80
84
|
end
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
if value.is_a?(Hash)
|
87
|
-
new_root = root + [key]
|
88
|
-
populate_flat_hash(value, new_root)
|
89
|
-
else
|
90
|
-
data.each do |k, v|
|
91
|
-
flat_key = [root] + [k]
|
92
|
-
@flat_hash[flat_key.join('.')] = v
|
93
|
-
end
|
94
|
-
return
|
95
|
-
end
|
85
|
+
|
86
|
+
def each_pair(hash, prev_key=nil, &block)
|
87
|
+
hash.each do |key, value|
|
88
|
+
curr_key = [prev_key, key].compact.join('.').to_sym
|
89
|
+
yield curr_key.to_s, value unless value.is_a?(Hash)
|
90
|
+
each_pair(value, curr_key, &block) if value.is_a?(Hash)
|
96
91
|
end
|
97
92
|
end
|
98
93
|
|
@@ -44,7 +44,6 @@ module I18nKit
|
|
44
44
|
# This is every row except the header row
|
45
45
|
# The key is expected to be in the first column
|
46
46
|
key = columns[0].text.to_s.strip
|
47
|
-
puts row.inspect if key == 'buk.sell.contact.valuation.choose_closest_auction_house'
|
48
47
|
# Now let's read the translations for this key. I.e. all columns except the first one
|
49
48
|
locales.each_with_index do |locale, locale_index|
|
50
49
|
locale = locale.to_s
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_kit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- funkensturm.
|