Class | GetText::RubyParser |
In: |
lib/gettext/tools/parser/ruby.rb
|
Parent: | Object |
ID | = | ["gettext", "_", "N_", "sgettext", "s_"] |
PLURAL_ID | = | ["ngettext", "n_", "Nn_", "ns_", "nsgettext"] |
MSGCTXT_ID | = | ["pgettext", "p_"] |
MSGCTXT_PLURAL_ID | = | ["npgettext", "np_"] |
@example `:comment_tag` option: String tag
path = "hello.rb" # content: # # TRANSLATORS: This is a comment to translators. # _("Hello") # # # This is a comment for programmers. # # TRANSLATORS: This is a comment to translators. # # This is also a comment to translators. # _("World") # # # This is a comment for programmers. # # This is also a comment for programmers # # because all lines don't start with "TRANSRATORS:". # _("Bye") options = {:comment_tag => "TRANSLATORS:"} parser = GetText::RubyParser.new(path, options) parser.parse # => [ # POEntry< # :msgid => "Hello", # :extracted_comment => # "TRANSLATORS: This is a comment to translators.", # >, # POEntry< # :msgid => "World", # :extracted_comment => # "TRANSLATORS: This is a comment to translators.\n" + # "This is also a comment to translators.", # >, # POEntry< # :msgid => "Bye", # :extracted_comment => nil, # >, # ]
@example `:comment_tag` option: nil tag
path = "hello.rb" # content: # # This is a comment to translators. # # This is also a comment for translators. # _("Hello") options = {:comment_tag => nil} parser = GetText::RubyParser.new(path, options) parser.parse # => [ # POEntry< # :msgid => "Hello", # :extracted_comment => # "This is a comment to translators.\n" + # " This is also a comment for translators.", # >, # ]
@param path [String] Ruby script path to be parsed @param options [Hash] Options @option options [String, nil] :comment_tag The tag to
detect comments to be extracted. The extracted comments are used to deliver messages to translators from programmers. If the tag is String and a line in a comment start with the tag, the line and the following lines are extracted. If the tag is nil, all comments are extracted.