lib/gettext/runtime/textdomain.rb in gettext-2.1.0 vs lib/gettext/runtime/textdomain.rb in gettext-2.2.0
- old
+ new
@@ -1,5 +1,7 @@
+# encoding: utf-8
+
=begin
textdomain.rb - GetText::Textdomain
Copyright (C) 2001-2009 Masao Mutoh
Copyright (C) 2001-2003 Masahiro Sakai
@@ -58,11 +60,11 @@
@name, @output_charset = name, output_charset
@locale_path = LocalePath.new(@name, topdir)
@mofiles = {}
end
-
+
# Translates the translated string.
# * lang: Locale::Tag::Simple's subclass.
# * msgid: the original message.
# * Returns: the translated string or nil.
def translate_singluar_message(lang, msgid)
@@ -75,11 +77,11 @@
mofile = @mofiles[lang_key]
end
unless mofile
mofile = load_mo(lang)
end
-
+
if (! mofile) or (mofile ==:empty)
return nil
end
msgstr = mofile[msgid]
@@ -87,21 +89,21 @@
msgstr
elsif msgid.include?("\000")
# Check "aaa\000bbb" and show warning but return the singluar part.
ret = nil
msgid_single = msgid.split("\000")[0]
- mofile.each{|key, val|
+ mofile.each{|key, val|
if key =~ /^#{Regexp.quote(msgid_single)}\000/
# Usually, this is not caused to make po-files from rgettext.
warn %Q[Warning: n_("#{msgid_single}", "#{msgid.split("\000")[1]}") and n_("#{key.gsub(/\000/, '", "')}") are duplicated.]
ret = val
break
end
}
ret
else
ret = nil
- mofile.each{|key, val|
+ mofile.each{|key, val|
if key =~ /^#{Regexp.quote(msgid)}\000/
ret = val.split("\000")[0]
break
end
}