Class: Translatomatic::CLI::Main
- Defined in:
- lib/translatomatic/cli/main.rb
Overview
Main command line interface
Instance Method Summary collapse
-
#display(file, *keys) ⇒ void
Display values from a resource bundle.
-
#services ⇒ void
List available translator services.
-
#strings(*files) ⇒ void
Extract strings from non-resource files.
-
#version ⇒ void
Display version number.
Instance Method Details
#display(file, *keys) ⇒ void
This method returns an undefined value.
Display values from a resource bundle
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/translatomatic/cli/main.rb', line 32 def display(file, *keys) run do source = Translatomatic::ResourceFile.load(file) keys = source.properties.keys if keys.empty? display_keys(source, keys) # TODO: if locales not specified, determine the list of locales from # all the files in the resource bundle. locales = parse_list([:locales]) locales << Translatomatic::Locale.default.to_s if locales.empty? locales.each do |tag| locale = locale(tag) next if locale == source.locale display_properties(source, keys, locale) end end end |
#services ⇒ void
This method returns an undefined value.
List available translator services
70 71 72 |
# File 'lib/translatomatic/cli/main.rb', line 70 def services run { puts Translatomatic::Translator.list } end |
#strings(*files) ⇒ void
This method returns an undefined value.
Extract strings from non-resource files
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/translatomatic/cli/main.rb', line 55 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
78 79 80 |
# File 'lib/translatomatic/cli/main.rb', line 78 def version puts "Translatomatic v#{Translatomatic::VERSION}" end |