1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/*
msgequal.c - Remove all msgstrs from a .po file which are identical to the
msgid.
(C) 2008 Canonical Ltd.
Author: Martin Pitt <martin.pitt@ubuntu.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <gettext-po.h>
void xerror (int severity, po_message_t message, const char *filename,
size_t lineno, size_t column, int multiline_p, const char *message_text)
{
fprintf (stderr, "%s:%zu: %s\n", filename, lineno, message_text);
if (severity == PO_SEVERITY_FATAL_ERROR) {
fputs ("FATAL error, aborting\n", stderr);
exit (2);
}
}
void xerror2 (int severity, po_message_t message1, const char *filename1,
size_t lineno1, size_t column1, int multiline_p1, const char *message_text1,
po_message_t message2, const char *filename2, size_t lineno2, size_t column2,
int multiline_p2, const char *message_text2)
{
}
int main (int argc, char** argv)
{
po_file_t po_in, po_out;
struct po_xerror_handler eh;
po_message_iterator_t msg_iter, out_iter;
po_message_t msg;
eh.xerror = xerror;
eh.xerror2 = xerror2;
if (argc != 3) {
fputs ("Usage: msgequal <input file> <output file>\n", stderr);
return 1;
}
/* slurp in file */
po_in = po_file_read (argv[1], &eh);
if (!po_in) {
perror("Opening input .po file");
return 1;
}
/* loop over translations and only copy those where msgid != msgstr */
po_out = po_file_create();
out_iter = po_message_iterator (po_out, NULL);
msg_iter = po_message_iterator (po_in, NULL);
while ((msg = po_next_message (msg_iter)) != NULL)
if (strcmp (po_message_msgid (msg), po_message_msgstr (msg)))
po_message_insert (out_iter, msg);
/* write output file */
if (!po_file_write (po_out, argv[2], &eh)) {
perror ("Writing output .po file");
return 1;
}
return 0;
}
|