translation 0.9 → 0.9.1

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: 96b136aa820f7455c6c3af78bf5098fd73393a8e
4
- data.tar.gz: 1eb107b37045580973bed903b04a8744fed5911b
3
+ metadata.gz: f220780138083246a7e89af3a5be22755bffed3f
4
+ data.tar.gz: 813d658f8cd40f6baf0891da1942917db95ccdf0
5
5
  SHA512:
6
- metadata.gz: 39064ef60e74ac879135ca2742f6193aa9531bc30f84393481934b301eace673089c9358242daf9fe211e886363683eeafad88267957c899aa7230b8a80450c4
7
- data.tar.gz: 47dd370a7fce5fa558f005d7fa9bda3b7e9f60d7b716ee9ac7a4f959cfad4deba5ab1dcd29b7abfd0bb59f97ef75b44de3bfe14dd669946f9b4b528fe567262a
6
+ metadata.gz: 129e6253e5f5f1a8032e618c9b6cf5e5469449230a5e05779c5ee1835b471080e98cff1b411f1c8064debd431f5e6f49fbd85a7dd3fcd61bac091ef60d70e78e
7
+ data.tar.gz: 6b3604af2e1fb9288adbc134e9d117b659490620e895566a14b051097722788af36a74ba1cb273805c7b8c38e318d133c26c2c2cc9d621d382f308b91792e5b9
@@ -16,6 +16,7 @@ module TranslationIO
16
16
  FileUtils.mkdir_p(@yaml_locales_path)
17
17
  yaml_path = File.join(@yaml_locales_path, "translation.#{target_locale}.yml")
18
18
  TranslationIO.info yaml_path, 2, 2
19
+
19
20
  yaml_data = YAMLConversion.get_yaml_data_from_po_data(@parsed_response["yaml_po_data_#{target_locale}"], target_locale)
20
21
 
21
22
  top_comment = <<EOS
@@ -2,7 +2,8 @@ module TranslationIO
2
2
  module FlatHash
3
3
  class << self
4
4
  def to_flat_hash(hash)
5
- hash = brackets_to_joker(hash)
5
+ hash = brackets_to_joker!(hash)
6
+ hash = remove_reserved_keys!(hash)
6
7
  get_flat_hash_for_level(hash)
7
8
  end
8
9
 
@@ -13,7 +14,7 @@ module TranslationIO
13
14
  build_hash_with_flat(hash, key, value)
14
15
  end
15
16
 
16
- joker_to_brackets(hash)
17
+ joker_to_brackets!(hash)
17
18
  end
18
19
 
19
20
  private
@@ -107,11 +108,11 @@ module TranslationIO
107
108
  flat_hash
108
109
  end
109
110
 
110
- def brackets_to_joker(h)
111
+ def brackets_to_joker!(h)
111
112
  gsub_keys!(h, '[', ']', '<@~<', '>@~>')
112
113
  end
113
114
 
114
- def joker_to_brackets(h)
115
+ def joker_to_brackets!(h)
115
116
  gsub_keys!(h, '<@~<', '>@~>', '[', ']')
116
117
  end
117
118
 
@@ -131,6 +132,21 @@ module TranslationIO
131
132
  end
132
133
  h
133
134
  end
135
+
136
+ def remove_reserved_keys!(h)
137
+ if h.is_a?(Hash)
138
+ h.keys.each do |key|
139
+ if [TrueClass, FalseClass].include?(key.class)
140
+ h.delete(key)
141
+ else
142
+ remove_reserved_keys!(h[key])
143
+ end
144
+ end
145
+ elsif h.respond_to?(:each)
146
+ h.each { |e| remove_reserved_keys!(e) }
147
+ end
148
+ h
149
+ end
134
150
  end
135
151
  end
136
152
  end
@@ -20,7 +20,7 @@ end
20
20
  module I18n
21
21
  class Config
22
22
  def locale=(locale)
23
- I18n.enforce_available_locales!(locale)
23
+ I18n.enforce_available_locales!(locale) if I18n.respond_to?(:enforce_available_locales!)
24
24
  @locale = locale.to_sym rescue nil
25
25
  GetText.locale = locale.to_s.gsub('-', '_').to_sym
26
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: translation
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9'
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurelien Malisart
@@ -124,4 +124,3 @@ signing_key:
124
124
  specification_version: 4
125
125
  summary: Rails translation made _("simple") with YAML and GetText.
126
126
  test_files: []
127
- has_rdoc: false