translatomatic 0.1.3 → 0.2.0
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 +5 -5
- data/.gitattributes +20 -20
- data/.gitignore +19 -15
- data/.rspec +3 -3
- data/.rubocop.yml +28 -0
- data/.translatomatic/config.yml +4 -0
- data/.travis.yml +4 -6
- data/.yardopts +9 -9
- data/Gemfile +8 -4
- data/Guardfile +4 -5
- data/README.de.md +55 -50
- data/README.en.md +177 -0
- data/README.es.md +53 -48
- data/README.fr.md +53 -48
- data/README.it.md +54 -49
- data/README.ja.md +63 -58
- data/README.ko.md +59 -54
- data/README.md +17 -13
- data/README.ms.md +50 -45
- data/README.pt.md +54 -49
- data/README.ru.md +57 -52
- data/README.sv.md +51 -46
- data/README.zh.md +60 -55
- data/Rakefile +3 -3
- data/TODO.txt +6 -0
- data/bin/console +3 -3
- data/bin/translatomatic +4 -2
- data/config/i18n-tasks.yml +130 -0
- data/config/locales/translatomatic/de.yml +141 -99
- data/config/locales/translatomatic/en.yml +129 -89
- data/config/locales/translatomatic/es.yml +136 -99
- data/config/locales/translatomatic/fr.yml +139 -100
- data/config/locales/translatomatic/it.yml +135 -97
- data/config/locales/translatomatic/ja.yml +137 -98
- data/config/locales/translatomatic/ko.yml +138 -98
- data/config/locales/translatomatic/ms.yml +138 -100
- data/config/locales/translatomatic/pt.yml +137 -101
- data/config/locales/translatomatic/ru.yml +136 -98
- data/config/locales/translatomatic/sv.yml +134 -96
- data/config/locales/translatomatic/zh.yml +136 -97
- data/db/migrate/201712170000_initial.rb +2 -3
- data/lib/translatomatic.rb +40 -25
- data/lib/translatomatic/cli.rb +5 -1
- data/lib/translatomatic/cli/base.rb +61 -58
- data/lib/translatomatic/cli/common_options.rb +14 -11
- data/lib/translatomatic/cli/config.rb +96 -91
- data/lib/translatomatic/cli/database.rb +85 -23
- data/lib/translatomatic/cli/main.rb +158 -104
- data/lib/translatomatic/cli/thor.rb +29 -0
- data/lib/translatomatic/cli/translate.rb +134 -157
- data/lib/translatomatic/config.rb +10 -301
- data/lib/translatomatic/config/display.rb +78 -0
- data/lib/translatomatic/config/files.rb +60 -0
- data/lib/translatomatic/config/location_settings.rb +133 -0
- data/lib/translatomatic/config/options.rb +68 -0
- data/lib/translatomatic/config/selector.rb +127 -0
- data/lib/translatomatic/config/settings.rb +148 -0
- data/lib/translatomatic/converter.rb +40 -28
- data/lib/translatomatic/database.rb +127 -110
- data/lib/translatomatic/define_options.rb +4 -5
- data/lib/translatomatic/escaped_unicode.rb +86 -76
- data/lib/translatomatic/extractor.rb +5 -2
- data/lib/translatomatic/extractor/base.rb +12 -12
- data/lib/translatomatic/extractor/ruby.rb +7 -6
- data/lib/translatomatic/file_translator.rb +101 -244
- data/lib/translatomatic/flattenation.rb +39 -0
- data/lib/translatomatic/http.rb +13 -0
- data/lib/translatomatic/http/client.rb +144 -0
- data/lib/translatomatic/http/exception.rb +43 -0
- data/lib/translatomatic/http/file_param.rb +27 -0
- data/lib/translatomatic/http/param.rb +37 -0
- data/lib/translatomatic/http/request.rb +91 -0
- data/lib/translatomatic/i18n.rb +43 -0
- data/lib/translatomatic/locale.rb +71 -59
- data/lib/translatomatic/logger.rb +43 -28
- data/lib/translatomatic/metadata.rb +58 -0
- data/lib/translatomatic/model.rb +4 -2
- data/lib/translatomatic/model/locale.rb +5 -5
- data/lib/translatomatic/model/text.rb +5 -5
- data/lib/translatomatic/option.rb +57 -34
- data/lib/translatomatic/path_utils.rb +126 -0
- data/lib/translatomatic/progress_updater.rb +13 -16
- data/lib/translatomatic/provider.rb +101 -0
- data/lib/translatomatic/provider/base.rb +136 -0
- data/lib/translatomatic/provider/frengly.rb +55 -0
- data/lib/translatomatic/provider/google.rb +78 -0
- data/lib/translatomatic/provider/google_web.rb +50 -0
- data/lib/translatomatic/provider/microsoft.rb +144 -0
- data/lib/translatomatic/provider/my_memory.rb +75 -0
- data/lib/translatomatic/provider/yandex.rb +61 -0
- data/lib/translatomatic/resource_file.rb +59 -53
- data/lib/translatomatic/resource_file/base.rb +171 -237
- data/lib/translatomatic/resource_file/csv.rb +176 -24
- data/lib/translatomatic/resource_file/html.rb +21 -42
- data/lib/translatomatic/resource_file/key_value_support.rb +117 -0
- data/lib/translatomatic/resource_file/markdown.rb +36 -38
- data/lib/translatomatic/resource_file/plist.rb +121 -126
- data/lib/translatomatic/resource_file/po.rb +104 -82
- data/lib/translatomatic/resource_file/properties.rb +48 -77
- data/lib/translatomatic/resource_file/properties.treetop +87 -0
- data/lib/translatomatic/resource_file/resw.rb +56 -41
- data/lib/translatomatic/resource_file/subtitle.rb +86 -54
- data/lib/translatomatic/resource_file/text.rb +18 -18
- data/lib/translatomatic/resource_file/xcode_strings.rb +32 -63
- data/lib/translatomatic/resource_file/xcode_strings.treetop +85 -0
- data/lib/translatomatic/resource_file/xml.rb +94 -81
- data/lib/translatomatic/resource_file/yaml.rb +54 -68
- data/lib/translatomatic/retry_executor.rb +37 -0
- data/lib/translatomatic/slurp.rb +32 -0
- data/lib/translatomatic/string_batcher.rb +50 -0
- data/lib/translatomatic/string_escaping.rb +61 -0
- data/lib/translatomatic/text.rb +263 -0
- data/lib/translatomatic/text_collection.rb +66 -0
- data/lib/translatomatic/tmx.rb +5 -3
- data/lib/translatomatic/tmx/document.rb +107 -82
- data/lib/translatomatic/tmx/translation_unit.rb +19 -18
- data/lib/translatomatic/translation.rb +8 -28
- data/lib/translatomatic/translation/collection.rb +199 -0
- data/lib/translatomatic/translation/fetcher.rb +123 -0
- data/lib/translatomatic/translation/munging.rb +112 -0
- data/lib/translatomatic/translation/result.rb +50 -0
- data/lib/translatomatic/translation/sharer.rb +32 -0
- data/lib/translatomatic/translation/stats.rb +44 -0
- data/lib/translatomatic/translator.rb +91 -88
- data/lib/translatomatic/type_cast.rb +63 -0
- data/lib/translatomatic/util.rb +37 -33
- data/lib/translatomatic/version.rb +2 -2
- data/translatomatic.gemspec +57 -46
- metadata +136 -59
- data/lib/translatomatic/http_request.rb +0 -162
- data/lib/translatomatic/string.rb +0 -188
- data/lib/translatomatic/translation_result.rb +0 -86
- data/lib/translatomatic/translation_stats.rb +0 -31
- data/lib/translatomatic/translator/base.rb +0 -128
- data/lib/translatomatic/translator/frengly.rb +0 -62
- data/lib/translatomatic/translator/google.rb +0 -37
- data/lib/translatomatic/translator/microsoft.rb +0 -41
- data/lib/translatomatic/translator/my_memory.rb +0 -68
- data/lib/translatomatic/translator/yandex.rb +0 -56
@@ -8,7 +8,7 @@ class Initial < ActiveRecord::Migration[4.2] # :nodoc:
|
|
8
8
|
t.timestamps
|
9
9
|
end
|
10
10
|
|
11
|
-
add_index :locales, [
|
11
|
+
add_index :locales, %i[language script region], unique: true
|
12
12
|
|
13
13
|
create_table :texts do |t|
|
14
14
|
t.belongs_to :locale, index: true, null: false
|
@@ -17,9 +17,8 @@ class Initial < ActiveRecord::Migration[4.2] # :nodoc:
|
|
17
17
|
}
|
18
18
|
t.text :value, null: false
|
19
19
|
t.boolean :shared, null: false, default: false, index: true
|
20
|
-
t.string :
|
20
|
+
t.string :provider
|
21
21
|
t.timestamps
|
22
22
|
end
|
23
|
-
|
24
23
|
end
|
25
24
|
end
|
data/lib/translatomatic.rb
CHANGED
@@ -1,52 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# gem :rchardet19, provided_by: :rchardet
|
2
|
+
# titlekit has rchardet19 dependency, but we don't want that.
|
3
|
+
dependency = Gem::Dependency.new('rchardet19')
|
4
|
+
specs = dependency.matching_specs
|
5
|
+
if specs
|
6
|
+
path = File.join(specs[0].full_gem_path, 'lib')
|
7
|
+
$LOAD_PATH.delete(path)
|
8
|
+
end
|
4
9
|
|
5
10
|
require 'pathname'
|
6
11
|
require 'active_support/core_ext/hash'
|
7
|
-
require '
|
12
|
+
require 'rchardet'
|
8
13
|
|
9
14
|
# Module containing all of the translation goodness
|
10
15
|
module Translatomatic
|
16
|
+
class << self
|
17
|
+
attr_writer :logger
|
18
|
+
attr_writer :config
|
11
19
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
private
|
20
|
+
# @return [Logger] Translatomatic logger instance
|
21
|
+
def logger
|
22
|
+
@logger ||= Translatomatic::Logger.new
|
23
|
+
end
|
18
24
|
|
19
|
-
|
20
|
-
|
21
|
-
|
25
|
+
# @return [Translatomatic::Config] Configuration settings
|
26
|
+
def config
|
27
|
+
@config ||= Translatomatic::Config::Settings.new
|
28
|
+
end
|
22
29
|
end
|
23
30
|
end
|
24
31
|
|
25
|
-
begin
|
26
|
-
Translatomatic.init_i18n(__FILE__)
|
27
|
-
end
|
28
|
-
|
29
32
|
require 'translatomatic/version'
|
30
|
-
require 'translatomatic/option'
|
31
|
-
require 'translatomatic/define_options'
|
32
33
|
require 'translatomatic/locale'
|
33
|
-
require 'translatomatic/
|
34
|
-
require 'translatomatic/
|
34
|
+
require 'translatomatic/slurp'
|
35
|
+
require 'translatomatic/i18n'
|
35
36
|
require 'translatomatic/util'
|
37
|
+
require 'translatomatic/option'
|
38
|
+
require 'translatomatic/define_options'
|
39
|
+
require 'translatomatic/flattenation'
|
40
|
+
require 'translatomatic/string_batcher'
|
41
|
+
require 'translatomatic/path_utils'
|
42
|
+
require 'translatomatic/string_escaping'
|
43
|
+
require 'translatomatic/text'
|
44
|
+
require 'translatomatic/text_collection'
|
45
|
+
require 'translatomatic/retry_executor'
|
36
46
|
require 'translatomatic/version'
|
37
47
|
require 'translatomatic/logger'
|
48
|
+
require 'translatomatic/type_cast'
|
38
49
|
require 'translatomatic/config'
|
39
50
|
require 'translatomatic/database'
|
51
|
+
require 'translatomatic/translation'
|
40
52
|
require 'translatomatic/escaped_unicode'
|
41
53
|
require 'translatomatic/model'
|
54
|
+
require 'translatomatic/metadata'
|
42
55
|
require 'translatomatic/resource_file'
|
43
|
-
require 'translatomatic/
|
56
|
+
require 'translatomatic/http'
|
44
57
|
require 'translatomatic/converter'
|
45
|
-
require 'translatomatic/
|
46
|
-
require 'translatomatic/translation_result'
|
47
|
-
require 'translatomatic/translation_stats'
|
58
|
+
require 'translatomatic/provider'
|
48
59
|
require 'translatomatic/file_translator'
|
49
60
|
require 'translatomatic/extractor'
|
50
61
|
require 'translatomatic/progress_updater'
|
51
62
|
require 'translatomatic/tmx'
|
63
|
+
require 'translatomatic/translator'
|
52
64
|
require 'translatomatic/cli'
|
65
|
+
|
66
|
+
# monkey patches
|
67
|
+
Thor::Option.prepend Translatomatic::CLI::ThorPatch::NoNo
|
data/lib/translatomatic/cli.rb
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
module Translatomatic
|
1
|
+
module Translatomatic
|
2
|
+
# Command line functions
|
3
|
+
module CLI; end
|
4
|
+
end
|
2
5
|
|
6
|
+
require 'translatomatic/cli/thor'
|
3
7
|
require 'translatomatic/cli/common_options'
|
4
8
|
require 'translatomatic/cli/base'
|
5
9
|
require 'translatomatic/cli/translate'
|
@@ -1,81 +1,84 @@
|
|
1
1
|
require 'thor'
|
2
|
+
require 'rainbow'
|
2
3
|
|
3
|
-
module Translatomatic
|
4
|
-
|
5
|
-
|
4
|
+
module Translatomatic
|
5
|
+
module CLI
|
6
|
+
# Base class for command line interface classes
|
7
|
+
class Base < Thor
|
8
|
+
private
|
6
9
|
|
7
|
-
|
10
|
+
include Translatomatic::Util
|
11
|
+
include Translatomatic::DefineOptions
|
8
12
|
|
9
|
-
|
10
|
-
|
13
|
+
# creates thor options
|
14
|
+
class << self
|
15
|
+
private
|
11
16
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
+
def thor_options(klass, object)
|
18
|
+
Translatomatic::Option.options_from_object(object).each do |option|
|
19
|
+
next if option.hidden
|
20
|
+
name = option.name.to_s.dasherize
|
21
|
+
klass.method_option name, option.to_thor
|
22
|
+
end
|
23
|
+
end
|
17
24
|
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def parse_list(list, default = [])
|
21
|
-
# use the default list if the list is empty
|
22
|
-
list = default if list.nil? || list.empty?
|
23
|
-
list = [list] unless list.kind_of?(Array)
|
24
|
-
# split list entries on ','
|
25
|
-
list.compact.collect { |i| i.split(/[, ]/) }.flatten.compact
|
26
|
-
end
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
log.info(t("cli.dry_run")) if @dry_run
|
26
|
+
def parse_list(list, default = [])
|
27
|
+
# use the default list if the list is empty
|
28
|
+
list = default if list.nil? || list.empty?
|
29
|
+
list = [list] unless list.is_a?(Array)
|
30
|
+
# split list entries on ','
|
31
|
+
list.compact.collect { |i| i.split(/[, ]/) }.flatten.compact
|
32
|
+
end
|
36
33
|
|
34
|
+
# run the give code block, display exceptions.
|
35
|
+
def run
|
36
|
+
Translatomatic.config = create_config
|
37
|
+
@dry_run = conf.get(:dry_run)
|
38
|
+
log.level = ::Logger::DEBUG if conf.get(:debug)
|
39
|
+
log.info(t('cli.dry_run')) if @dry_run
|
37
40
|
yield
|
38
|
-
true
|
39
41
|
rescue Interrupt
|
40
|
-
puts "\n" + t(
|
41
|
-
|
42
|
-
|
42
|
+
puts "\n" + t('cli.aborted')
|
43
|
+
rescue StandardError => e
|
44
|
+
handle_run_error(e)
|
45
|
+
end
|
46
|
+
|
47
|
+
def create_config
|
48
|
+
Translatomatic::Config::Settings.new(runtime: options)
|
49
|
+
end
|
50
|
+
|
51
|
+
def handle_run_error(e)
|
43
52
|
finish_log
|
44
53
|
log.error(e.message)
|
45
54
|
log.debug(e.backtrace.join("\n"))
|
46
|
-
raise e if ENV[
|
47
|
-
false
|
55
|
+
raise e if ENV['TEST'] # reraise exceptions in test
|
48
56
|
end
|
49
|
-
end
|
50
57
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
def conf
|
56
|
-
Translatomatic.config
|
57
|
-
end
|
58
|
+
def finish_log
|
59
|
+
log.finish if log.respond_to?(:finish)
|
60
|
+
end
|
58
61
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
62
|
+
def conf
|
63
|
+
Translatomatic.config
|
64
|
+
end
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
Translatomatic::Config.options.each do |option|
|
70
|
-
unless @options.include?(option.name)
|
71
|
-
@options[option.name] = conf.get(option.name)
|
66
|
+
def rainbow
|
67
|
+
@rainbow ||= begin
|
68
|
+
rainbow = Rainbow.new
|
69
|
+
rainbow.enabled = !conf.get(:no_wank)
|
70
|
+
rainbow
|
72
71
|
end
|
73
72
|
end
|
74
|
-
end
|
75
73
|
|
76
|
-
|
77
|
-
|
78
|
-
|
74
|
+
def empty_array?(value)
|
75
|
+
value.is_a?(Array) && value.empty?
|
76
|
+
end
|
79
77
|
|
78
|
+
def add_table_heading(rows, headings)
|
79
|
+
underscores = headings.collect { |i| i.gsub(/\w/, '=') }
|
80
|
+
[headings, underscores] + rows
|
81
|
+
end
|
82
|
+
end
|
80
83
|
end
|
81
84
|
end
|
@@ -1,14 +1,17 @@
|
|
1
|
-
module Translatomatic
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
define_options(
|
9
|
-
{ name: :debug, type: :boolean, default: false, desc: t("cli.debug") },
|
10
|
-
{ name: :wank, type: :boolean, default: true, desc: t("cli.wank") },
|
11
|
-
)
|
1
|
+
module Translatomatic
|
2
|
+
module CLI
|
3
|
+
# Defines options common to all command line methods
|
4
|
+
class CommonOptions
|
5
|
+
include Translatomatic::DefineOptions
|
6
|
+
include Translatomatic::Util
|
12
7
|
|
8
|
+
define_option :debug, type: :boolean, default: false,
|
9
|
+
desc: t('cli.debug'), command_line_only: true
|
10
|
+
define_option :no_wank, type: :boolean, default: false,
|
11
|
+
desc: t('cli.no_wank')
|
12
|
+
define_option :dry_run, type: :boolean, aliases: '-n',
|
13
|
+
desc: t('cli.dry_run'),
|
14
|
+
command_line_only: true
|
15
|
+
end
|
13
16
|
end
|
14
17
|
end
|
@@ -1,110 +1,115 @@
|
|
1
|
-
module Translatomatic
|
2
|
-
|
3
|
-
|
1
|
+
module Translatomatic
|
2
|
+
module CLI
|
3
|
+
# Configuration functions for the command line interface
|
4
|
+
class Config < Base
|
5
|
+
define_option :user, type: :boolean,
|
6
|
+
desc: t('cli.config.user'),
|
7
|
+
command_line_only: true
|
8
|
+
define_option :project, type: :boolean,
|
9
|
+
desc: t('cli.config.project'),
|
10
|
+
command_line_only: true
|
11
|
+
define_option :for_file, type: :path,
|
12
|
+
desc: t('cli.config.for_file'),
|
13
|
+
command_line_only: true
|
4
14
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
15
|
+
desc 'set key value', t('cli.config.set')
|
16
|
+
thor_options(self, Translatomatic::CLI::CommonOptions)
|
17
|
+
thor_options(self, Translatomatic::CLI::Config)
|
18
|
+
# Change a configuration setting
|
19
|
+
# @param key [String] configuration key
|
20
|
+
# @param value [String] new value for the configuration
|
21
|
+
# @return [String] the new value
|
22
|
+
def set(key, *value)
|
23
|
+
run { conf.set(key, value, config_params) }
|
24
|
+
end
|
12
25
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
26
|
+
desc 'unset key', t('cli.config.unset')
|
27
|
+
thor_options(self, Translatomatic::CLI::CommonOptions)
|
28
|
+
thor_options(self, Translatomatic::CLI::Config)
|
29
|
+
# Remove a configuration setting
|
30
|
+
# @param key [String] configuration key to remove
|
31
|
+
# @return [void]
|
32
|
+
def unset(key)
|
33
|
+
run { conf.unset(key, config_params) }
|
34
|
+
end
|
23
35
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
36
|
+
desc 'add key value', t('cli.config.add')
|
37
|
+
thor_options(self, Translatomatic::CLI::CommonOptions)
|
38
|
+
thor_options(self, Translatomatic::CLI::Config)
|
39
|
+
# Add a configuration setting to a list
|
40
|
+
# @param key [String] configuration key
|
41
|
+
# @param value [String] value to add
|
42
|
+
# @return [String] the new value
|
43
|
+
def add(key, *value)
|
44
|
+
run { conf.add(key, value, config_params) }
|
45
|
+
end
|
33
46
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
)
|
47
|
+
desc 'subtract key value', t('cli.config.subtract')
|
48
|
+
thor_options(self, Translatomatic::CLI::CommonOptions)
|
49
|
+
thor_options(self, Translatomatic::CLI::Config)
|
50
|
+
# Remove a configuration setting from a list
|
51
|
+
# @param key [String] configuration key
|
52
|
+
# @param value [String] value to remove
|
53
|
+
# @return [void]
|
54
|
+
def subtract(key, value)
|
55
|
+
run { conf.subtract(key, value, config_params) }
|
44
56
|
end
|
45
|
-
end
|
46
57
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
desc 'list', t('cli.config.list')
|
59
|
+
thor_options(self, Translatomatic::CLI::CommonOptions)
|
60
|
+
thor_options(self, Translatomatic::CLI::Config)
|
61
|
+
option :skip_blanks, type: :boolean, desc: 'Skip blank values'
|
62
|
+
# List current configuration settings
|
63
|
+
def list
|
64
|
+
run do
|
65
|
+
print_config_table(columns: %i[key value], skip_blanks: true)
|
66
|
+
end
|
54
67
|
end
|
55
|
-
end
|
56
68
|
|
57
|
-
|
69
|
+
desc 'describe', t('cli.config.describe')
|
70
|
+
thor_options(self, Translatomatic::CLI::CommonOptions)
|
71
|
+
thor_options(self, Translatomatic::CLI::Config)
|
72
|
+
# Describe available configuration settings
|
73
|
+
def describe
|
74
|
+
run do
|
75
|
+
print_config_table(columns: %i[key type desc])
|
76
|
+
end
|
77
|
+
end
|
58
78
|
|
59
|
-
|
60
|
-
key: t("cli.config.name"),
|
61
|
-
type: t("cli.config.type"),
|
62
|
-
value: t("cli.config.value"),
|
63
|
-
desc: t("cli.config.desc"),
|
64
|
-
}
|
79
|
+
private
|
65
80
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
rows = []
|
81
|
+
def config_params
|
82
|
+
{ location: config_location, for_file: options['for-file'] }
|
83
|
+
end
|
70
84
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
85
|
+
def config_location
|
86
|
+
if options[:user]
|
87
|
+
:user
|
88
|
+
elsif options[:project]
|
89
|
+
:project
|
90
|
+
end
|
75
91
|
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
key
|
87
|
-
when :value
|
88
|
-
value.nil? ? "-" : value
|
89
|
-
when :type
|
90
|
-
t("config.types.#{option.type}")
|
91
|
-
when :desc
|
92
|
-
option.description
|
93
|
-
end
|
92
|
+
|
93
|
+
def print_config_table(params)
|
94
|
+
display_options = options.merge(params).merge(config_params)
|
95
|
+
display = Translatomatic::Config::Display.new(display_options)
|
96
|
+
puts config_table_intro + "\n"
|
97
|
+
rows = display.config_table_body
|
98
|
+
if rows.empty?
|
99
|
+
puts t('cli.config.no_config')
|
100
|
+
else
|
101
|
+
print_table(rows)
|
94
102
|
end
|
95
|
-
|
103
|
+
puts
|
96
104
|
end
|
97
105
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
rows.unshift headings
|
105
|
-
print_table(rows, indent: 2)
|
106
|
+
def config_table_intro
|
107
|
+
if (location = config_location)
|
108
|
+
t('cli.config.location_configuration', location: location)
|
109
|
+
else
|
110
|
+
t('cli.config.configuration')
|
111
|
+
end
|
106
112
|
end
|
107
|
-
puts
|
108
113
|
end
|
109
114
|
end
|
110
115
|
end
|