let extract command default_options filename_options filename_lst filename_pot =
let make_command options filename =
Printf.sprintf "%s %s %s" command options filename
in
let extract_one po filename =
let options =
try
MapString.find filename filename_options
with Not_found ->
default_options
in
let real_command =
make_command options filename
in
let chn =
Unix.open_process_in real_command
in
let value =
(Marshal.from_channel chn : po_content)
in
match Unix.close_process_in chn with
| Unix.WEXITED 0 ->
GettextPo.merge_po po value
| Unix.WEXITED exit_code ->
raise (CompileExtractionFailed(filename,real_command,exit_code))
| Unix.WSIGNALED signal
| Unix.WSTOPPED signal ->
raise (CompileExtractionInterrupted(filename,real_command,signal))
in
let extraction =
List.fold_left extract_one GettextPo.empty_po filename_lst
in
let chn =
open_out filename_pot
in
let date =
let current_time =
Unix.time ()
in
let gmt_time =
Unix.gmtime current_time
in
Printf.sprintf "%04d-%02d-%02d %02d:%02d+0000"
(gmt_time.Unix.tm_year + 1900)
(gmt_time.Unix.tm_mon + 1)
(gmt_time.Unix.tm_mday)
(gmt_time.Unix.tm_hour)
(gmt_time.Unix.tm_min)
in
Printf.fprintf chn
"# SOME DESCRIPTIVE TITLE.\n# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER\n# This file is distributed under the same license as the PACKAGE package.\n# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.\n#\n#, fuzzy\nmsgid \"\"\nmsgstr \"\"\n\"Project-Id-Version: PACKAGE VERSION\\n\"\n\"Report-Msgid-Bugs-To: \\n\"\n\"POT-Creation-Date: %s\\n\"\n\"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n\"\n\"Last-Translator: FULL NAME <EMAIL@ADDRESS>\\n\"\n\"Language-Team: LANGUAGE <LL@li.org>\\n\"\n\"MIME-Version: 1.0\\n\"\n\"Content-Type: text/plain; charset=CHARSET\\n\"\n\"Content-Transfer-Encoding: 8bit\\n\"\n\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n\n" date;
GettextPo.output_po chn extraction;
close_out chn