Changeset 651 for trunk/tools/linguist/lupdate
- Timestamp:
- Mar 8, 2010, 12:52:58 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
-
. (modified) (1 prop)
-
tools/linguist/lupdate/cpp.cpp (modified) (2 diffs)
-
tools/linguist/lupdate/java.cpp (modified) (1 diff)
-
tools/linguist/lupdate/lupdate.h (modified) (1 diff)
-
tools/linguist/lupdate/main.cpp (modified) (13 diffs)
-
tools/linguist/lupdate/merge.cpp (modified) (3 diffs)
-
tools/linguist/lupdate/qscript.cpp (modified) (1 diff)
-
tools/linguist/lupdate/qscript.g (modified) (1 diff)
-
tools/linguist/lupdate/ui.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.6.2 (added) merged: 650 /branches/vendor/nokia/qt/current merged: 649 /branches/vendor/nokia/qt/4.6.1 removed
- Property svn:mergeinfo changed
-
trunk/tools/linguist/lupdate/cpp.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 1733 1733 } 1734 1734 } 1735 if (!pendingContext.isEmpty() ) {1735 if (!pendingContext.isEmpty()) { 1736 1736 QStringList unresolved; 1737 1737 if (!fullyQualify(namespaces, pendingContext, true, &functionContext, &unresolved)) { -
trunk/tools/linguist/lupdate/java.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/linguist/lupdate/lupdate.h
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/linguist/lupdate/main.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 44 44 #include <translator.h> 45 45 #include <profileevaluator.h> 46 #include <proreader.h>47 46 48 47 #include <QtCore/QCoreApplication> … … 119 118 " Disable the named merge heuristic. Can be specified multiple times.\n" 120 119 " -pro <filename>\n" 121 " Name of a .pro file. Useful for files with .pro \n"122 " file syntax but different file suffix\n"120 " Name of a .pro file. Useful for files with .pro\n" 121 " \n" 123 122 " -source-language <language>[_<region>]\n" 124 123 " Specify the language of the source strings for new files.\n" … … 127 126 " Specify the language of the translations for new files.\n" 128 127 " Guessed from the file name if not specified.\n" 128 129 130 131 132 129 133 " -version\n" 130 134 " Display the version of lupdate and exit.\n" … … 215 219 } 216 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 217 405 int main(int argc, char **argv) 218 406 { … … 221 409 222 410 QStringList args = app.arguments(); 223 QString defaultContext; // This was QLatin1String("@default") before.224 Translator fetchedTor;225 QByteArray codecForTr;226 QByteArray codecForSource;227 411 QStringList tsFileNames; 228 412 QStringList proFiles; … … 233 417 QString targetLanguage; 234 418 QString sourceLanguage; 419 235 420 236 421 UpdateOptions options = … … 238 423 HeuristicSameText | HeuristicSimilarText | HeuristicNumber; 239 424 int numFiles = 0; 240 bool standardSyntax = true;241 425 bool metTsFlag = false; 242 426 bool recursiveScan = true; … … 244 428 QString extensions = m_defaultExtensions; 245 429 QSet<QString> extensionsNameFilters; 246 247 for (int i = 1; i < argc; ++i) {248 if (args.at(i) == QLatin1String("-ts"))249 standardSyntax = false;250 }251 430 252 431 for (int i = 1; i < argc; ++i) { … … 337 516 printOut(QObject::tr("lupdate version %1\n").arg(QLatin1String(QT_VERSION_STR))); 338 517 return 0; 518 519 520 521 522 523 524 525 339 526 } else if (arg == QLatin1String("-ts")) { 340 527 metTsFlag = true; … … 373 560 return 1; 374 561 } 375 376 numFiles++;377 378 QString fullText;379 380 codecForTr.clear();381 codecForSource.clear();382 562 383 563 if (metTsFlag) { … … 404 584 || arg.endsWith(QLatin1String(".pri"), Qt::CaseInsensitive)) { 405 585 proFiles << arg; 586 406 587 } else { 407 588 QFileInfo fi(arg); … … 448 629 sourceFiles << QDir::cleanPath(fi.absoluteFilePath());; 449 630 } 631 450 632 } 451 633 } // for args 452 634 453 foreach (const QString &proFile, proFiles) 454 projectRoots.insert(QDir::cleanPath(QFileInfo(proFile).absolutePath()) + QLatin1Char('/')); 455 456 bool firstPass = true; 635 if (numFiles == 0) { 636 printUsage(); 637 return 1; 638 } 639 640 if (!targetLanguage.isEmpty() && tsFileNames.count() != 1) 641 std::cerr << "lupdate warning: -target-language usually only " 642 "makes sense with exactly one TS file.\n"; 643 if (!codecForTr.isEmpty() && tsFileNames.isEmpty()) 644 std::cerr << "lupdate warning: -codecfortr has no effect without -ts.\n"; 645 457 646 bool fail = false; 458 while (firstPass || !proFiles.isEmpty()) { 647 if (proFiles.isEmpty()) { 648 if (tsFileNames.isEmpty()) 649 std::cerr << "lupdate warning: no TS files specified. " 650 "Only diagnostics will be produced.\n"; 651 652 Translator fetchedTor; 459 653 ConversionData cd; 460 cd.m_defaultContext = defaultContext;461 654 cd.m_noUiLines = options & NoUiLines; 462 655 cd.m_projectRoots = projectRoots; 463 656 cd.m_includePath = includePath; 464 657 cd.m_allCSources = allCSources; 465 466 QStringList tsFiles = tsFileNames; 467 if (proFiles.count() > 0) { 468 QFileInfo pfi(proFiles.takeFirst()); 469 QHash<QByteArray, QStringList> variables; 470 471 ProFileEvaluator visitor; 472 visitor.setVerbose(options & Verbose); 473 474 ProFile pro(pfi.absoluteFilePath()); 475 if (!visitor.queryProFile(&pro)) 476 return 2; 477 if (!visitor.accept(&pro)) 478 return 2; 479 480 if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) { 481 QDir proDir(pfi.absoluteDir()); 482 foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) { 483 QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir)); 484 QFileInfo subInfo(subPro); 485 if (subInfo.isDir()) 486 proFiles << (subPro + QLatin1Char('/') 487 + subInfo.fileName() + QLatin1String(".pro")); 488 else 489 proFiles << subPro; 490 } 491 continue; 492 } 493 494 cd.m_includePath += visitor.values(QLatin1String("INCLUDEPATH")); 495 496 evaluateProFile(visitor, &variables, pfi.absolutePath()); 497 498 sourceFiles = variables.value("SOURCES"); 499 500 QStringList tmp = variables.value("CODECFORTR"); 501 if (!tmp.isEmpty() && !tmp.first().isEmpty()) { 502 codecForTr = tmp.first().toLatin1(); 503 fetchedTor.setCodecName(codecForTr); 504 cd.m_outputCodec = codecForTr; 505 } 506 tmp = variables.value("CODECFORSRC"); 507 if (!tmp.isEmpty() && !tmp.first().isEmpty()) { 508 codecForSource = tmp.first().toLatin1(); 509 if (!QTextCodec::codecForName(codecForSource)) 510 qWarning("lupdate warning: Codec for source '%s' is invalid. Falling back to codec for tr().", 511 codecForSource.constData()); 512 else 513 cd.m_codecForSource = codecForSource; 514 } 515 516 tsFiles += variables.value("TRANSLATIONS"); 517 } 518 519 QStringList sourceFilesCpp; 520 for (QStringList::iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) { 521 if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive)) 522 loadJava(fetchedTor, *it, cd); 523 else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive) 524 || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive)) 525 loadUI(fetchedTor, *it, cd); 526 else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive) 527 || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive)) 528 loadQScript(fetchedTor, *it, cd); 529 else 530 sourceFilesCpp << *it; 531 } 532 loadCPP(fetchedTor, sourceFilesCpp, cd); 533 if (!cd.error().isEmpty()) 534 printOut(cd.error()); 535 536 tsFiles.sort(); 537 tsFiles.removeDuplicates(); 538 539 if (!tsFiles.isEmpty()) 540 updateTsFiles(fetchedTor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, &fail); 541 542 firstPass = false; 658 fetchedTor.setCodecName(codecForTr); 659 processSources(fetchedTor, sourceFiles, cd); 660 updateTsFiles(fetchedTor, tsFileNames, codecForTr, 661 sourceLanguage, targetLanguage, options, &fail); 662 } else { 663 if (!sourceFiles.isEmpty() || !includePath.isEmpty()) { 664 qWarning("lupdate error: Both project and source files / include paths specified.\n"); 665 return 1; 666 } 667 if (!tsFileNames.isEmpty()) { 668 Translator fetchedTor; 669 fetchedTor.setCodecName(codecForTr); 670 processProjects(true, true, proFiles, options, QByteArray(), 671 targetLanguage, sourceLanguage, &fetchedTor, &fail); 672 updateTsFiles(fetchedTor, tsFileNames, codecForTr, 673 sourceLanguage, targetLanguage, options, &fail); 674 } else { 675 processProjects(true, false, proFiles, options, QByteArray(), 676 targetLanguage, sourceLanguage, 0, &fail); 677 } 543 678 } 544 545 if (numFiles == 0) {546 printUsage();547 return 1;548 }549 550 679 return fail ? 1 : 0; 551 680 } -
trunk/tools/linguist/lupdate/merge.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected]) … … 61 61 static int numberLength(const QString &s, int i) 62 62 { 63 if (i <s.size() || !s.at(i).isDigit())63 if (i s.size() || !s.at(i).isDigit()) 64 64 return 0; 65 65 … … 88 88 bool metSomething = false; 89 89 90 for (int i = 0; i !=key.size(); ++i) {90 for (int i = 0; i key.size(); ++i) { 91 91 int len = numberLength(key, i); 92 92 if (len > 0) { -
trunk/tools/linguist/lupdate/qscript.cpp
r561 r651 2 2 /**************************************************************************** 3 3 ** 4 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).4 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 5 5 ** All rights reserved. 6 6 ** Contact: Nokia Corporation ([email protected]) -
trunk/tools/linguist/lupdate/qscript.g
r561 r651 1 1 ---------------------------------------------------------------------------- 2 2 -- 3 -- Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 -- Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 -- All rights reserved. 5 5 -- Contact: Nokia Corporation ([email protected]) -
trunk/tools/linguist/lupdate/ui.cpp
r561 r651 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 20 09Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 20 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation ([email protected])
Note:
See TracChangeset
for help on using the changeset viewer.
