Class: GetText::GladeParser

Inherits:
Object
  • Object
show all
Extended by:
GetText
Defined in:
lib/gettext/tools/parser/glade.rb

Constant Summary collapse

XML_RE =
/<\?xml/
GLADE_RE =
/glade-2.0.dtd/
TARGET1 =
/<property.*translatable="yes">(.*)/
TARGET2 =
/(.*)<\/property>/

Constants included from GetText

VERSION

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

#initialize(path, options = {}) ⇒ GladeParser

Returns a new instance of GladeParser.



49
50
51
52
# File 'lib/gettext/tools/parser/glade.rb', line 49

def initialize(path, options={})
  @path = path
  @options = options
end

Class Method Details

.parse(path, options = {}) ⇒ Object



40
41
42
43
# File 'lib/gettext/tools/parser/glade.rb', line 40

def parse(path, options={})
  parser = new(path, options)
  parser.parse
end

.target?(file) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


32
33
34
35
36
37
38
# File 'lib/gettext/tools/parser/glade.rb', line 32

def target?(file) # :nodoc:
  return false unless File.extname(file) == ".glade"
  data = File.read(file)
  return false unless data.include?("<?xml")
  return false unless data.include?("glade-2.0.dtd")
  true
end

Instance Method Details

#parseObject

:nodoc:



54
55
56
57
58
# File 'lib/gettext/tools/parser/glade.rb', line 54

def parse # :nodoc:
  File.open(@path) do |file|
    parse_source(file)
  end
end