twine 1.1.2 → 1.1.3

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: 381bd0d84850220b7ef1f8071a7398eb6c61e1f7c5bc057e5d96cd259f0f4578
4
- data.tar.gz: 04a94d58790f88c95cf3ae000986f7f0df62165e2749cdc22e409fef391e2760
3
+ metadata.gz: a0ddd09377d4bdc637c451ef936e94532bd6af7986cbe7ff490732ff0a42ff6d
4
+ data.tar.gz: 93dbc48a7c9b10681ddbc0fc996f02e15c8658144da6d1a285628543cec30a5d
5
5
  SHA512:
6
- metadata.gz: f14b9de69dcd4a533fa5b769dc42a2601caec06d41e04470188fa3a59a3e418d53e2d2994bce2c119fec6fee8252a7d7e421b58cd90316e98a527422c6a19551
7
- data.tar.gz: 60bc8c8c800d1f4b3e3b1664504052bf4dc561fe97f1e62b361943de6567e5a5d22902c98f485e03f1e651f76765a7951142c915576ee80dfc6ae933df12139c
6
+ metadata.gz: 5565a7205236780b07f99b1fc8e7d7e8a22b11ee67bf08137aed0660cf49e283bbdfc9d86e2073dc689b98a5167de9bd2f17c5cde266580455e04d66d92559ac
7
+ data.tar.gz: 47616ba00b6f17de2eda9aac730b4595e21a2e43395b1bc95a6eb5bd44d656d31c71f9fbab87d8ff7d393357602998769f511930dee1c23ca6372e956d425000
@@ -20,6 +20,16 @@ module Twine
20
20
  return super
21
21
  end
22
22
 
23
+ def set_translation_for_key_recursive(key, lang, value)
24
+ if value.is_a?(Hash)
25
+ value.each do |key2, value2|
26
+ set_translation_for_key_recursive(key+"."+key2, lang, value2)
27
+ end
28
+ else
29
+ set_translation_for_key(key, lang, value)
30
+ end
31
+ end
32
+
23
33
  def read(io, lang)
24
34
  begin
25
35
  require "json"
@@ -29,7 +39,7 @@ module Twine
29
39
 
30
40
  json = JSON.load(io)
31
41
  json.each do |key, value|
32
- set_translation_for_key(key, lang, value)
42
+ set_translation_for_key_recursive(key, lang, value)
33
43
  end
34
44
  end
35
45
 
data/lib/twine/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Twine
2
- VERSION = '1.1.2'
2
+ VERSION = '1.1.3'
3
3
  end
@@ -0,0 +1,11 @@
1
+ {
2
+ "key1":"value1-english",
3
+ "key2":"value2-english",
4
+
5
+ "key3":"value3-english",
6
+ "key4":"value4-english",
7
+ "key5":{
8
+ "key5a":"value5a-english",
9
+ "key5b":"value5b-english"
10
+ }
11
+ }
@@ -28,6 +28,14 @@ class FormatterTest < TwineTest
28
28
  end
29
29
  end
30
30
 
31
+ def assert_nested_translations_read_correctly
32
+ 1.upto(4) do |i|
33
+ assert_equal "value#{i}-english", @empty_twine_file.definitions_by_key["key#{i}"].translations['en']
34
+ end
35
+ assert_equal "value5a-english", @empty_twine_file.definitions_by_key["key5.key5a"].translations['en']
36
+ assert_equal "value5b-english", @empty_twine_file.definitions_by_key["key5.key5b"].translations['en']
37
+ end
38
+
31
39
  def assert_file_contents_read_correctly
32
40
  assert_translations_read_correctly
33
41
 
@@ -442,6 +450,12 @@ class TestJQueryFormatter < FormatterTest
442
450
  assert_translations_read_correctly
443
451
  end
444
452
 
453
+ def test_read_format_nested
454
+ @formatter.read content_io('formatter_jquery_nested.json'), 'en'
455
+
456
+ assert_nested_translations_read_correctly
457
+ end
458
+
445
459
  def test_format_file
446
460
  formatter = Twine::Formatters::JQuery.new
447
461
  formatter.twine_file = @twine_file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twine
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastian Celis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-15 00:00:00.000000000 Z
11
+ date: 2023-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rexml
@@ -154,6 +154,7 @@ files:
154
154
  - test/fixtures/formatter_gettext.po
155
155
  - test/fixtures/formatter_gettext_quotes.po
156
156
  - test/fixtures/formatter_jquery.json
157
+ - test/fixtures/formatter_jquery_nested.json
157
158
  - test/fixtures/formatter_tizen.xml
158
159
  - test/fixtures/gettext_multiline.po
159
160
  - test/fixtures/twine_accent_values.txt
@@ -176,7 +177,7 @@ homepage: https://github.com/scelis/twine
176
177
  licenses:
177
178
  - BSD-3-Clause
178
179
  metadata: {}
179
- post_install_message:
180
+ post_install_message:
180
181
  rdoc_options: []
181
182
  require_paths:
182
183
  - lib
@@ -191,21 +192,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  - !ruby/object:Gem::Version
192
193
  version: '0'
193
194
  requirements: []
194
- rubygems_version: 3.1.2
195
- signing_key:
195
+ rubygems_version: 3.4.10
196
+ signing_key:
196
197
  specification_version: 4
197
198
  summary: Manage strings and their translations for your iOS, Android and other projects.
198
199
  test_files:
199
- - test/test_formatters.rb
200
- - test/test_output_processor.rb
201
- - test/test_consume_localization_file.rb
202
- - test/test_consume_localization_archive.rb
203
200
  - test/test_abstract_formatter.rb
204
201
  - test/test_cli.rb
205
- - test/test_twine_file.rb
206
- - test/test_generate_localization_file.rb
202
+ - test/test_consume_localization_archive.rb
203
+ - test/test_consume_localization_file.rb
204
+ - test/test_formatters.rb
207
205
  - test/test_generate_all_localization_files.rb
208
206
  - test/test_generate_localization_archive.rb
209
- - test/test_twine_definition.rb
207
+ - test/test_generate_localization_file.rb
208
+ - test/test_output_processor.rb
210
209
  - test/test_placeholders.rb
210
+ - test/test_twine_definition.rb
211
+ - test/test_twine_file.rb
211
212
  - test/test_validate_twine_file.rb