lib/gettext/tools.rb in fair-gettext-2.0.2 vs lib/gettext/tools.rb in fair-gettext-2.0.3
- old
+ new
@@ -86,19 +86,30 @@
# * po_root: the root directory of po-files.
# * mo_root: the target root directory where the mo-files are stored.
# * mo_path_rule: the target directory for each mo-files.
def create_mofiles(options = {})
options = {:po_root => "./po"}.merge(options)
+
+ po_text = ''
+ mo_file = ''
+ pofile = ''
+
+ Dir.glob(File.join(options[:po_root], "*/")) do |dir|
+ Dir.glob(File.join(dir, "*.po")).each do |po_file|
+ po_text = File.read(po_file) + po_text
+ pofile = po_file unless po_file.include?("private")
+ mo_file = mo_file_from_po_file(pofile,options)
+ end
- Dir.glob(File.join(options[:po_root], "*/*.po")) do |po_file|
- mo_file = mo_file_from_po_file(po_file,options)
- $stderr.print %Q[#{po_file} -> #{mo_file} ... ] if options[:verbose]
+ en_tmp = dir + 'en_tmp.po'
+ file = File.new(en_tmp, "w+")
+ file << po_text
FileUtils.mkdir_p(File.dirname(mo_file))
- rmsgfmt(po_file, mo_file)
- $stderr.puts "Done." if options[:verbose]
+ rmsgfmt(file, mo_file)
+ File.delete(en_tmp)
+ po_text = ''
end
end
-
# At first, this creates the #{po_root}/#{domainname}.pot file using GetText.rgettext.
# In the second step, this updates(merges) the #{po_root}/#{domainname}.pot and all of the
# #{po_root}/#{lang}/#{domainname}.po files under "po_root" using "msgmerge".
#
\ No newline at end of file