summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/auto/linguist/lupdate/.gitignore5
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd2
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result20
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result13
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt2
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result20
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd2
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result20
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt1
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd2
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result13
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt1
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result20
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result0
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd1
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro4
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp46
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro1
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro2
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp46
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro1
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp46
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro4
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro2
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp46
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro1
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro2
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp46
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro1
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp46
-rw-r--r--tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro4
-rw-r--r--tools/linguist/lupdate/main.cpp264
41 files changed, 592 insertions, 98 deletions
diff --git a/tests/auto/linguist/lupdate/.gitignore b/tests/auto/linguist/lupdate/.gitignore
index 3572c82..a11e8d1 100644
--- a/tests/auto/linguist/lupdate/.gitignore
+++ b/tests/auto/linguist/lupdate/.gitignore
@@ -1,3 +1,4 @@
tst_lupdate
-testdata/good/*/project.ts
-testdata/good/*/*/project.ts
+testdata/*/*.ts
+testdata/*/*/*.ts
+testdata/*/*/*/*.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/expectedoutput.txt
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd
new file mode 100644
index 0000000..40987e2
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/lupdatecmd
@@ -0,0 +1,2 @@
+TRANSLATION: project.ts project_sub.ts
+cd ../../subdirs_full
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result
new file mode 100644
index 0000000..7d9a6f4
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project.ts.result
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>subdir1</name>
+ <message>
+ <location filename="subdir1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>subsub1</name>
+ <message>
+ <location filename="subdir2/subsub1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result
new file mode 100644
index 0000000..cddb963
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full/project_sub.ts.result
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<defaultcodec>ISO-8859-2</defaultcodec>
+<context>
+ <name>subsub2</name>
+ <message>
+ <location filename="subdir2/subsub2/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt
new file mode 100644
index 0000000..fd7a158
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/expectedoutput.txt
@@ -0,0 +1,2 @@
+lupdate warning: TS files from command line will override TRANSLATIONS in project\.pro\.
+lupdate warning: TS files from command line prevent recursing into .*/subdir2/subsub2/subsub2\.pro\.
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd
new file mode 100644
index 0000000..33296c3
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/lupdatecmd
@@ -0,0 +1,3 @@
+TRANSLATION: project.ts project_sub.ts
+cd ../../subdirs_full
+lupdate project.pro -ts project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result
new file mode 100644
index 0000000..7d9a6f4
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project.ts.result
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>subdir1</name>
+ <message>
+ <location filename="subdir1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>subsub1</name>
+ <message>
+ <location filename="subdir2/subsub1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.before
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts/project_sub.ts.result
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/expectedoutput.txt
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd
new file mode 100644
index 0000000..628acc0
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/lupdatecmd
@@ -0,0 +1,2 @@
+cd ../../subdirs_full
+lupdate subdir1/subdir1.pro subdir2/subsub1/subsub1.pro -ts project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result
new file mode 100644
index 0000000..7d9a6f4
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_full_ts_join/project.ts.result
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>subdir1</name>
+ <message>
+ <location filename="subdir1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>subsub1</name>
+ <message>
+ <location filename="subdir2/subsub1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt
new file mode 100644
index 0000000..808db18
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/expectedoutput.txt
@@ -0,0 +1 @@
+lupdate warning: no TS files specified\. Only diagnostics will be produced for 'project\.pro'\.
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd
new file mode 100644
index 0000000..3e15bc7
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/lupdatecmd
@@ -0,0 +1,2 @@
+TRANSLATION: project.ts project_sub.ts
+cd ../../subdirs_part
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.before
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project.ts.result
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result
new file mode 100644
index 0000000..cddb963
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part/project_sub.ts.result
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<defaultcodec>ISO-8859-2</defaultcodec>
+<context>
+ <name>subsub2</name>
+ <message>
+ <location filename="subdir2/subsub2/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt
new file mode 100644
index 0000000..b904390
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/expectedoutput.txt
@@ -0,0 +1 @@
+lupdate warning: TS files from command line prevent recursing into .*/subdir2/subsub2/subsub2\.pro\.
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd
new file mode 100644
index 0000000..41bfcec
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/lupdatecmd
@@ -0,0 +1,3 @@
+TRANSLATION: project.ts project_sub.ts
+cd ../../subdirs_part
+lupdate project.pro -ts project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result
new file mode 100644
index 0000000..7d9a6f4
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project.ts.result
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>subdir1</name>
+ <message>
+ <location filename="subdir1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>subsub1</name>
+ <message>
+ <location filename="subdir2/subsub1/main.cpp" line="45"/>
+ <source>minimal test</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.before
diff --git a/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/recurse_part_ts/project_sub.ts.result
diff --git a/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd
index da6103f..90f609b 100644
--- a/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd
+++ b/tests/auto/linguist/lupdate/testdata/good/reloutput/lupdatecmd
@@ -1,2 +1 @@
TRANSLATION: translations/project.ts
-lupdate project.pro -ts translations/project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro
new file mode 100644
index 0000000..1f744a7
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/project.pro
@@ -0,0 +1,4 @@
+TEMPLATE = subdirs
+SUBDIRS = subdir1 subdir2/subdir2.pro
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp
new file mode 100644
index 0000000..0f1dc70
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/main.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+QString foo()
+{
+ QCoreApplication::translate("subdir1","minimal test");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro
new file mode 100644
index 0000000..28dcadc
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir1/subdir1.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro
new file mode 100644
index 0000000..f8d03df
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subdir2.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = subsub1 subsub2
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp
new file mode 100644
index 0000000..8c82c80
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/main.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+QString foo()
+{
+ QCoreApplication::translate("subsub1","minimal test");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro
new file mode 100644
index 0000000..28dcadc
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub1/subsub1.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp
new file mode 100644
index 0000000..ff85936
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/main.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+QString foo()
+{
+ QCoreApplication::translate("subsub2","minimal test");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro
new file mode 100644
index 0000000..3499222
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_full/subdir2/subsub2/subsub2.pro
@@ -0,0 +1,4 @@
+SOURCES += main.cpp
+
+TRANSLATIONS = ../../project_sub.ts
+CODECFORTR = ISO-8859-2
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro
new file mode 100644
index 0000000..d803c37
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/project.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = subdir1 subdir2/subdir2.pro
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp
new file mode 100644
index 0000000..0f1dc70
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/main.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+QString foo()
+{
+ QCoreApplication::translate("subdir1","minimal test");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro
new file mode 100644
index 0000000..28dcadc
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir1/subdir1.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro
new file mode 100644
index 0000000..f8d03df
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subdir2.pro
@@ -0,0 +1,2 @@
+TEMPLATE = subdirs
+SUBDIRS = subsub1 subsub2
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp
new file mode 100644
index 0000000..8c82c80
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/main.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+QString foo()
+{
+ QCoreApplication::translate("subsub1","minimal test");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro
new file mode 100644
index 0000000..28dcadc
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub1/subsub1.pro
@@ -0,0 +1 @@
+SOURCES += main.cpp
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp
new file mode 100644
index 0000000..ff85936
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/main.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+
+QString foo()
+{
+ QCoreApplication::translate("subsub2","minimal test");
+}
diff --git a/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro
new file mode 100644
index 0000000..3499222
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/subdirs_part/subdir2/subsub2/subsub2.pro
@@ -0,0 +1,4 @@
+SOURCES += main.cpp
+
+TRANSLATIONS = ../../project_sub.ts
+CODECFORTR = ISO-8859-2
diff --git a/tools/linguist/lupdate/main.cpp b/tools/linguist/lupdate/main.cpp
index 44717bf..6d91aa3 100644
--- a/tools/linguist/lupdate/main.cpp
+++ b/tools/linguist/lupdate/main.cpp
@@ -117,14 +117,17 @@ static void printUsage()
" -disable-heuristic {sametext|similartext|number}\n"
" Disable the named merge heuristic. Can be specified multiple times.\n"
" -pro <filename>\n"
- " Name of a .pro file. Useful for files with .pro\n"
- " file syntax but different file suffix\n"
+ " Name of a .pro file. Useful for files with .pro file syntax but\n"
+ " different file suffix. Projects are recursed into and merged.\n"
" -source-language <language>[_<region>]\n"
" Specify the language of the source strings for new files.\n"
" Defaults to POSIX if not specified.\n"
" -target-language <language>[_<region>]\n"
" Specify the language of the translations for new files.\n"
" Guessed from the file name if not specified.\n"
+ " -ts <ts-file>...\n"
+ " Specify the output file(s). This will override the TRANSLATIONS\n"
+ " and nullify the CODECFORTR from possibly specified project files.\n"
" -version\n"
" Display the version of lupdate and exit.\n"
).arg(m_defaultExtensions));
@@ -249,16 +252,151 @@ static QStringList getSources(const ProFileEvaluator &visitor, const QString &pr
return sourceFiles;
}
+static void processSources(Translator &fetchedTor,
+ const QStringList &sourceFiles, ConversionData &cd)
+{
+ QStringList sourceFilesCpp;
+ for (QStringList::const_iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) {
+ if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive))
+ loadJava(fetchedTor, *it, cd);
+ else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive)
+ || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive))
+ loadUI(fetchedTor, *it, cd);
+ else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive)
+ || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive))
+ loadQScript(fetchedTor, *it, cd);
+ else
+ sourceFilesCpp << *it;
+ }
+ loadCPP(fetchedTor, sourceFilesCpp, cd);
+ if (!cd.error().isEmpty())
+ printOut(cd.error());
+}
+
+static void processProjects(
+ bool topLevel, bool nestComplain, const QStringList &proFiles,
+ UpdateOptions options, const QByteArray &codecForSource,
+ const QString &targetLanguage, const QString &sourceLanguage,
+ Translator *parentTor, bool *fail);
+
+static void processProject(
+ bool nestComplain, const QFileInfo &pfi, ProFileEvaluator &visitor,
+ UpdateOptions options, const QByteArray &_codecForSource,
+ const QString &targetLanguage, const QString &sourceLanguage,
+ Translator *fetchedTor, bool *fail)
+{
+ QByteArray codecForSource = _codecForSource;
+ QStringList tmp = visitor.values(QLatin1String("CODECFORSRC"));
+ if (!tmp.isEmpty()) {
+ codecForSource = tmp.last().toLatin1();
+ if (!QTextCodec::codecForName(codecForSource)) {
+ qWarning("lupdate warning: Codec for source '%s' is invalid. "
+ "Falling back to codec for tr().", codecForSource.constData());
+ codecForSource.clear();
+ }
+ }
+ if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) {
+ QStringList subProFiles;
+ QDir proDir(pfi.absoluteDir());
+ foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) {
+ QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir));
+ QFileInfo subInfo(subPro);
+ if (subInfo.isDir())
+ subProFiles << (subPro + QLatin1Char('/')
+ + subInfo.fileName() + QLatin1String(".pro"));
+ else
+ subProFiles << subPro;
+ }
+ processProjects(false, nestComplain, subProFiles, options, codecForSource,
+ targetLanguage, sourceLanguage, fetchedTor, fail);
+ } else {
+ ConversionData cd;
+ cd.m_noUiLines = options & NoUiLines;
+ cd.m_codecForSource = codecForSource;
+ cd.m_includePath = visitor.values(QLatin1String("INCLUDEPATH"));
+ QStringList sourceFiles = getSources(visitor, pfi.absolutePath());
+ QSet<QString> projectRoots;
+ projectRoots.insert(QDir::cleanPath(pfi.absolutePath()) + QLatin1Char('/'));
+ cd.m_projectRoots = projectRoots;
+ processSources(*fetchedTor, sourceFiles, cd);
+ }
+}
+
+static void processProjects(
+ bool topLevel, bool nestComplain, const QStringList &proFiles,
+ UpdateOptions options, const QByteArray &codecForSource,
+ const QString &targetLanguage, const QString &sourceLanguage,
+ Translator *parentTor, bool *fail)
+{
+ foreach (const QString &proFile, proFiles) {
+ ProFileEvaluator visitor;
+ visitor.setVerbose(options & Verbose);
+
+ QFileInfo pfi(proFile);
+ ProFile pro(pfi.absoluteFilePath());
+ if (!visitor.queryProFile(&pro) || !visitor.accept(&pro)) {
+ if (topLevel)
+ *fail = true;
+ continue;
+ }
+
+ if (visitor.contains(QLatin1String("TRANSLATIONS"))) {
+ if (parentTor) {
+ if (topLevel) {
+ std::cerr << "lupdate warning: TS files from command line "
+ "will override TRANSLATIONS in " << qPrintable(proFile) << ".\n";
+ goto noTrans;
+ } else if (nestComplain) {
+ std::cerr << "lupdate warning: TS files from command line "
+ "prevent recursing into " << qPrintable(proFile) << ".\n";
+ continue;
+ }
+ }
+ QStringList tsFiles;
+ QDir proDir(pfi.absolutePath());
+ foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS")))
+ tsFiles << QFileInfo(proDir, tsFile).filePath();
+ if (tsFiles.isEmpty()) {
+ // This might mean either a buggy PRO file or an intentional detach -
+ // we can't know without seeing the actual RHS of the assignment ...
+ // Just assume correctness and be silent.
+ continue;
+ }
+ Translator tor;
+ QByteArray codecForTr;
+ QStringList tmp = visitor.values(QLatin1String("CODEC"))
+ + visitor.values(QLatin1String("DEFAULTCODEC"))
+ + visitor.values(QLatin1String("CODECFORTR"));
+ if (!tmp.isEmpty()) {
+ codecForTr = tmp.last().toLatin1();
+ tor.setCodecName(codecForTr);
+ }
+ processProject(false, pfi, visitor, options, codecForSource,
+ targetLanguage, sourceLanguage, &tor, fail);
+ updateTsFiles(tor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, fail);
+ continue;
+ }
+ noTrans:
+ if (!parentTor) {
+ if (topLevel)
+ std::cerr << "lupdate warning: no TS files specified. Only diagnostics "
+ "will be produced for '" << qPrintable(proFile) << "'.\n";
+ Translator tor;
+ processProject(nestComplain, pfi, visitor, options, codecForSource,
+ targetLanguage, sourceLanguage, &tor, fail);
+ } else {
+ processProject(nestComplain, pfi, visitor, options, codecForSource,
+ targetLanguage, sourceLanguage, parentTor, fail);
+ }
+ }
+}
+
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
m_defaultExtensions = QLatin1String("ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx");
QStringList args = app.arguments();
- QString defaultContext; // This was QLatin1String("@default") before.
- Translator fetchedTor;
- QByteArray codecForTr;
- QByteArray codecForSource;
QStringList tsFileNames;
QStringList proFiles;
QMultiHash<QString, QString> allCSources;
@@ -402,9 +540,6 @@ int main(int argc, char **argv)
return 1;
}
- codecForTr.clear();
- codecForSource.clear();
-
if (metTsFlag) {
bool found = false;
foreach (const Translator::FileFormat &fmt, Translator::registeredFileFormats()) {
@@ -477,106 +612,45 @@ int main(int argc, char **argv)
}
} // for args
- if (!proFiles.isEmpty() && !sourceFiles.isEmpty()) {
- qWarning("lupdate error: Both project and source files specified.\n");
- return 1;
- }
if (numFiles == 0) {
printUsage();
return 1;
}
- foreach (const QString &proFile, proFiles)
- projectRoots.insert(QDir::cleanPath(QFileInfo(proFile).absolutePath()) + QLatin1Char('/'));
+ if (!targetLanguage.isEmpty() && tsFileNames.count() != 1)
+ std::cerr << "lupdate warning: -target-language usually only "
+ "makes sense with exactly one TS file.\n";
- bool firstPass = true;
bool fail = false;
- while (firstPass || !proFiles.isEmpty()) {
+ if (proFiles.isEmpty()) {
+ if (tsFileNames.isEmpty())
+ std::cerr << "lupdate warning: no TS files specified. "
+ "Only diagnostics will be produced.\n";
+
+ Translator fetchedTor;
ConversionData cd;
- cd.m_defaultContext = defaultContext;
cd.m_noUiLines = options & NoUiLines;
cd.m_projectRoots = projectRoots;
cd.m_includePath = includePath;
cd.m_allCSources = allCSources;
-
- QStringList tsFiles = tsFileNames;
- if (proFiles.count() > 0) {
- QFileInfo pfi(proFiles.takeFirst());
-
- ProFileEvaluator visitor;
- visitor.setVerbose(options & Verbose);
-
- ProFile pro(pfi.absoluteFilePath());
- if (!visitor.queryProFile(&pro))
- return 2;
- if (!visitor.accept(&pro))
- return 2;
-
- if (visitor.templateType() == ProFileEvaluator::TT_Subdirs) {
- QDir proDir(pfi.absoluteDir());
- foreach (const QString &subdir, visitor.values(QLatin1String("SUBDIRS"))) {
- QString subPro = QDir::cleanPath(proDir.absoluteFilePath(subdir));
- QFileInfo subInfo(subPro);
- if (subInfo.isDir())
- proFiles << (subPro + QLatin1Char('/')
- + subInfo.fileName() + QLatin1String(".pro"));
- else
- proFiles << subPro;
- }
- continue;
- }
-
- cd.m_includePath += visitor.values(QLatin1String("INCLUDEPATH"));
-
- sourceFiles = getSources(visitor, pfi.absolutePath());
-
- QStringList tmp = visitor.values(QLatin1String("CODEC"))
- + visitor.values(QLatin1String("DEFAULTCODEC"))
- + visitor.values(QLatin1String("CODECFORTR"));
- if (!tmp.isEmpty()) {
- codecForTr = tmp.last().toLatin1();
- fetchedTor.setCodecName(codecForTr);
- cd.m_outputCodec = codecForTr;
- }
- tmp = visitor.values(QLatin1String("CODECFORSRC"));
- if (!tmp.isEmpty()) {
- codecForSource = tmp.last().toLatin1();
- if (!QTextCodec::codecForName(codecForSource))
- qWarning("lupdate warning: Codec for source '%s' is invalid. Falling back to codec for tr().",
- codecForSource.constData());
- else
- cd.m_codecForSource = codecForSource;
- }
-
- QDir proDir(pfi.absolutePath());
- foreach (const QString &tsFile, visitor.values(QLatin1String("TRANSLATIONS")))
- tsFiles << QFileInfo(proDir, tsFile).filePath();
+ processSources(fetchedTor, sourceFiles, cd);
+ updateTsFiles(fetchedTor, tsFileNames, QByteArray(),
+ sourceLanguage, targetLanguage, options, &fail);
+ } else {
+ if (!sourceFiles.isEmpty() || !includePath.isEmpty()) {
+ qWarning("lupdate error: Both project and source files / include paths specified.\n");
+ return 1;
}
-
- QStringList sourceFilesCpp;
- for (QStringList::iterator it = sourceFiles.begin(); it != sourceFiles.end(); ++it) {
- if (it->endsWith(QLatin1String(".java"), Qt::CaseInsensitive))
- loadJava(fetchedTor, *it, cd);
- else if (it->endsWith(QLatin1String(".ui"), Qt::CaseInsensitive)
- || it->endsWith(QLatin1String(".jui"), Qt::CaseInsensitive))
- loadUI(fetchedTor, *it, cd);
- else if (it->endsWith(QLatin1String(".js"), Qt::CaseInsensitive)
- || it->endsWith(QLatin1String(".qs"), Qt::CaseInsensitive))
- loadQScript(fetchedTor, *it, cd);
- else
- sourceFilesCpp << *it;
+ if (!tsFileNames.isEmpty()) {
+ Translator fetchedTor;
+ processProjects(true, true, proFiles, options, QByteArray(),
+ targetLanguage, sourceLanguage, &fetchedTor, &fail);
+ updateTsFiles(fetchedTor, tsFileNames, QByteArray(),
+ sourceLanguage, targetLanguage, options, &fail);
+ } else {
+ processProjects(true, false, proFiles, options, QByteArray(),
+ targetLanguage, sourceLanguage, 0, &fail);
}
- loadCPP(fetchedTor, sourceFilesCpp, cd);
- if (!cd.error().isEmpty())
- printOut(cd.error());
-
- tsFiles.removeDuplicates();
-
- if (!tsFiles.isEmpty())
- updateTsFiles(fetchedTor, tsFiles, codecForTr, sourceLanguage, targetLanguage, options, &fail);
-
- firstPass = false;
}
-
return fail ? 1 : 0;
}