summaryrefslogtreecommitdiffstats
path: root/poxml/swappo.cpp
blob: 94c308ae9ca8b1bab347f66454793a0d63038486 (plain)
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
#include <iostream>
using namespace std;
#include "GettextParser.hpp"
#include <fstream>
#include "GettextLexer.hpp"

int main(int argc, char **argv)
{
    if ( argc != 2 ) {
        qWarning( "usage: %s pofile", argv[0] );
        return -1;
    }

    MsgList translated;

    try {
        ifstream s(argv[1]);
        GettextLexer lexer(s);
        GettextParser parser(lexer);
        translated = parser.file();

    } catch(exception& e) {
        cerr << "exception: " << e.what() << endl;
        return 1;
    }

    for (MsgList::ConstIterator it = translated.begin();
         it != translated.end(); ++it)
    {
        if ( !( *it ).msgstr.isEmpty() ) {
            outputMsg("msgid", (*it).msgstr);
            outputMsg("msgstr", (*it).msgid);
            cout << "\n";
        }
    }

}