def translate_singular_message(lang, msgid)
return "" if msgid.nil?
lang_key = lang.to_s
mo = nil
if self.class.cached?
mo = @mofiles[lang_key]
end
unless mo
mo = load_mo(lang)
end
if (! mo) or (mo ==:empty)
return nil
end
return mo[msgid] if mo.has_key?(msgid)
ret = nil
if msgid.include?("\000")
msgid_single = msgid.split("\000")[0]
msgid_single_prefix_re = /^#{Regexp.quote(msgid_single)}\000/
mo.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
plural_msgid_prefix = "#{msgid}\000"
mo.each do |key, val|
next unless Encoding.compatible?(key, plural_msgid_prefix)
next unless key.start_with?(plural_msgid_prefix)
ret = val.split("\000")[0]
break
end
end
ret
end