let output_po chn po =
let fpf x =
Printf.fprintf chn x
in
let hyphens chn lst =
match lst with
[] ->
()
| [s] ->
Printf.fprintf chn "%S" s
| hd :: tl ->
Printf.fprintf chn "%S" hd;
List.iter ( fun s -> Printf.fprintf chn "\n%S" s) tl
in
let rec output_po_translation_aux _ (location_lst,translation) =
(
match location_lst with
[] ->
()
| lst ->
fpf "#: %s\n" (
String.concat " " (
List.map (
fun (str,line) ->
str^":"^(string_of_int line)
) lst
)
)
);
(
match translation with
PoSingular(id,str) ->
(
fpf "msgid %a\n" hyphens id;
fpf "msgstr %a\n" hyphens str
)
| PoPlural(id,id_plural,lst) ->
(
fpf "msgid %a\n" hyphens id;
fpf "msgid_plural %a\n" hyphens id_plural;
let _ = List.fold_left
( fun i s ->
fpf "msgstr[%i] %a\n" i hyphens s;
i + 1
) 0 lst
in
()
)
);
fpf "\n"
in
MapString.iter output_po_translation_aux po.no_domain;
MapTextdomain.iter (
fun domain map ->
fpf "domain %S\n\n" domain;
MapString.iter output_po_translation_aux map
) po.domain