Class: GetText::Tools::XGetText
- Inherits:
-
Object
- Object
- GetText::Tools::XGetText
- Includes:
- GetText
- Defined in:
- lib/gettext/tools/xgettext.rb
Constant Summary collapse
- @@default_parsers =
This classvariable is part of a private API. You should avoid using this classvariable if possible, as it may be removed or be changed in the future.
[]
Constants included from GetText
Instance Attribute Summary collapse
-
#parse_options ⇒ Hash<Symbol, Object>
readonly
Options for parsing.
Class Method Summary collapse
-
.add_parser(parser) ⇒ void
Adds a parser to the default parser list.
- .run(*arguments) ⇒ Object
Instance Method Summary collapse
-
#add_parser(parser) ⇒ void
The parser object requires to have target?(path) and parse(path) method.
-
#initialize ⇒ XGetText
constructor
:nodoc:.
-
#parse(paths) ⇒ Object
:nodoc:.
-
#run(*options) ⇒ Object
:nodoc:.
Methods included from GetText
#N_, #Nn_, #bindtextdomain, #bindtextdomain_to, #cgi, #cgi=, #gettext, included, #locale, #ngettext, #npgettext, #nsgettext, #output_charset, #pgettext, #set_cgi, #set_current_locale, #set_locale, #set_output_charset, #sgettext, #textdomain, #textdomain_to
Constructor Details
#initialize ⇒ XGetText
:nodoc:
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/gettext/tools/xgettext.rb', line 74 def initialize #:nodoc: @parsers = [] @input_files = nil @output = nil @package_name = "PACKAGE" @package_version = "VERSION" @msgid_bugs_address = "" @copyright_holder = "THE PACKAGE'S COPYRIGHT HOLDER" @copyright_year = "YEAR" @output_encoding = "UTF-8" @parse_options = {} @po_order = :references @po_format_options = { max_line_width: POEntry::Formatter::DEFAULT_MAX_LINE_WIDTH, use_one_line_per_reference: false, } end |
Instance Attribute Details
#parse_options ⇒ Hash<Symbol, Object> (readonly)
Returns Options for parsing. Options are depend on each parser.
72 73 74 |
# File 'lib/gettext/tools/xgettext.rb', line 72 def @parse_options end |
Class Method Details
.add_parser(parser) ⇒ void
This method returns an undefined value.
Adds a parser to the default parser list.
41 42 43 |
# File 'lib/gettext/tools/xgettext.rb', line 41 def add_parser(parser) @@default_parsers.unshift(parser) end |
.run(*arguments) ⇒ Object
31 32 33 |
# File 'lib/gettext/tools/xgettext.rb', line 31 def run(*arguments) new.run(*arguments) end |
Instance Method Details
#add_parser(parser) ⇒ void
This method returns an undefined value.
The parser object requires to have target?(path) and parse(path) method.
143 144 145 |
# File 'lib/gettext/tools/xgettext.rb', line 143 def add_parser(parser) @parsers.unshift(parser) end |
#parse(paths) ⇒ Object
:nodoc:
162 163 164 165 166 167 168 169 170 171 172 173 174 |
# File 'lib/gettext/tools/xgettext.rb', line 162 def parse(paths) # :nodoc: po = PO.new paths = [paths] if paths.kind_of?(String) paths.each do |path| begin parse_path(path, po) rescue puts(_("Error parsing %{path}") % {:path => path}) raise end end po end |
#run(*options) ⇒ Object
:nodoc:
147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/gettext/tools/xgettext.rb', line 147 def run(*) # :nodoc: (*) pot = generate_pot(@input_files) if @output.is_a?(String) File.open(File.(@output), "w+") do |file| file.puts(pot) end else @output.puts(pot) end self end |