2 Copyright (C) 1995-1998, 2000-2003, 2005-2006, 2008-2009, 2014-2015
3 Free Software Foundation, Inc.
4 This file was written by Daiki Ueno <ueno@gnu.org>.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
24 #include "write-xml.h"
31 #include "msgl-iconv.h"
32 #include "po-charset.h"
33 #include "read-catalog.h"
35 #include "fwriteerror.h"
39 #define _(str) gettext (str)
42 msgdomain_write_xml_bulk (msgfmt_operand_list_ty *operands,
43 const char *template_file_name,
44 its_rule_list_ty *its_rules,
45 const char *file_name)
47 its_merge_context_ty *context;
51 if (strcmp (file_name, "-") == 0)
55 fp = fopen (file_name, "wb");
58 error (0, errno, _("cannot create output file \"%s\""),
64 context = its_merge_context_alloc (its_rules, template_file_name);
65 for (i = 0; i < operands->nitems; i++)
66 its_merge_context_merge (context,
67 operands->items[i].language,
68 operands->items[i].mlp);
69 its_merge_context_write (context, fp);
70 its_merge_context_free (context);
72 /* Make sure nothing went wrong. */
75 error (0, errno, _("error while writing \"%s\" file"),
84 msgdomain_write_xml (message_list_ty *mlp,
85 const char *canon_encoding,
86 const char *locale_name,
87 const char *template_file_name,
88 its_rule_list_ty *its_rules,
89 const char *file_name)
91 msgfmt_operand_ty operand;
92 msgfmt_operand_list_ty operands;
94 /* Convert the messages to Unicode. */
95 iconv_message_list (mlp, canon_encoding, po_charset_utf8, NULL);
97 /* Create a single-element operands and run the bulk operation on it. */
98 operand.language = (char *) locale_name;
101 operands.items = &operand;
103 return msgdomain_write_xml_bulk (&operands,