Class: Translatomatic::CLI::Main
- Defined in:
- lib/translatomatic/cli/main.rb
Overview
Main command line interface
Instance Method Summary collapse
-
#convert(source, target) ⇒ void
Convert a resource file from one format to another.
-
#display(file = nil, *keys) ⇒ void
Display values from a resource bundle.
-
#providers ⇒ void
List available translation providers.
-
#strings(*files) ⇒ void
Extract strings from non-resource files.
-
#version ⇒ void
Display version number.
Instance Method Details
#convert(source, target) ⇒ void
This method returns an undefined value.
Convert a resource file from one format to another
68 69 70 71 72 73 |
# File 'lib/translatomatic/cli/main.rb', line 68 def convert(source, target) run do converter = Translatomatic::Converter.new converter.convert(source, target) end end |
#display(file = nil, *keys) ⇒ void
This method returns an undefined value.
Display values from a resource bundle
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/translatomatic/cli/main.rb', line 29 def display(file = nil, *keys) run do source_files = parse_list(file, conf.get(:source_files)) locales = conf.get(:target_locales, for_file: file) source_files.each do |path| raise t('file.not_found', file: path) unless File.exist?(path) source = Translatomatic::ResourceFile.load(path) display_properties(source, keys) locales.each do |locale| path = source.locale_path(locale) next if path == source.path || !path.exist? resource = Translatomatic::ResourceFile.load(path) display_properties(resource, keys) end end end end |
#providers ⇒ void
This method returns an undefined value.
List available translation providers
79 80 81 |
# File 'lib/translatomatic/cli/main.rb', line 79 def providers run { display_providers } end |
#strings(*files) ⇒ void
This method returns an undefined value.
Extract strings from non-resource files
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/translatomatic/cli/main.rb', line 52 def strings(*files) run do strings = [] files.each do |file| extractor = Translatomatic::Extractor::Base.new(file) strings << extractor.extract end puts strings.join("\n") end end |
#version ⇒ void
This method returns an undefined value.
Display version number
87 88 89 |
# File 'lib/translatomatic/cli/main.rb', line 87 def version puts "Translatomatic v#{Translatomatic::VERSION}" end |