-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStatistics.cc
46 lines (36 loc) · 1.17 KB
/
Statistics.cc
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
#include "Statistics.h"
#include "ErrorHandlers.h"
#include "config.h"
#include <cstring>
Statistics::Statistics(const Glib::ustring &filename) {
m_fuzzy_count = 0;
m_untranslated_count = 0;
m_msg_count = 0;
struct po_xerror_handler error_handler;
error_handler.xerror = xerror_handler;
error_handler.xerror2 = xerror2_handler;
po_file_t pofile = po_file_read(filename.c_str(), &error_handler);
po_message_iterator_t iter = po_message_iterator(pofile, NULL);
po_next_message(iter); //we skip header which is msgid
po_message_t po_msg = NULL;
do {
po_msg = po_next_message(iter);
if (po_msg) {
if (po_message_is_fuzzy(po_msg)) m_fuzzy_count++;;
if (!strlen(po_message_msgstr(po_msg))) m_untranslated_count++;
if (!po_message_is_obsolete(po_msg)) ++m_msg_count;
}
} while (po_msg!=NULL);
debug("Message count = %d; Untraslated = %d; Fuzzy = %d\n", m_msg_count, m_untranslated_count, m_fuzzy_count);
po_message_iterator_free(iter);
po_file_free(pofile);
}
size_t Statistics::getTotal() const {
return m_msg_count;
}
size_t Statistics::getFuzzy() const {
return m_fuzzy_count;
}
size_t Statistics::getUntranslated() const {
return m_untranslated_count;
}