Thanks for sharing Antero, I'm afraid you are the first one to try
adding gettext support to Dryml!
> deftarget?(file)# :nodoc:
> @config[:extnames].each do|v|
> returntrueifFile.extname(file)==v
> end
> false
> end
>
> # Parses eRuby script located at `path`.
> #
> # This is a short cut method. It equals to `new(path,
> # options).parse`.
> #
> # @return [Array<POEntry>] Extracted messages
> # @see #initialize and #parse
> defparse(path,options={})
> parser =new(path,options)
> parser.parse
> end
> end
>
> MAGIC_COMMENT =/\A#coding:.*\n/
>
> # @param path [String] eRuby script path to be parsed
> # @param options [Hash]
> definitialize(path,options={})
> @path=path
> @options=options
> end
>
> # Extracts messages from @path.
> #
> # @return [Array<POEntry>] Extracted messages
> defparse
> content =IO.read(@path)
> src =ERB.new(content).src
>
> # Force the src encoding back to the encoding in magic comment
> # or original content.
> encoding =detect_encoding(src)||content.encoding
> src.force_encoding(encoding)
>
> # Remove magic comment prepended by erb in Ruby 1.9.
> src =src.gsub(MAGIC_COMMENT,"")
>
> RubyParser.new(@path,@options).parse_source(src)
> end
>
> defdetect_encoding(source)
> if/\A#coding:(.*)\n/ =~ source
> $1
> else
> nil
> end
> end
> end
> end
>
> if__FILE__ ==$0
> # ex) ruby glade.dryml?
> ARGV.each do|file|
> p GetText::DrymlParser.parse(file)
> end
> end
>
> GetText::Tools::XGetText.add_parser(GetText::DrymlParser)
> |
>
> As this code is based on erb parser it does not support all dryml
> features. Any ideas to make this better would be welcome..
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google
> Groups "Hobo Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to
hobodev+u...@googlegroups.com
> <mailto:
hobodev+u...@googlegroups.com>.
> To post to this group, send email to
hob...@googlegroups.com
> <mailto:
hob...@googlegroups.com>.
> Visit this group at
http://groups.google.com/group/hobodev.
> For more options, visit
https://groups.google.com/d/optout.