yaml-translator 0.8.1 → 0.8.2

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: e1f9fe0d6a97dd9b77fbb6b0518de26eeb8653a9
4
- data.tar.gz: 216b96151e446e5b3ced6e2451cff5cbe0bd5ac8
3
+ metadata.gz: 0d076ea46fb1b164013c237fe69d471f175ff5f8
4
+ data.tar.gz: fc4419c8af60700a7b5c5f376f6e55996bea458c
5
5
  SHA512:
6
- metadata.gz: e374a1b1baff8cc9ceed7359852e087c10f7c89fba3a51bfbe24fab721424a170583391e8e600dd59f6005ba5ec155e1390dbeda0ecead3404e295ca2191a29a
7
- data.tar.gz: ac81f565b8ae5f32e6bf9476a77a35650d517de39742b61f82b787b228cbe1df790d53b8d13a513b93ffb2b6834bd2857637df2e151de44c366c679d371cbb17
6
+ metadata.gz: e54f86d2255a306818b61b9e58690afca50282cd5f257b2c18665caa1335fde3d1742becb77de6b7ef92b0909f7141cd0e39645e5e4c210be56be5d1ef98ef82
7
+ data.tar.gz: d80d766b17844ce696108aeb9ab4a4aab07505315b88b91f64c3aa7acc0c542848e255f1678644b3b8faae10f9741dce782438dbb58ac560e5e3518eb03d204e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- yaml-translator (0.8.1)
4
+ yaml-translator (0.8.2)
5
5
  diff-lcs
6
6
  easy_translate
7
7
 
@@ -13,7 +13,12 @@ module YamlTranslator
13
13
  # @return [Locale] locale
14
14
  def translate(locale, options={})
15
15
  translated = @adapter.translate(locale.to_single_key_hash, options)
16
- Locale.new(translated.to_tree, options[:to])
16
+ translated_tree = translated.to_tree
17
+
18
+ result = {}
19
+ result[options[:to].to_s] = translated_tree[locale.lang]
20
+
21
+ Locale.new(result, options[:to])
17
22
  end
18
23
 
19
24
  def string(s)
@@ -1,3 +1,3 @@
1
1
  module YamlTranslator
2
- VERSION = '0.8.1'
2
+ VERSION = '0.8.2'
3
3
  end
@@ -1,3 +1,4 @@
1
+ ---
1
2
  ja:
2
3
  bar: bar
3
4
  foo: foo
@@ -1,36 +1,21 @@
1
1
  describe YamlTranslator::Translator do
2
2
  let(:translator) { YamlTranslator::Translator.new }
3
- describe '#translate' do
4
- context 'when have root' do
5
- let(:yaml_tree) { load_yaml(:with_root) }
6
- let(:locale) { YamlTranslator::Locale.new(yaml_tree, :en) }
7
- it 'translated tree' do
8
- translated_locale = translator.translate(locale)
9
- expect(translated_locale.values).to eq(locale.values)
10
- end
11
- end
12
- context 'when have root' do
13
- let(:yaml_tree) { load_yaml(:no_root) }
14
- let(:locale) { YamlTranslator::Locale.new(yaml_tree, :en) }
15
- it 'translated tree' do
16
- translated_locale = translator.translate(locale)
17
- expect(translated_locale.values).to eq(locale.values)
18
- end
19
- end
20
- end
21
3
  describe '#file' do
22
- let(:path) { yaml_path(:en) }
4
+ let(:path) { yaml_path(:ja) }
23
5
  let(:expected_locale) { YamlTranslator::Locale.load_file(path) }
24
6
  it 'translate files' do
25
- result = translator.file(path).to(:en)
7
+ result = translator.file(path).to(:ja)
8
+ expect(result.lang).to eq(:ja)
26
9
  expect(result.values).to eq(expected_locale.values)
27
10
  end
28
11
  end
29
12
  describe '#string' do
13
+ let(:path) { yaml_path(:ja) }
30
14
  let(:yaml_source) { yaml_contents(:en) }
31
- let(:expected_locale) { YamlTranslator::Locale.load(yaml_source) }
15
+ let(:expected_locale) { YamlTranslator::Locale.load_file(path) }
32
16
  it 'translate yaml string' do
33
- result = translator.string(yaml_source).to(:en)
17
+ result = translator.string(yaml_source).to(:ja)
18
+ expect(result.lang).to eq(:ja)
34
19
  expect(result.values).to eq(expected_locale.values)
35
20
  end
36
21
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaml-translator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noritaka Horio
@@ -173,9 +173,8 @@ files:
173
173
  - spec/fixtures/diff/after/en.yml
174
174
  - spec/fixtures/diff/before/en.yml
175
175
  - spec/fixtures/en.yml
176
+ - spec/fixtures/ja.yml
176
177
  - spec/fixtures/merge_target.yml
177
- - spec/fixtures/no_root.yml
178
- - spec/fixtures/with_root.yml
179
178
  - spec/helpers/locale_helper.rb
180
179
  - spec/spec_helper.rb
181
180
  - spec/yaml-translator/locale_spec.rb
@@ -212,9 +211,8 @@ test_files:
212
211
  - spec/fixtures/diff/after/en.yml
213
212
  - spec/fixtures/diff/before/en.yml
214
213
  - spec/fixtures/en.yml
214
+ - spec/fixtures/ja.yml
215
215
  - spec/fixtures/merge_target.yml
216
- - spec/fixtures/no_root.yml
217
- - spec/fixtures/with_root.yml
218
216
  - spec/helpers/locale_helper.rb
219
217
  - spec/spec_helper.rb
220
218
  - spec/yaml-translator/locale_spec.rb
@@ -1,5 +0,0 @@
1
- bar: bar
2
- foo: foo
3
- foo1:
4
- foo1: foo1-1
5
- foo2: foo1-2