Technology and Software

gettext puzzle: unknown type of %string, Solved

I was running a routine rake updatepo for a Rails application of mine when suddenly I got a unknown type of %string error. The Ruby parsing routines used by gettext weren’t able to understand something that the Ruby interpreter has no problem understanding. There were no hints of the offending lines so finding what to fix in my code was a little troublesome.

A little digging in the error trace got me to the method identify_quotation in the file /usr/lib/ruby/1.8/irb/ruby-lex.rb

I added these lines before RubyLex.fail SyntaxError, "unknown type of %string"

puts "Error parsing Ruby source."
puts "Here are the 200 characters following the error point.\n"
200.times do
  putc getc
end
puts ""

Running rake again let me see the code immediately following the point where the parser failed. As it turned out the problem was the %m format argument of the calls to strtime embedded inside %() or in multi line strings. Rephrasing those strings let rake updatepo succeed.

Advertisements
Standard