let input_mo_informations failsafe chn mo_header =
let empty_translation =
get_translated_value failsafe
(input_mo_translation failsafe chn mo_header 0)
0
in
let field_value =
let lexbuf = Lexing.from_string empty_translation
in
try
GettextMo_parser.main GettextMo_lexer.token_field_name lexbuf
with
Parsing.Parse_error
| Failure("lexing: empty token") ->
fail_or_continue failsafe
(MoInvalidOptions (lexbuf,empty_translation))
[]
in
let (nplurals,fun_plural_forms) =
try
let field_plural_forms = List.assoc "Plural-Forms" field_value
in
let lexbuf = Lexing.from_string field_plural_forms
in
try
GettextMo_parser.plural_forms
GettextMo_lexer.token_field_plural_value lexbuf
with
Parsing.Parse_error
| Failure("lexing: empty token") ->
fail_or_continue failsafe
(MoInvalidPlurals(lexbuf,field_plural_forms))
(2,germanic_plural)
with Not_found ->
(2,germanic_plural)
in
let (content_type, content_type_charset) =
let gettext_content = ("text/plain", GettextConfig.default_codeset)
in
try
let field_content_type = List.assoc "Content-Type" field_value
in
let lexbuf = Lexing.from_string field_content_type
in
try
GettextMo_parser.content_type
GettextMo_lexer.token_field_content_type lexbuf
with
Parsing.Parse_error
| Failure("lexing: empty token") ->
fail_or_continue failsafe
(MoInvalidContentType(lexbuf,field_content_type))
gettext_content
with Not_found ->
gettext_content
in
let extract_field_string name =
try
Some (List.assoc name field_value)
with Not_found ->
None
in
{
project_id_version = extract_field_string "Project-Id-Version";
report_msgid_bugs_to = extract_field_string "Report-Msgid-Bugs-To";
pot_creation_date = extract_field_string "POT-Creation-Date";
po_revision_date = extract_field_string "PO-Revision-Date";
last_translator = extract_field_string "Last-Translator";
language_tream = extract_field_string "Language-Team";
mime_version = extract_field_string "MIME-Version";
content_type = extract_field_string "Content-Type";
content_transfer_encoding = extract_field_string "Content-Transfer-Encoding";
plural_forms = extract_field_string "Plural-Forms";
content_type_charset = content_type_charset;
nplurals = nplurals;
fun_plural_forms = fun_plural_forms;
}