yaml-translator 0.11.0 → 0.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/example/{en.yml → diff/none/en.yml} +0 -0
- data/example/diff/none/new.en.yml +2 -0
- data/example/diff/some/en.yml +2 -0
- data/example/{new.en.yml → diff/some/new.en.yml} +0 -0
- data/example/diff_translate.rb +8 -3
- data/lib/yaml-translator/adapters/google_translate_adapter.rb +1 -1
- data/lib/yaml-translator/version.rb +1 -1
- data/spec/yaml-translator/adapters/google_translate_adapter_spec.rb +32 -0
- metadata +8 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4a831e015e8495d91dfcd7ce06da490c2e92a8c
|
4
|
+
data.tar.gz: 19a700af24925a9b0bbb79324e057c63d0a50faf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f6f078dadceae0715d084bafa2ee1431947ea4f92d4b4d3f353670b909c62b2995857b51f34f6f7535d5add5b9acd1acd8244bf818d82eb41f6bff91702ccad
|
7
|
+
data.tar.gz: 8b28ba8cb0953650264e528b23591c3c1438d1c2b0fef1d3fda0eb296c96f668628eb2a7d41b03b085eb5b1f6b0d3fad62dc130b32f238491b12c9ef2593dadc
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
yaml-translator (0.11.
|
4
|
+
yaml-translator (0.11.1)
|
5
5
|
diff-lcs
|
6
6
|
easy_translate
|
7
7
|
|
@@ -58,7 +58,7 @@ GEM
|
|
58
58
|
tins (~> 0.8)
|
59
59
|
thor (0.18.1)
|
60
60
|
thread (0.2.2)
|
61
|
-
thread_safe (0.3.
|
61
|
+
thread_safe (0.3.6)
|
62
62
|
tins (0.13.2)
|
63
63
|
|
64
64
|
PLATFORMS
|
File without changes
|
File without changes
|
data/example/diff_translate.rb
CHANGED
@@ -3,11 +3,16 @@ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
|
3
3
|
require 'yaml'
|
4
4
|
require 'yaml-translator'
|
5
5
|
|
6
|
-
dir = File.dirname(__FILE__)
|
7
6
|
translator = ::YamlTranslator.create(
|
8
7
|
:google_translate,
|
9
8
|
api_key: ENV['GOOGLE_TRANSLATE_API_KEY']
|
10
9
|
)
|
11
10
|
|
12
|
-
|
13
|
-
diff_locale.
|
11
|
+
diff_some_dir = File.join(File.dirname(__FILE__), 'diff/some')
|
12
|
+
diff_locale = translator.file("#{diff_some_dir}/en.yml").diff("#{diff_some_dir}/new.en.yml")
|
13
|
+
diff_locale.to(:ja).save_to("/tmp", prefix: 'some_diff.')
|
14
|
+
|
15
|
+
# diff nothing!!
|
16
|
+
diff_none_dir = File.join(File.dirname(__FILE__), 'diff/none')
|
17
|
+
diff_locale = translator.file("#{diff_none_dir}/en.yml").diff("#{diff_none_dir}/new.en.yml")
|
18
|
+
diff_locale.to(:ja).save_to("/tmp", prefix: 'no_diff.')
|
@@ -0,0 +1,32 @@
|
|
1
|
+
describe YamlTranslator::Adapters::GoogleTranslateAdapter do
|
2
|
+
let(:adapter) { YamlTranslator::Adapters::GoogleTranslateAdapter.new(api_key: 'xyz') }
|
3
|
+
describe '#translate' do
|
4
|
+
context 'when some values' do
|
5
|
+
let(:some_values) do
|
6
|
+
values = {}
|
7
|
+
values['en.foo'] = 'a_b'
|
8
|
+
values['en.bar'] = 'b_b'
|
9
|
+
values
|
10
|
+
end
|
11
|
+
before do
|
12
|
+
allow(EasyTranslate).to receive(:translate).and_return(['a_a', 'a_b'])
|
13
|
+
end
|
14
|
+
subject { adapter.translate(some_values, to: :ja) }
|
15
|
+
it 'should be return translate results' do
|
16
|
+
expect(subject.size).to be 2
|
17
|
+
expect(subject['en.foo']).to eq('a_a')
|
18
|
+
expect(subject['en.bar']).to eq('a_b')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
context 'when empty values' do
|
22
|
+
let(:null_values) { {} }
|
23
|
+
before do
|
24
|
+
allow(EasyTranslate).to receive(:translate).and_return(nil)
|
25
|
+
end
|
26
|
+
subject { adapter.translate(null_values, to: :ja) }
|
27
|
+
it 'should be return empty' do
|
28
|
+
expect(subject.size).to be 0
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml-translator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.11.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noritaka Horio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: easy_translate
|
@@ -153,9 +153,11 @@ files:
|
|
153
153
|
- LICENSE
|
154
154
|
- README.md
|
155
155
|
- Rakefile
|
156
|
+
- example/diff/none/en.yml
|
157
|
+
- example/diff/none/new.en.yml
|
158
|
+
- example/diff/some/en.yml
|
159
|
+
- example/diff/some/new.en.yml
|
156
160
|
- example/diff_translate.rb
|
157
|
-
- example/en.yml
|
158
|
-
- example/new.en.yml
|
159
161
|
- example/simple.rb
|
160
162
|
- lib/yaml-translator.rb
|
161
163
|
- lib/yaml-translator/adapters.rb
|
@@ -175,6 +177,7 @@ files:
|
|
175
177
|
- spec/fixtures/zh-CN.yml
|
176
178
|
- spec/helpers/locale_helper.rb
|
177
179
|
- spec/spec_helper.rb
|
180
|
+
- spec/yaml-translator/adapters/google_translate_adapter_spec.rb
|
178
181
|
- spec/yaml-translator/context_spec.rb
|
179
182
|
- spec/yaml-translator/locale_spec.rb
|
180
183
|
- spec/yaml-translator/translator_spec.rb
|
@@ -213,6 +216,7 @@ test_files:
|
|
213
216
|
- spec/fixtures/zh-CN.yml
|
214
217
|
- spec/helpers/locale_helper.rb
|
215
218
|
- spec/spec_helper.rb
|
219
|
+
- spec/yaml-translator/adapters/google_translate_adapter_spec.rb
|
216
220
|
- spec/yaml-translator/context_spec.rb
|
217
221
|
- spec/yaml-translator/locale_spec.rb
|
218
222
|
- spec/yaml-translator/translator_spec.rb
|