Changeset 561 for trunk/tools/linguist/lconvert/main.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/tools/linguist/lconvert/main.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the Qt Linguist of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 47 47 #include <QtCore/QStringList> 48 48 49 #include <iostream> 50 49 51 static int usage(const QStringList &args) 50 52 { … … 52 54 53 55 QString loaders; 54 QString savers; 55 QString line = QString(QLatin1String(" %1 - %2\n")); 56 foreach (Translator::FileFormat format, Translator::registeredFileFormats()) { 56 QString line(QLatin1String(" %1 - %2\n")); 57 foreach (Translator::FileFormat format, Translator::registeredFileFormats()) 57 58 loaders += line.arg(format.extension, -5).arg(format.description); 58 if (format.fileType != Translator::FileFormat::SourceCode) 59 savers += line.arg(format.extension, -5).arg(format.description); 60 } 61 62 qWarning("%s", qPrintable(QString(QLatin1String("\nUsage:\n" 59 60 std::cerr << qPrintable(QString(QLatin1String("\nUsage:\n" 63 61 " lconvert [options] <infile> [<infile>...]\n\n" 64 62 "lconvert is part of Qt's Linguist tool chain. It can be used as a\n" 65 "stand-alone tool to convert translation data files from one of the\n" 66 "following input formats\n\n%1\n" 67 "to one of the following output formats\n\n%2\n" 68 "If multiple input files are specified the translations are merged with\n" 63 "stand-alone tool to convert and filter translation data files.\n" 64 "The following file formats are supported:\n\n%1\n" 65 "If multiple input files are specified, they are merged with\n" 69 66 "translations from later files taking precedence.\n\n" 70 67 "Options:\n" … … 86 83 " --output-format <outformat>\n" 87 84 " Specify output format. See -if.\n\n" 85 " --input-codec <codec>\n" 86 " Specify encoding for QM and PO input files. Default is 'Latin1'\n" 87 " for QM and 'UTF-8' for PO files. UTF-8 is always tried as well for\n" 88 " QM, corresponding to the possible use of the trUtf8() function.\n\n" 89 " --output-codec <codec>\n" 90 " Specify encoding for PO output files. Default is 'UTF-8'.\n\n" 88 91 " --drop-tags <regexp>\n" 89 " Drop named extra tags when writing 'ts' or 'xlf'files.\n"92 " Drop named extra tags when writing TS or XLIFF files.\n" 90 93 " May be specified repeatedly.\n\n" 91 94 " --drop-translations\n" … … 94 97 " --source-language <language>[_<region>]\n" 95 98 " Specify/override the language of the source strings. Defaults to\n" 96 " POSIX if not specified and the file does not name it yet.\n "99 " POSIX if not specified and the file does not name it yet.\n\n" 97 100 " --target-language <language>[_<region>]\n" 98 101 " Specify/override the language of the translation.\n" … … 103 106 " --no-finished\n" 104 107 " Drop finished messages.\n\n" 108 " --sort-contexts\n" 109 " Sort contexts in output TS file alphabetically.\n\n" 110 " --locations {absolute|relative|none}\n" 111 " Override how source code references are saved in TS files.\n" 112 " Default is absolute.\n\n" 113 " --no-ui-lines\n" 114 " Drop line numbers from references to UI files.\n\n" 105 115 " --verbose\n" 106 116 " be a bit more verbose\n\n" … … 110 120 " 1 on command line parse failures\n" 111 121 " 2 on read failures\n" 112 " 3 on write failures\n")).arg(loaders) .arg(savers)));122 " 3 on write failures\n")).arg(loaders)); 113 123 return 1; 114 124 } … … 135 145 bool noFinished = false; 136 146 bool verbose = false; 147 bool noUiLines = false; 148 Translator::LocationsType locations = Translator::DefaultLocations; 137 149 138 150 ConversionData cd; … … 165 177 return usage(args); 166 178 inFormat = args[i]; 179 } else if (args[i] == QLatin1String("-input-codec")) { 180 if (++i >= args.size()) 181 return usage(args); 182 cd.m_codecForSource = args[i].toLatin1(); 183 } else if (args[i] == QLatin1String("-output-codec")) { 184 if (++i >= args.size()) 185 return usage(args); 186 cd.m_outputCodec = args[i].toLatin1(); 167 187 } else if (args[i] == QLatin1String("-drop-tag")) { 168 188 if (++i >= args.size()) … … 186 206 } else if (args[i] == QLatin1String("-no-finished")) { 187 207 noFinished = true; 208 } else if (args[i] == QLatin1String("-sort-contexts")) { 209 cd.m_sortContexts = true; 210 } else if (args[i] == QLatin1String("-locations")) { 211 if (++i >= args.size()) 212 return usage(args); 213 if (args[i] == QLatin1String("none")) 214 locations = Translator::NoLocations; 215 else if (args[i] == QLatin1String("relative")) 216 locations = Translator::RelativeLocations; 217 else if (args[i] == QLatin1String("absolute")) 218 locations = Translator::AbsoluteLocations; 219 else 220 return usage(args); 221 } else if (args[i] == QLatin1String("-no-ui-lines")) { 222 noUiLines = true; 188 223 } else if (args[i] == QLatin1String("-verbose")) { 189 224 verbose = true; … … 202 237 203 238 tr.setLanguageCode(Translator::guessLanguageCodeFromFileName(inFiles[0].name)); 204 if (!targetLanguage.isEmpty())205 tr.setLanguageCode(targetLanguage);206 if (!sourceLanguage.isEmpty())207 tr.setSourceLanguageCode(sourceLanguage);208 239 209 240 if (!tr.load(inFiles[0].name, cd, inFiles[0].format)) { … … 211 242 return 2; 212 243 } 213 Translator::reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose);244 tr.reportDuplicates(tr.resolveDuplicates(), inFiles[0].name, verbose); 214 245 215 246 for (int i = 1; i < inFiles.size(); ++i) { … … 219 250 return 2; 220 251 } 221 Translator::reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose);252 tr2.reportDuplicates(tr2.resolveDuplicates(), inFiles[i].name, verbose); 222 253 for (int j = 0; j < tr2.messageCount(); ++j) 223 254 tr.replaceSorted(tr2.message(j)); 224 255 } 225 256 257 if (!targetLanguage.isEmpty()) 258 tr.setLanguageCode(targetLanguage); 259 if (!sourceLanguage.isEmpty()) 260 tr.setSourceLanguageCode(sourceLanguage); 226 261 if (noObsolete) 227 262 tr.stripObsoleteMessages(); … … 230 265 if (dropTranslations) 231 266 tr.dropTranslations(); 232 267 if (noUiLines) 268 tr.dropUiLines(); 269 if (locations != Translator::DefaultLocations) 270 tr.setLocationsType(locations); 271 272 tr.normalizeTranslations(cd); 273 if (!cd.errors().isEmpty()) { 274 qWarning("%s", qPrintable(cd.error())); 275 cd.clearErrors(); 276 } 233 277 if (!tr.save(outFileName, cd, outFormat)) { 234 278 qWarning("%s", qPrintable(cd.error()));
Note:
See TracChangeset
for help on using the changeset viewer.