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

Constant Summary

Constants included from GetText

BOM_UTF8, MOFile, MoFile, PoParser

Class Method Summary collapse

Instance Method Summary collapse

Methods included from GetText

#N_, #Nn_, #bindtextdomain, #bindtextdomain_to, #cgi, #cgi=, #create_mofiles, #create_mofiles_org, #gettext, included, #locale, #msgmerge, #ngettext, #npgettext, #nsgettext, #output_charset, #pgettext, #remove_bom, #set_cgi, #set_current_locale, #set_locale, #set_output_charset, #sgettext, #textdomain, #textdomain_to, #update_pofiles, #update_pofiles_org

Constructor Details

#initializeMsgInit

:nodoc:



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

def initialize #:nodoc:
  @input_file = nil
  @output_file = nil
  @locale = nil
  @language = nil
  @entry = nil
  @comment = nil
  @translator = 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.



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

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



65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/gettext/tools/msginit.rb', line 65

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