tr4n5l4te 0.1.3 → 0.1.4
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 +4 -4
- data/CHANGELOG +4 -0
- data/README.md +11 -1
- data/lib/tr4n5l4te.rb +14 -4
- data/lib/tr4n5l4te/agent.rb +5 -1
- data/lib/tr4n5l4te/configuration.rb +9 -0
- data/lib/tr4n5l4te/runner.rb +15 -3
- data/lib/tr4n5l4te/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4340f6701e586bd8b845004b3006e58574cacba1
|
|
4
|
+
data.tar.gz: eaf2a16a128c494b29e227b9f1eeaf9981cc4cfb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5ddde917d746dca94e383478f264db6a0b8be60afa0578db9ea071e31a95cd0ece374f947edc2de8ad2ba16a9b39e4743a0a644f6da8c10d648753c8de332fd9
|
|
7
|
+
data.tar.gz: c46a604bc040415700ef356656df1ebfbc1ed25a43e18c23a5a4b42bdb82c0e9f33248b2fad42c11d05dde684a9e37a3994e0b29e10778322a4781e1448907c2
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Tr4n5l4te
|
|
2
2
|
|
|
3
|
-
**Version: 0.1.
|
|
3
|
+
**Version: 0.1.4**
|
|
4
4
|
|
|
5
5
|
Use Google Translate without an API key.
|
|
6
6
|
|
|
@@ -43,6 +43,16 @@ end
|
|
|
43
43
|
|
|
44
44
|
### Command Line
|
|
45
45
|
|
|
46
|
+
➤ ./exe/translate -h
|
|
47
|
+
Options:
|
|
48
|
+
-y, --yaml-file=<s> A YAML locale file - filename determines source language 'en.yml' - English
|
|
49
|
+
-l, --lang=<s> Destination language
|
|
50
|
+
-i, --list List known languages
|
|
51
|
+
-s, --sleep-time=<i> Sleep time (default: 2)
|
|
52
|
+
-t, --timeout=<i> Poltergeist timeout option (default: 30)
|
|
53
|
+
-v, --verbose Be verbose with output
|
|
54
|
+
-h, --help Show this message
|
|
55
|
+
|
|
46
56
|
To translate a YAML file:
|
|
47
57
|
|
|
48
58
|
$ ./exe/translate -y /path/to/yml/file -l "destination-language"
|
data/lib/tr4n5l4te.rb
CHANGED
|
@@ -6,6 +6,8 @@ require 'midwire_common/hash'
|
|
|
6
6
|
|
|
7
7
|
module Tr4n5l4te
|
|
8
8
|
class << self
|
|
9
|
+
attr_accessor :configuration
|
|
10
|
+
|
|
9
11
|
def root
|
|
10
12
|
Pathname.new(File.dirname(__FILE__)).parent
|
|
11
13
|
end
|
|
@@ -39,10 +41,18 @@ module Tr4n5l4te
|
|
|
39
41
|
FileUtils.touch(file)
|
|
40
42
|
file
|
|
41
43
|
end
|
|
44
|
+
|
|
45
|
+
def configure
|
|
46
|
+
self.configuration ||= Configuration.new
|
|
47
|
+
yield(configuration)
|
|
48
|
+
end
|
|
42
49
|
end
|
|
43
50
|
|
|
44
|
-
autoload :Agent,
|
|
45
|
-
autoload :
|
|
46
|
-
autoload :
|
|
47
|
-
autoload :
|
|
51
|
+
autoload :Agent, 'tr4n5l4te/agent'
|
|
52
|
+
autoload :Configuration, 'tr4n5l4te/configuration'
|
|
53
|
+
autoload :Language, 'tr4n5l4te/language'
|
|
54
|
+
autoload :Runner, 'tr4n5l4te/runner'
|
|
55
|
+
autoload :Translator, 'tr4n5l4te/translator'
|
|
48
56
|
end
|
|
57
|
+
|
|
58
|
+
Tr4n5l4te.configure {}
|
data/lib/tr4n5l4te/agent.rb
CHANGED
|
@@ -4,7 +4,11 @@ require 'yaml'
|
|
|
4
4
|
|
|
5
5
|
module Tr4n5l4te
|
|
6
6
|
Capybara.register_driver :poltergeist do |app|
|
|
7
|
-
Capybara::Poltergeist::Driver.new(
|
|
7
|
+
Capybara::Poltergeist::Driver.new(
|
|
8
|
+
app,
|
|
9
|
+
js_errors: false,
|
|
10
|
+
timeout: Tr4n5l4te.configuration.timeout
|
|
11
|
+
)
|
|
8
12
|
end
|
|
9
13
|
Capybara.default_driver = :poltergeist
|
|
10
14
|
Capybara.javascript_driver = :poltergeist
|
data/lib/tr4n5l4te/runner.rb
CHANGED
|
@@ -21,6 +21,11 @@ module Tr4n5l4te
|
|
|
21
21
|
log_identifier(start_time)
|
|
22
22
|
@count = 0
|
|
23
23
|
|
|
24
|
+
# configure
|
|
25
|
+
Tr4n5l4te.configure do |config|
|
|
26
|
+
config.timeout = options[:timeout]
|
|
27
|
+
end
|
|
28
|
+
|
|
24
29
|
hash = YAML.load_file(options[:yaml_file])
|
|
25
30
|
translated = process(hash)
|
|
26
31
|
store_translation(translated)
|
|
@@ -49,13 +54,16 @@ module Tr4n5l4te
|
|
|
49
54
|
end
|
|
50
55
|
|
|
51
56
|
def from_lang
|
|
52
|
-
File.basename(options[:yaml_file]
|
|
57
|
+
md = File.basename(options[:yaml_file]).match(/^.+(\w\w)\.yml$/)
|
|
58
|
+
raise "Could not determine language from yaml file: '#{options[:yaml_file]}'" unless md
|
|
59
|
+
md[1]
|
|
53
60
|
end
|
|
54
61
|
|
|
55
62
|
def store_translation(translated)
|
|
56
63
|
data = YAML.dump(translated)
|
|
57
64
|
dir = File.dirname(options[:yaml_file])
|
|
58
|
-
File.
|
|
65
|
+
base = File.basename(options[:yaml_file]).gsub(/#{from_lang}\.yml$/, '')
|
|
66
|
+
File.open(File.join(dir, "#{base}#{options[:lang]}.yml"), 'w') { |f| f.write(data) }
|
|
59
67
|
end
|
|
60
68
|
|
|
61
69
|
# rubocop:disable Metrics/MethodLength
|
|
@@ -72,11 +80,15 @@ module Tr4n5l4te
|
|
|
72
80
|
opt(
|
|
73
81
|
:list,
|
|
74
82
|
'List known languages',
|
|
75
|
-
type: :boolean, required: false
|
|
83
|
+
type: :boolean, required: false)
|
|
76
84
|
opt(
|
|
77
85
|
:sleep_time,
|
|
78
86
|
'Sleep time',
|
|
79
87
|
type: :integer, default: 2, short: 's')
|
|
88
|
+
opt(
|
|
89
|
+
:timeout,
|
|
90
|
+
'Poltergeist timeout option - default 30',
|
|
91
|
+
type: :integer, default: 30, short: 't')
|
|
80
92
|
opt(
|
|
81
93
|
:verbose,
|
|
82
94
|
'Be verbose with output',
|
data/lib/tr4n5l4te/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tr4n5l4te
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chris Blackburn
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-11-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -171,6 +171,7 @@ files:
|
|
|
171
171
|
- exe/translate
|
|
172
172
|
- lib/tr4n5l4te.rb
|
|
173
173
|
- lib/tr4n5l4te/agent.rb
|
|
174
|
+
- lib/tr4n5l4te/configuration.rb
|
|
174
175
|
- lib/tr4n5l4te/language.rb
|
|
175
176
|
- lib/tr4n5l4te/runner.rb
|
|
176
177
|
- lib/tr4n5l4te/translator.rb
|
|
@@ -196,7 +197,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
196
197
|
version: '0'
|
|
197
198
|
requirements: []
|
|
198
199
|
rubyforge_project:
|
|
199
|
-
rubygems_version: 2.
|
|
200
|
+
rubygems_version: 2.5.1
|
|
200
201
|
signing_key:
|
|
201
202
|
specification_version: 4
|
|
202
203
|
summary: Use Google Translate without an API key.
|