1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the linguist application of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#include <metatranslator.h>
33
#include <qtranslator.h>
36
typedef QList<TranslatorMessage> TML;
38
static void printUsage()
40
fprintf( stderr, "Usage:\n"
41
" qm2ts [ options ] qm-files\n"
43
" -help Display this information and exit\n"
45
" Explain what is being done\n"
47
" Display the version of qm2ts and exit\n" );
50
int main( int argc, char **argv )
55
for ( int i = 1; i < argc; i++ ) {
56
if ( qstrcmp(argv[i], "-help") == 0 ) {
59
} else if ( qstrcmp(argv[i], "-verbose") == 0 ) {
62
} else if ( qstrcmp(argv[i], "-version") == 0 ) {
63
fprintf( stderr, "qm2ts version %s\n", QT_VERSION_STR );
69
if ( tor.load(argv[i], ".") ) {
71
g.replace( QRegExp(QString("\\.qm$")), QString() );
72
g += QString( ".ts" );
75
fprintf( stderr, "Generating '%s'...\n", g.toLatin1().data() );
77
MetaTranslator metator;
80
TML all = tor.messages();
82
for ( it = all.begin(); it != all.end(); ++it ) {
83
if ( (*it).sourceText() == 0 ) {
86
QByteArray context = (*it).context();
87
if ( context.isEmpty() )
89
metator.insert( MetaTranslatorMessage(context,
90
(*it).sourceText(), (*it).comment(),
91
(*it).translation(), false,
92
MetaTranslatorMessage::Finished) );
96
if ( !metator.save(g) ) {
98
"qm2ts warning: For some reason, I cannot save '%s'\n",
99
g.toLatin1().constData() );
102
int converted = (int) metator.messages().count();
103
fprintf( stderr, " %d message%s converted (%d ignored)\n",
104
converted, converted == 1 ? "" : "s", ignored );
108
"qm2ts warning: File '%s' is not a Qt 2.x .qm"
109
" file (some information is lost)\n",
114
"qm2ts warning: For some reason, I cannot load '%s'\n",
119
if ( numQmFiles == 0 ) {