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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d076ea46fb1b164013c237fe69d471f175ff5f8
|
4
|
+
data.tar.gz: fc4419c8af60700a7b5c5f376f6e55996bea458c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e54f86d2255a306818b61b9e58690afca50282cd5f257b2c18665caa1335fde3d1742becb77de6b7ef92b0909f7141cd0e39645e5e4c210be56be5d1ef98ef82
|
7
|
+
data.tar.gz: d80d766b17844ce696108aeb9ab4a4aab07505315b88b91f64c3aa7acc0c542848e255f1678644b3b8faae10f9741dce782438dbb58ac560e5e3518eb03d204e
|
data/Gemfile.lock
CHANGED
@@ -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
|
-
|
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,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(:
|
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(:
|
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.
|
15
|
+
let(:expected_locale) { YamlTranslator::Locale.load_file(path) }
|
32
16
|
it 'translate yaml string' do
|
33
|
-
result = translator.string(yaml_source).to(:
|
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.
|
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
|