From 92244e93ac650f7b0d0cad8d5f2cb44919273932 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 27 Jan 2010 17:25:41 +0100 Subject: add directories with sources to list of project roots if the pro file for the translations lives in a sibling tree of the actual source tree, messages from included headers wouldn't have been collected, as they were not considered part of the project. Task-number: QTBUG-7495 (cherry picked from commit f300f5cfdf3b32e687191b071c30e14ac2721fc8) --- .../lupdate/testdata/good/from_subdir/lupdatecmd | 1 + .../testdata/good/from_subdir/project.ts.result | 17 ++++++++ .../lupdate/testdata/good/from_subdir/src/main.cpp | 50 ++++++++++++++++++++++ .../lupdate/testdata/good/from_subdir/src/main.h | 45 +++++++++++++++++++ .../good/from_subdir/translations/translations.pro | 7 +++ tools/linguist/lupdate/main.cpp | 15 +++++-- 6 files changed, 132 insertions(+), 3 deletions(-) create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h create mode 100644 tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd new file mode 100644 index 0000000..8a5b4ad --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/lupdatecmd @@ -0,0 +1 @@ +lupdate translations/translations.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result new file mode 100644 index 0000000..7167cf3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/project.ts.result @@ -0,0 +1,17 @@ + + + + + QApplication + + + string in main.cpp + + + + + string in main.h + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp new file mode 100644 index 0000000..1a24ab2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! + +#include "main.h" + +int main(char **argv, int argc) +{ + return QApplication::tr("string in main.cpp"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h new file mode 100644 index 0000000..cc07d7c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/src/main.h @@ -0,0 +1,45 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// IMPORTANT!!!! If you want to add testdata to this file, +// always add it to the end in order to not change the linenumbers of translations!!! + +QT_TRANSLATE_NOOP("QApplication", "string in main.h") diff --git a/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro b/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro new file mode 100644 index 0000000..1815c37 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/from_subdir/translations/translations.pro @@ -0,0 +1,7 @@ +VPATH = ../src +INCLUDEPATH = ../src + +SOURCES += main.cpp +HEADERS += main.h + +TRANSLATIONS += ../project.ts diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp index fd9c696..a50c97a 100644 --- a/tools/linguist/lupdate/main.cpp +++ b/tools/linguist/lupdate/main.cpp @@ -317,9 +317,18 @@ static void processProject( cd.m_codecForSource = codecForSource; cd.m_includePath = visitor.values(QLatin1String("INCLUDEPATH")); QStringList sourceFiles = getSources(visitor, pfi.absolutePath()); - QSet projectRoots; - projectRoots.insert(QDir::cleanPath(pfi.absolutePath()) + QLatin1Char('/')); - cd.m_projectRoots = projectRoots; + QSet sourceDirs; + sourceDirs.insert(QDir::cleanPath(pfi.absolutePath()) + QLatin1Char('/')); + foreach (const QString &sf, sourceFiles) + sourceDirs.insert(sf.left(sf.lastIndexOf(QLatin1Char('/')) + 1)); + QStringList rootList = sourceDirs.toList(); + rootList.sort(); + for (int prev = 0, curr = 1; curr < rootList.length(); ) + if (rootList.at(curr).startsWith(rootList.at(prev))) + rootList.removeAt(curr); + else + prev = curr++; + cd.m_projectRoots = QSet::fromList(rootList); processSources(*fetchedTor, sourceFiles, cd); } } -- cgit v0.12