/usr/lib/ruby/1.8/ramaze/contrib/gettext/parser.rb is in libramaze-ruby1.8 2010.06.18-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | # suppress load warning message
verbose = $VERBOSE
$VERBOSE = nil
require 'gettext/rgettext'
$VERBOSE = verbose
module Ramaze::Tool::Gettext::Parser
module_function
TARGETS = Ramaze::Template::ENGINES.values.inject([]) do |exts, list|
list += exts
end
def target?(file)
TARGETS.include?(File.extname(file)[1..-1])
end
def parse(file, ary)
regex = Ramaze::Tool::Gettext.trait[:regex]
body = File.read(file)
body.gsub!(regex) do
msg = $1
unless msg.to_s.empty?
line_number = body[0..(body.index(msg))].split("\n").size
add_message(ary, msg, file, line_number)
end
end
return ary
end
def add_message(ary, msg, file, line_number)
loc = message_location(file, line_number)
if value = ary.assoc(msg)
value << loc
else
ary << [msg, loc]
end
return ary
end
def message_location(file, line_number)
file + ":line" + line_number.to_s
end
end
GetText::RGetText.add_parser(Ramaze::Tool::Gettext::Parser)
|