Class: GetText::Tools::MsgInit

Inherits:
Object
  • Object
show all
Includes:
GetText
Defined in:
lib/gettext/tools/msginit.rb

Defined Under Namespace

Classes: ArgumentError, CLDRPluralsConverter, Error, ValidationError

Class Method Summary collapse

Instance Method Summary collapse

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

#initializeMsgInit

Returns a new instance of MsgInit.



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/gettext/tools/msginit.rb', line 60

def initialize
  @input_file = nil
  @output_file = nil
  @locale = nil
  @language = nil
  @entry = nil
  @comment = nil
  @translator = nil
  @set_translator = true
  @translator_name = nil
  @translator_eamil = nil
end

Class Method Details

.run(*arguments) ⇒ void

This method returns an undefined value.

Create a new .po file from initializing .pot file with user's environment and input.

Parameters:

  • arguments (Array<String>)

    arguments for rmsginit.



51
52
53
# File 'lib/gettext/tools/msginit.rb', line 51

def run(*arguments)
  new.run(*arguments)
end

Instance Method Details

#run(*arguments) ⇒ Object

Create .po file from .pot file, user's inputs and metadata.

Parameters:

  • arguments (Array)

    the list of arguments for rmsginit



75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/gettext/tools/msginit.rb', line 75

def run(*arguments)
  parse_arguments(*arguments)
  validate

  parser = POParser.new
  parser.ignore_fuzzy = false
  pot = parser.parse_file(@input_file, GetText::PO.new)
  po = replace_pot_header(pot)

  File.open(@output_file, "w") do |f|
    f.puts(po.to_s)
  end
end