def translate_singular_message(lang, msgid)
return "" if msgid.nil?
lang_key = lang.to_s
mofile = nil
if self.class.cached?
mofile = @mofiles[lang_key]
end
unless mofile
mofile = load_mo(lang)
end
if (! mofile) or (mofile ==:empty)
return nil
end
return mofile[msgid] if mofile.has_key?(msgid)
ret = nil
if msgid.include?("\000")
msgid_single = msgid.split("\000")[0]
msgid_single_prefix_re = /^#{Regexp.quote(msgid_single)}\000/
mofile.each do |key, val|
if msgid_single_prefix_re =~ key
separated_msgid = msgid.gsub(/\000/, '", "')
duplicated_msgid = key.gsub(/\000/, '", "')
warn("Warning: " +
"n_(\"#{separated_msgid}\") and " +
"n_(\"#{duplicated_msgid}\") " +
"are duplicated.")
ret = val
break
end
end
else
msgid_prefix_re = /^#{Regexp.quote(msgid)}\000/
mofile.each do |key, val|
if msgid_prefix_re =~ key
ret = val.split("\000")[0]
break
end
end
end
ret
end