Class: GetText::Tools::MsgInit

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

Defined Under Namespace

Classes: ArgumentError, 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.


54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/gettext/tools/msginit.rb', line 54

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.


45
46
47
# File 'lib/gettext/tools/msginit.rb', line 45

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


69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/gettext/tools/msginit.rb', line 69

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