Class: GetText::GladeParser

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

Constant Summary

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



47
48
49
50
# File 'lib/gettext/tools/parser/glade.rb', line 47

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

Class Method Details

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



38
39
40
41
# File 'lib/gettext/tools/parser/glade.rb', line 38

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

.target?(file) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


26
27
28
29
30
31
32
33
34
35
36
# File 'lib/gettext/tools/parser/glade.rb', line 26

def target?(file) # :nodoc:
  data = IO.readlines(file)
  if XML_RE =~ data[0] and GLADE_RE =~ data[1]
    true
  else
    if File.extname(file) == '.glade'
      raise _("`%{file}' is not glade-2.0 format.") % {:file => file}
    end
    false
  end
end

Instance Method Details

#parseObject

:nodoc:



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

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