diff options
author | axis <qt-info@nokia.com> | 2009-07-07 08:50:33 (GMT) |
---|---|---|
committer | axis <qt-info@nokia.com> | 2009-07-07 08:50:33 (GMT) |
commit | 1e192edd72789241e7397dcbc5ee326b2aed5790 (patch) | |
tree | 430961aed08cdfa25717bde84c3f74a2f75673fe /tests/auto/linguist/lupdate | |
parent | 2aac0c8b71fffd7c0335c1429bd1f2405adaa5e7 (diff) | |
parent | 343e8b7e75c98a4fd1b692a230de8d1132988705 (diff) | |
download | Qt-1e192edd72789241e7397dcbc5ee326b2aed5790.zip Qt-1e192edd72789241e7397dcbc5ee326b2aed5790.tar.gz Qt-1e192edd72789241e7397dcbc5ee326b2aed5790.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
configure.exe
src/network/access/qhttpnetworkconnection_p.h
tests/auto/qstyle/qstyle.pro
tests/auto/qstyle/tst_qstyle.cpp
tools/configure/configureapp.cpp
configure.exe will be recompiled in next commit. Took ours.
Diffstat (limited to 'tests/auto/linguist/lupdate')
158 files changed, 4971 insertions, 0 deletions
diff --git a/tests/auto/linguist/lupdate/lupdate.pro b/tests/auto/linguist/lupdate/lupdate.pro new file mode 100644 index 0000000..19259dc --- /dev/null +++ b/tests/auto/linguist/lupdate/lupdate.pro @@ -0,0 +1,7 @@ +CONFIG += qttest_p4 + +TARGET = tst_lupdate + +HEADERS += testlupdate.h +SOURCES += tst_lupdate.cpp testlupdate.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/backslashes/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/backslashes/lupdatecmd new file mode 100644 index 0000000..9b83a04 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/backslashes/lupdatecmd @@ -0,0 +1,3 @@ +# Add the command that lupdate should run here. If it can't find anything it will default to +TRANSLATION: ts\project.ts +lupdate -silent project.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/backslashes/project.pro b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.pro new file mode 100644 index 0000000..3584c89 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.pro @@ -0,0 +1,19 @@ +###################################################################### +# Automatically generated by qmake (2.01a) ma 22. jan 10:10:16 2007 +###################################################################### + +TEMPLATE = app +TARGET = +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += src\main.cpp + +TRANSLATIONS = ts\project.ts + + +!exists(ts) { + win32: system(md ts) + else: system(mkdir ts) +} diff --git a/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result new file mode 100644 index 0000000..151a18e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="1.1"> +<context> + <name>QApplication</name> + <message> + <location filename="../src/main.cpp" line="13"/> + <source>QT_LAYOUT_DIRECTION</source> + <comment>Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/backslashes/src/main.cpp b/tests/auto/linguist/lupdate/testdata/good/backslashes/src/main.cpp new file mode 100644 index 0000000..348a6be --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/backslashes/src/main.cpp @@ -0,0 +1,15 @@ +// 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!!! +// +// +// +// + +QString qt_detectRTLLanguage() +{ + return QApplication::tr("QT_LAYOUT_DIRECTION", + "Translate this string to the string 'LTR' in left-to-right" + " languages or to 'RTL' in right-to-left languages (such as Hebrew" + " and Arabic) to get proper widget layout.") == QLatin1String("RTL"); +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp new file mode 100644 index 0000000..2573fbb --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp @@ -0,0 +1,18 @@ +#include <QApplication> +#include <QtGui> +#include <QtCore> +#include <QTextCodec> + +int main(int argc, char **argv) +{ + QApplication a(argc, argv); + QWidget w; + QLabel label1(QObject::tr("abc", "ascii"), &w); + QLabel label2(QObject::tr("æøå", "utf-8"), &w); + +// I would expect the following to work !? +// QLabel label3(QObject::trUtf8("F\374r \310lise", "trUtf8"), &w); + + w.show(); + return a.exec(); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.pro new file mode 100644 index 0000000..848ebda --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.pro @@ -0,0 +1,20 @@ +TEMPLATE = app +TARGET += +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CONFIG+= console + +CODECFORTR = utf-8 +CODECFORSRC = utf-8 + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result new file mode 100644 index 0000000..e746c7e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>UTF-8</defaultcodec> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="10"/> + <source>abc</source> + <comment>ascii</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="11"/> + <source>æøå</source> + <comment>utf-8</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr/main.cpp new file mode 100644 index 0000000..79b0503 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr/main.cpp @@ -0,0 +1,24 @@ +#include <QApplication> +#include <QtGui> +#include <QtCore> +#include <QTextCodec> + +int main(int argc, char **argv) +{ + QApplication a(argc, argv); + QTranslator trans(0); + + trans.load("t1_en", "."); + + a.installTranslator(&trans); + QWidget w; +/* + QLabel label1(QObject::tr("\33"), &w); + QLabel label2(QObject::tr("\32"), &w); + QLabel label3(QObject::tr("\176"), &w); +*/ + QLabel label4(QObject::tr("\301"), &w); + + w.show(); + return a.exec(); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.pro new file mode 100644 index 0000000..81273ee --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.pro @@ -0,0 +1,19 @@ +TEMPLATE = app +TARGET += +DEPENDPATH += . +INCLUDEPATH += . + +# Input +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CONFIG+= console + +CODECFORTR = CP1251 + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result new file mode 100644 index 0000000..9a082ef --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>windows-1251</defaultcodec> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="20"/> + <source>Ã</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp new file mode 100644 index 0000000..91af165 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp @@ -0,0 +1,20 @@ +#include <QtCore> + +class FooBar : QObject +{ + Q_OBJECT + +public: + void doFoo() + { + tr("random ascii only"); + tr("this contains an umlaut ü ü"); + trUtf8("random ascii only in utf8"); + trUtf8("umlaut \xfc ü in utf8"); + } +}; + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.pro new file mode 100644 index 0000000..1d5b071 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.pro @@ -0,0 +1,15 @@ +TEMPLATE = app + +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CONFIG += console + +CODECFORTR = CP1252 + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result new file mode 100644 index 0000000..5ffa2f3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>windows-1252</defaultcodec> +<context> + <name>FooBar</name> + <message> + <location filename="main.cpp" line="10"/> + <source>random ascii only</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="11"/> + <source>this contains an umlaut ü &uuml;</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="12"/> + <source>random ascii only in utf8</source> + <translation type="unfinished"></translation> + </message> + <message utf8="true"> + <location filename="main.cpp" line="13"/> + <source>umlaut ü &uuml; in utf8</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp new file mode 100644 index 0000000..91af165 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp @@ -0,0 +1,20 @@ +#include <QtCore> + +class FooBar : QObject +{ + Q_OBJECT + +public: + void doFoo() + { + tr("random ascii only"); + tr("this contains an umlaut ü ü"); + trUtf8("random ascii only in utf8"); + trUtf8("umlaut \xfc ü in utf8"); + } +}; + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.pro b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.pro new file mode 100644 index 0000000..f4975f2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.pro @@ -0,0 +1,16 @@ +TEMPLATE = app + +SOURCES += main.cpp + +TRANSLATIONS = project.ts +CONFIG += console + +CODECFORSRC = CP1252 +CODECFORTR = UTF-8 + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result new file mode 100644 index 0000000..0ebdbfd --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<defaultcodec>UTF-8</defaultcodec> +<context> + <name>FooBar</name> + <message> + <location filename="main.cpp" line="10"/> + <source>random ascii only</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="11"/> + <source>this contains an umlaut ü &uuml;</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="12"/> + <source>random ascii only in utf8</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="13"/> + <source>umlaut ü &uuml; in utf8</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt new file mode 100644 index 0000000..8a0bd11 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt @@ -0,0 +1,4 @@ +.*/lupdate/testdata/good/lacksqobject/main.cpp:17: Class 'B' lacks Q_OBJECT macro +.*/lupdate/testdata/good/lacksqobject/main.cpp:26: Class 'C' lacks Q_OBJECT macro +.*/lupdate/testdata/good/lacksqobject/main.cpp:37: Class 'nsB::B' lacks Q_OBJECT macro +.*/lupdate/testdata/good/lacksqobject/main.cpp:45: Class 'nsB::C' lacks Q_OBJECT macro diff --git a/tests/auto/linguist/lupdate/testdata/good/lacksqobject/main.cpp b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/main.cpp new file mode 100644 index 0000000..05fcd79 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/main.cpp @@ -0,0 +1,47 @@ +// 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 <QtCore> + + +// +// Test 'lacks Q_OBJECT' reporting on namespace scopes +// + +class B : public QObject { + //Q_OBJECT + void foo(); +}; + +void B::foo() { + tr("Bla", "::B"); +} + + +class C : public QObject { + //Q_OBJECT + void foo() { + tr("Bla", "::C"); + } +}; + + +namespace nsB { + + class B : public QObject { + //Q_OBJECT + void foo(); + }; + + void B::foo() { + tr("Bla", "nsB::B"); + } + + class C : public QObject { + //Q_OBJECT + void foo() { + tr("Bla", "nsB::C"); + } + }; +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.pro b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.pro new file mode 100644 index 0000000..7547a8d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES = main.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.ts.result new file mode 100644 index 0000000..bab0881 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.ts.result @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>B</name> + <message> + <location filename="main.cpp" line="17"/> + <source>Bla</source> + <comment>::B</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>C</name> + <message> + <location filename="main.cpp" line="24"/> + <source>Bla</source> + <comment>::C</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>nsB::B</name> + <message> + <location filename="main.cpp" line="37"/> + <source>Bla</source> + <comment>nsB::B</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>nsB::C</name> + <message> + <location filename="main.cpp" line="43"/> + <source>Bla</source> + <comment>nsB::C</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp new file mode 100644 index 0000000..af8534d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp @@ -0,0 +1,28 @@ + +// The first line in this file should always be empty, its part of the test!! +class Foo : public QObject +{ + Q_OBJECT +public: + Foo(); +}; + +Foo::Foo(MainWindow *parent) + : QObject(parent) +{ + tr("This is the first entry."); + tr("A second message."); tr("And a second one on the same line."); + tr("This string did move from the bottom."); + tr("This tr is new."); + tr("This one moved in from another file."); + tr("Now again one which is just where it was."); + + tr("Just as this one."); + tr("Another alien."); + tr("This is from the bottom, too."); + tr("Third string from the bottom."); + tr("Fourth one!"); + tr("They are coming!"); + tr("They are everywhere!"); + tr("An earthling again."); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_ordering/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/lupdatecmd new file mode 100644 index 0000000..91a4800 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/lupdatecmd @@ -0,0 +1,5 @@ +# Add the command that lupdate should run here. If it can't find anything it will default to +# 'lupdate project.pro -ts project.ts' + +# lupdate project.pro +lupdate -silent -locations relative project.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.pro b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.pro new file mode 100644 index 0000000..e79456f --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += foo.cpp + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.before new file mode 100644 index 0000000..d70193f --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.before @@ -0,0 +1,74 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS><TS version="2.0"> +<context> + <name>Bar</name> + <message> + <location filename="bar1.cpp" line="13"/> + <source>Another alien.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="bar1.cpp" line="14"/> + <source>They are coming!</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="bar1.cpp" line="16"/> + <source>They are everywhere!</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="bar1.cpp" line="18"/> + <source>This one moved in from another file.</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Foo</name> + <message> + <location filename="foo1.cpp" line="13"/> + <source>This is the first entry.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="14"/> + <source>A second message.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="15"/> + <source>Now again one which is just where it was.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="16"/> + <source>Just as this one.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="17"/> + <source>An earthling again.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="18"/> + <source>This is from the bottom, too.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="19"/> + <source>Third string from the bottom.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="20"/> + <source>Fourth one!</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="foo1.cpp" line="21"/> + <source>This string did move from the bottom.</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.result new file mode 100644 index 0000000..2027efd --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.result @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>Foo</name> + <message> + <location filename="foo.cpp" line="+13"/> + <source>This is the first entry.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>A second message.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+0"/> + <source>And a second one on the same line.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+2"/> + <source>This tr is new.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>This one moved in from another file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>Now again one which is just where it was.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+2"/> + <source>Just as this one.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>Another alien.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+4"/> + <source>They are coming!</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>They are everywhere!</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>An earthling again.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="-5"/> + <source>This is from the bottom, too.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>Third string from the bottom.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="+1"/> + <source>Fourth one!</source> + <translation type="unfinished"></translation> + </message> + <message> + <location line="-9"/> + <source>This string did move from the bottom.</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.pro b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.pro new file mode 100644 index 0000000..6c704c2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +FORMS += project.ui + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.before new file mode 100644 index 0000000..fdc2a99 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.before @@ -0,0 +1,14 @@ +<?xml version="1.0"?> +<!DOCTYPE TS><TS version="1.1"> +<context> + <name>FindDialog</name> + <message> + <source>Qt Assistant - Finn text</source> + <translation></translation> + </message> + <message> + <source>Finn tekst</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result new file mode 100644 index 0000000..f9d26df --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <source>Qt Assistant - Finn text</source> + <translation></translation> + </message> + <message> + <source>Finn tekst</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ui b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ui new file mode 100644 index 0000000..7adb650 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ui @@ -0,0 +1,44 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>FindDialog</class> + <widget class="QWidget" name="FindDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>172</height> + </rect> + </property> + <property name="windowTitle" > + <string>Qt Assistant - Finn text</string><!-- changed to uppercase --> + </property> + <property name="height" > + <string>Finn tekst</string> + </property> + </widget> + <tabstops> + <tabstop>comboFind</tabstop> + <tabstop>checkWords</tabstop> + <tabstop>checkCase</tabstop> + <tabstop>radioForward</tabstop> + <tabstop>radioBackward</tabstop> + <tabstop>findButton</tabstop> + <tabstop>closeButton</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/main.cpp b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/main.cpp new file mode 100644 index 0000000..e058da0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/main.cpp @@ -0,0 +1,23 @@ +#include <QApplication> +#include <QDebug> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QTranslator translator; + translator.load("whitespace"); + app.installTranslator(&translator); + + QObject::tr("\nnewline at the start"); + QObject::tr("newline at the end\n"); + QObject::tr("newline and space at the end\n "); + QObject::tr("space and newline at the end \n"); + QObject::tr("\tTab at the start and newline at the end\n"); + QObject::tr("\n\tnewline and tab at the start"); + QObject::tr(" \tspace and tab at the start"); + QObject::tr(" space_first"); + QObject::tr("space_last "); + QObject::tr("carriage return and line feed last\r\n"); + return app.exec(); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.pro b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.pro new file mode 100644 index 0000000..f4faf2f --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES = main.cpp + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.before new file mode 100644 index 0000000..3acae3e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.before @@ -0,0 +1,70 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS><TS version="1.1"> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="7"/> + <source> +newline at the start</source> + <translation> +NEWLINE AT THE START</translation> + </message> + <message> + <location filename="main.cpp" line="8"/> + <source>newline at the end +</source> + <translation>NEWLINE AT THE END +</translation> + </message> + <message> + <location filename="main.cpp" line="9"/> + <source>newline and space at the end + </source> + <translation>NEWLINE AND SPACE AT THE END + </translation> + </message> + <message> + <location filename="main.cpp" line="10"/> + <source>space and newline at the end +</source> + <translation>SPACE AND NEWLINE AT THE END +</translation> + </message> + <message> + <location filename="main.cpp" line="11"/> + <source><byte value="x9"/>Tab at the start and newline at the end +</source> + <translation><byte value="x9"/>TAB AT THE START AND NEWLINE AT THE END +</translation> + </message> + <message> + <location filename="main.cpp" line="12"/> + <source> +<byte value="x9"/>newline and tab at the start</source> + <translation> +<byte value="x9"/>NEWLINE AND TAB AT THE START</translation> + </message> + <message> + <location filename="main.cpp" line="13"/> + <source> <byte value="x9"/>space and tab at the start</source> + <translation> <byte value="x9"/>SPACE AND TAB AT THE START</translation> + </message> + <message> + <location filename="main.cpp" line="14"/> + <source> space_first</source> + <translation> SPACE_FIRST</translation> + </message> + <message> + <location filename="main.cpp" line="15"/> + <source>space_last </source> + <translation>SPACE_LAST </translation> + </message> + <message> + <location filename="main.cpp" line="21"/> + <source>carriage return and line feed last<byte value="xd"/> +</source> + <translation type="unfinished">CARRIAGE RETURN AND LINE FEED LAST<byte value="xd"/> +</translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.result new file mode 100644 index 0000000..6d6b469 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.result @@ -0,0 +1,71 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="12"/> + <source> +newline at the start</source> + <translation> +NEWLINE AT THE START</translation> + </message> + <message> + <location filename="main.cpp" line="13"/> + <source>newline at the end +</source> + <translation>NEWLINE AT THE END +</translation> + </message> + <message> + <location filename="main.cpp" line="14"/> + <source>newline and space at the end + </source> + <translation>NEWLINE AND SPACE AT THE END + </translation> + </message> + <message> + <location filename="main.cpp" line="15"/> + <source>space and newline at the end +</source> + <translation>SPACE AND NEWLINE AT THE END +</translation> + </message> + <message> + <location filename="main.cpp" line="16"/> + <source> Tab at the start and newline at the end +</source> + <translation> TAB AT THE START AND NEWLINE AT THE END +</translation> + </message> + <message> + <location filename="main.cpp" line="17"/> + <source> + newline and tab at the start</source> + <translation> + NEWLINE AND TAB AT THE START</translation> + </message> + <message> + <location filename="main.cpp" line="18"/> + <source> space and tab at the start</source> + <translation> SPACE AND TAB AT THE START</translation> + </message> + <message> + <location filename="main.cpp" line="19"/> + <source> space_first</source> + <translation> SPACE_FIRST</translation> + </message> + <message> + <location filename="main.cpp" line="20"/> + <source>space_last </source> + <translation>SPACE_LAST </translation> + </message> + <message> + <location filename="main.cpp" line="21"/> + <source>carriage return and line feed last +</source> + <translation type="unfinished">CARRIAGE RETURN AND LINE FEED LAST +</translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp new file mode 100644 index 0000000..7edb923 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp @@ -0,0 +1,25 @@ + +// The first line in this file should always be empty, its part of the test!! +class FindDialog : public QDialog +{ + Q_OBJECT +public: + FindDialog(MainWindow *parent); + void reset(); +}; + +FindDialog::FindDialog(MainWindow *parent) + : QDialog(parent) +{ + QString trans = tr("Enter the text you want to find."); + trans = tr("Search reached end of the document"); + trans = tr("Search reached start of the document"); + trans = tr( "Text not found" ); +} + +void FindDialog::reset() +{ + tr("%n item(s)", "merge from singular to plural form", 4); + tr("%n item(s)", "merge from a finished singular form to an unfinished plural form", 4); +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.pro b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.pro new file mode 100644 index 0000000..e988c0a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += finddialog.cpp + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before new file mode 100644 index 0000000..474444f --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before @@ -0,0 +1,48 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS><TS version="1.1" language="zh_CN"> +<context> + <name>FindDialog</name> + <message> + <source></source> + <comment>magic context comment</comment> + <translatorcomment>random translator comment</translatorcomment> + <translation></translation> + </message> + <message> + <location filename="finddialog.cpp" line="14"/> + <source>Enter the text you want to find.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="15"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="16"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="17"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location filename="finddialog.cpp" line="22"/> + <source>%n item(s)</source> + <comment>merge from singular to plural form</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="finddialog.cpp" line="23"/> + <source>%n item(s)</source> + <comment>merge from a finished singular form to an unfinished plural form</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result new file mode 100644 index 0000000..152b568 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0" language="zh_CN"> +<context> + <name>FindDialog</name> + <message> + <source></source> + <comment>magic context comment</comment> + <translatorcomment>random translator comment</translatorcomment> + <translation></translation> + </message> + <message> + <location filename="finddialog.cpp" line="14"/> + <source>Enter the text you want to find.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="15"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="16"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="17"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location filename="finddialog.cpp" line="22"/> + <source>%n item(s)</source> + <comment>merge from singular to plural form</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="finddialog.cpp" line="23"/> + <source>%n item(s)</source> + <comment>merge from a finished singular form to an unfinished plural form</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp new file mode 100644 index 0000000..f587618 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "finddialog.h" +#include "mainwindow.h" +#include "tabbedbrowser.h" +#include "helpwindow.h" + +#include <QTextBrowser> +#include <QTextCursor> +#include <QStatusBar> +#include <QLineEdit> +#include <QDateTime> +#include <QGridLayout> + +CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent) + : QStandardItemModel(rows, columns, parent) +{} +QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value, + int hits, Qt::MatchFlags flags) const +{ + if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) + flags |= Qt::MatchCaseSensitive; + + return QStandardItemModel::match(start, role, value, hits, flags); +} + +FindDialog::FindDialog(MainWindow *parent) + : QDialog(parent) +{ + contentsWidget = new QWidget(this); + ui.setupUi(contentsWidget); + ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); + + QVBoxLayout *l = new QVBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + l->addWidget(contentsWidget); + + lastBrowser = 0; + onceFound = false; + findExpr.clear(); + + sb = new QStatusBar(this); + l->addWidget(sb); + + sb->showMessage(tr("Enter the text you want to find.")); + + connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); + connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); +} + +FindDialog::~FindDialog() +{ +} + +void FindDialog::findButtonClicked() +{ + doFind(ui.radioForward->isChecked()); +} + +void FindDialog::doFind(bool forward) +{ + QTextBrowser *browser = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser()); + sb->clearMessage(); + + if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) + onceFound = false; + findExpr = ui.comboFind->currentText(); + + QTextDocument::FindFlags flags = 0; + + if (ui.checkCase->isChecked()) + flags |= QTextDocument::FindCaseSensitively; + + if (ui.checkWords->isChecked()) + flags |= QTextDocument::FindWholeWords; + + QTextCursor c = browser->textCursor(); + if (!c.hasSelection()) { + if (forward) + c.movePosition(QTextCursor::Start); + else + c.movePosition(QTextCursor::End); + + browser->setTextCursor(c); + } + + QTextDocument::FindFlags options; + if (forward == false) + flags |= QTextDocument::FindBackward; + + QTextCursor found = browser->document()->find(findExpr, c, flags); + if (found.isNull()) { + if (onceFound) { + if (forward) + statusMessage(tr("Search reached end of the document")); + else + statusMessage(tr("Search reached start of the document")); + } else { + statusMessage(tr( "Text not found" )); + } + } else { + browser->setTextCursor(found); + } + onceFound |= !found.isNull(); + lastBrowser = browser; +} + +bool FindDialog::hasFindExpression() const +{ + // statusMessage(tr( "Should be obsolete" )); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/lupdatecmd b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/lupdatecmd new file mode 100644 index 0000000..d200143 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/lupdatecmd @@ -0,0 +1,5 @@ +# Add the command that lupdate should run here. If it can't find anything it will default to +# 'lupdate project.pro -ts project.ts' + +# lupdate project.pro +lupdate -silent -noobsolete project.pro diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.pro b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.pro new file mode 100644 index 0000000..e988c0a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += finddialog.cpp + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before new file mode 100644 index 0000000..12e30b5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS><TS version="1.1"> +<context> + <name>FindDialog</name> + <message> + <location filename="finddialog.cpp" line="57"/> + <source>Enter the text you want to find.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="107"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="109"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="111"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="122"/> + <source>Should be obsolete</source> + <translation type="unfinished">SHOULD BE OBSOLETE</translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result new file mode 100644 index 0000000..21d1ca0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <location filename="finddialog.cpp" line="57"/> + <source>Enter the text you want to find.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="107"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="109"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="111"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp new file mode 100644 index 0000000..e23d129 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp @@ -0,0 +1,146 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "finddialog.h" +#include "mainwindow.h" +#include "tabbedbrowser.h" +#include "helpwindow.h" + +#include <QTextBrowser> +#include <QTextCursor> +#include <QStatusBar> +#include <QLineEdit> +#include <QDateTime> +#include <QGridLayout> + +CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent) + : QStandardItemModel(rows, columns, parent) +{} +QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value, + int hits, Qt::MatchFlags flags) const +{ + if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) + flags |= Qt::MatchCaseSensitive; + + return QStandardItemModel::match(start, role, value, hits, flags); +} + +FindDialog::FindDialog(MainWindow *parent) + : QDialog(parent) +{ + contentsWidget = new QWidget(this); + ui.setupUi(contentsWidget); + ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); + + QVBoxLayout *l = new QVBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + l->addWidget(contentsWidget); + + lastBrowser = 0; + onceFound = false; + findExpr.clear(); + + sb = new QStatusBar(this); + l->addWidget(sb); + + + // Move it to another line and change the text, + // then lupdate should add this one as a new one, and mark the old one as obsolete. + sb->showMessage(tr("Enter the text you want to find.")); + + connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); + connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); +} + +FindDialog::~FindDialog() +{ +} + +void FindDialog::findButtonClicked() +{ + doFind(ui.radioForward->isChecked()); +} + +void FindDialog::doFind(bool forward) +{ + QTextBrowser *browser = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser()); + sb->clearMessage(); + + if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) + onceFound = false; + findExpr = ui.comboFind->currentText(); + + QTextDocument::FindFlags flags = 0; + + if (ui.checkCase->isChecked()) + flags |= QTextDocument::FindCaseSensitively; + + if (ui.checkWords->isChecked()) + flags |= QTextDocument::FindWholeWords; + + QTextCursor c = browser->textCursor(); + if (!c.hasSelection()) { + if (forward) + c.movePosition(QTextCursor::Start); + else + c.movePosition(QTextCursor::End); + + browser->setTextCursor(c); + } + + QTextDocument::FindFlags options; + if (forward == false) + flags |= QTextDocument::FindBackward; + + QTextCursor found = browser->document()->find(findExpr, c, flags); + if (found.isNull()) { + if (onceFound) { + if (forward) + statusMessage(tr("Search reached end of the document")); + else + statusMessage(tr("Search reached start of the document")); + } else { + statusMessage(tr( "Text not found" )); + } + } else { + browser->setTextCursor(found); + } + onceFound |= !found.isNull(); + lastBrowser = browser; +} + +bool FindDialog::hasFindExpression() const +{ + return !findExpr.isEmpty(); +} + +void FindDialog::statusMessage(const QString &message) +{ + if (isVisible()) + sb->showMessage(message); + else + static_cast<MainWindow*>(parent())->statusBar()->showMessage(message, 2000); +} + +MainWindow *FindDialog::mainWindow() const +{ + return static_cast<MainWindow*>(parentWidget()); +} + +void FindDialog::reset() +{ + ui.comboFind->setFocus(); + ui.comboFind->lineEdit()->setSelection( + 0, ui.comboFind->lineEdit()->text().length()); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.pro b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.pro new file mode 100644 index 0000000..e988c0a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += finddialog.cpp + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before new file mode 100644 index 0000000..271cc39 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before @@ -0,0 +1,26 @@ +<?xml version="1.0"?> +<!DOCTYPE TS><TS version="1.1"> +<context> + <name>FindDialog</name> + <message> + <location filename="finddialog.cpp" line="57"/> + <source>Enter the text you are looking for.</source> + <translation type="unfinished">Skriv inn teksten du soker etter</translation> + </message> + <message> + <location filename="finddialog.cpp" line="107"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="109"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="111"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result new file mode 100644 index 0000000..b7074fe --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <source>Enter the text you are looking for.</source> + <translation type="obsolete">Skriv inn teksten du soker etter</translation> + </message> + <message> + <location filename="finddialog.cpp" line="60"/> + <source>Enter the text you want to find.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="110"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="112"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="114"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.pro b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.pro new file mode 100644 index 0000000..28ba291 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +FORMS += project.ui + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before new file mode 100644 index 0000000..e297784 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before @@ -0,0 +1,22 @@ +<?xml version="1.0"?> +<!DOCTYPE TS><TS version="1.1"> +<context> + <name>FindDialog</name> + <message> + <location filename="project.ui" line="27"/> + <source>Qt Assistant - Find text</source> + <!--should be changed to unfinished, since we are changing the sourcetext in the ui file--> + <translation>Qt Assistant - Finn tekst</translation> + </message> + <message> + <location filename="project.ui" line="30"/> + <source>300px</source> + <translation>300px</translation> + </message> + <message> + <location filename="project.ui" line="33"/> + <source>400px</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result new file mode 100644 index 0000000..b21f583 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <location filename="project.ui" line="27"/> + <source>Qt Assistant - Find Text</source> + <oldsource>Qt Assistant - Find text</oldsource> + <translation type="unfinished">Qt Assistant - Finn tekst</translation> + </message> + <message> + <location filename="project.ui" line="30"/> + <source>300px</source> + <translation>300px</translation> + </message> + <message> + <location filename="project.ui" line="33"/> + <source>401 pixels</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui new file mode 100644 index 0000000..c10545d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui @@ -0,0 +1,47 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>FindDialog</class> + <widget class="QWidget" name="FindDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>172</height> + </rect> + </property> + <property name="windowTitle" > + <string>Qt Assistant - Find Text</string><!-- changed to uppercase, marked as finished --> + </property> + <property name="height" > + <string>300px</string> + </property> + <property name="width" > + <string>401 pixels</string><!-- Changed from 400px to 401 pixels, but this is marked as unfinished --> + </property> + </widget> + <tabstops> + <tabstop>comboFind</tabstop> + <tabstop>checkWords</tabstop> + <tabstop>checkCase</tabstop> + <tabstop>radioForward</tabstop> + <tabstop>radioBackward</tabstop> + <tabstop>findButton</tabstop> + <tabstop>closeButton</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.pro b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.pro new file mode 100644 index 0000000..28ba291 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +FORMS += project.ui + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.before new file mode 100644 index 0000000..f06c22c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.before @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<!DOCTYPE TS><TS version="1.1"> +<context> + <name>FindDialog</name> + <message> + <location filename="project.ui" line="20"/> + <source>Test similarity</source> + <translation type="unfinished">Test likhet (test1)</translation> + </message> + <message> + <location filename="project.ui" line="23"/> + <source>Similarity should have kicked in here!</source> + <translation type="unfinished">Test likhet (test2)</translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result new file mode 100644 index 0000000..d65110a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <source>Test similarity</source> + <translation type="obsolete">Test likhet (test1)</translation> + </message> + <message> + <location filename="project.ui" line="20"/> + <source>This should not be considered to be more or less equal to the corresponding one in the ts file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="project.ui" line="23"/> + <source>Here, similarity should kick in!</source> + <oldsource>Similarity should have kicked in here!</oldsource> + <translation type="unfinished">Test likhet (test2)</translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui new file mode 100644 index 0000000..0d0defd --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui @@ -0,0 +1,26 @@ +<ui version="4.0" > + <author></author> + <comment><!-- +********************************************************************* +** +** Do not change the location (linenumber) of the <string> elements in this file! +** That will make the test break! +** +** If you need to add some tests, please add them to the end of the file! +** +** +********************************************************************* +--> +</comment> + <exportmacro></exportmacro> + <class>FindDialog</class> + <widget class="QWidget" name="FindDialog" > + <property name="test1"> + <!-- If the sourcetext is not similar to the vernacular sourcetext, mark the old one as obsolete and the new one as unfinished --> + <string>This should not be considered to be more or less equal to the corresponding one in the ts file.</string> + </property> + <property name="test2"> + <string>Here, similarity should kick in!</string> + </property> + </widget> +</ui> diff --git a/tests/auto/linguist/lupdate/testdata/good/multiple_locations/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/finddialog.cpp new file mode 100644 index 0000000..c3881d3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/finddialog.cpp @@ -0,0 +1,7 @@ + +QT_TRANSLATE_NOOP("context", "just a message") + + + +//: This is one comment +QT_TRANSLATE_NOOP("context", "just a message") diff --git a/tests/auto/linguist/lupdate/testdata/good/multiple_locations/main.cpp b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/main.cpp new file mode 100644 index 0000000..71d9085 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/main.cpp @@ -0,0 +1,13 @@ + + + + +//: This is a comment, too. +QT_TRANSLATE_NOOP("context", "just a message") + + + + + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.pro b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.pro new file mode 100644 index 0000000..4582705 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp +SOURCES += finddialog.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result new file mode 100644 index 0000000..dd013fa --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>context</name> + <message> + <location filename="finddialog.cpp" line="2"/> + <location filename="finddialog.cpp" line="7"/> + <location filename="main.cpp" line="6"/> + <source>just a message</source> + <extracomment>This is one comment +---------- +This is a comment, too.</extracomment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp b/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp new file mode 100644 index 0000000..9f5a98c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp @@ -0,0 +1,97 @@ +#include <QtCore> + +class Class : public QObject +{ + Q_OBJECT + + class SubClass + { + void f() + { + tr("nested class context"); + } + }; + + void f() + { + tr("just class context"); + } +}; + +namespace Outer { + +class Class : public QObject { Q_OBJECT }; + +namespace Middle1 { + +class Class : public QObject { Q_OBJECT }; + +namespace Inner1 { + +class Class : public QObject { Q_OBJECT }; + +} + +namespace I = Inner1; + +class Something; +class Different; + +} + +namespace Middle2 { + +class Class : public QObject { Q_OBJECT }; + +namespace Inner2 { + +class Class : public QObject { Q_OBJECT }; + +namespace IO = Middle2; + +} + +namespace I = Inner2; + +} + +namespace MI = Middle1::Inner1; + +namespace O = ::Outer; + +class Middle1::Different : QObject { +Q_OBJECT + void f() { + tr("different namespaced class def"); + } +}; + +} + +namespace O = Outer; +namespace OM = Outer::Middle1; +namespace OMI = Outer::Middle1::I; + +int main() +{ + Class::tr("outestmost class"); + Outer::Class::tr("outer class"); + Outer::MI::Class::tr("innermost one"); + OMI::Class::tr("innermost two"); + O::Middle1::I::Class::tr("innermost three"); + O::Middle2::I::Class::tr("innermost three b"); + OM::I::Class::tr("innermost four"); + return 0; +} + +class OM::Something : QObject { +Q_OBJECT + void f() { + tr("namespaced class def"); + } + void g() { + tr("namespaced class def 2"); + } +}; + +#include "main.moc" diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.pro b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.pro new file mode 100644 index 0000000..56d472c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result new file mode 100644 index 0000000..d1193d3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result @@ -0,0 +1,82 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>Class</name> + <message> + <location filename="main.cpp" line="11"/> + <source>nested class context</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="17"/> + <source>just class context</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="77"/> + <source>outestmost class</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Outer::Class</name> + <message> + <location filename="main.cpp" line="78"/> + <source>outer class</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Outer::Middle1::Different</name> + <message> + <location filename="main.cpp" line="65"/> + <source>different namespaced class def</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Outer::Middle1::Inner1::Class</name> + <message> + <location filename="main.cpp" line="79"/> + <source>innermost one</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="80"/> + <source>innermost two</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="81"/> + <source>innermost three</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="83"/> + <source>innermost four</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Outer::Middle1::Something</name> + <message> + <location filename="main.cpp" line="90"/> + <source>namespaced class def</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="93"/> + <source>namespaced class def 2</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Outer::Middle2::Inner2::Class</name> + <message> + <location filename="main.cpp" line="82"/> + <source>innermost three b</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/main.cpp new file mode 100644 index 0000000..72a1590 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/main.cpp @@ -0,0 +1,18 @@ +// 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!!! + +class Dialog2 : public QDialog +{ + Q_OBJECT + void func(); + +}; + +void Dialog2::func() +{ + tr("cat\351gorie"); + + tr("F\374r \310lise") +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.pro b/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.pro new file mode 100644 index 0000000..cb18ea4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.ts.result new file mode 100644 index 0000000..a49b47a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.ts.result @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>Dialog2</name> + <message> + <location filename="main.cpp" line="13"/> + <source>catégorie</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="15"/> + <source>Für Èlise</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp new file mode 100644 index 0000000..65eeed5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp @@ -0,0 +1,229 @@ +// 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 <QtCore> +#include <QtGui> + +// +// Test namespace scoping +// + +class D : public QObject { + Q_OBJECT + public: + QString foo() { + return tr("test", "D"); + } + +}; + +namespace A { + + class C : public QObject { + Q_OBJECT + public: + void foo(); + }; + + void C::foo() { + tr("Bla", "A::C"); + } + + void goo() { + C::tr("Bla", "A::C"); // Is identical to the previous tr(), (same context, sourcetext and comment, + // so it should not add another entry to the list of messages) + } + + void goo2() { + C::tr("Bla 2", "A::C"); //Should be in the same namespace as the previous tr() + } + +} + + +namespace X { + + class D : public QObject { + Q_OBJECT + public: + + }; + + class E : public QObject { + Q_OBJECT + public: + void foo() { D::tr("foo", "D"); } // Note that this is X::D from 440 on + }; + + + namespace Y { + class E : public QObject { + Q_OBJECT + + }; + + class C : public QObject { + Q_OBJECT + void foo(); + }; + + void C::foo() { + tr("Bla", "X::Y::C"); + } + + void goo() { + D::tr("Bla", "X::D"); //This should be assigned to the X::D context + } + + void goo2() { + E::tr("Bla", "X::Y::E"); //This should be assigned to the X::Y::E context + Y::E::tr("Bla", "X::Y::E"); //This should be assigned to the X::Y::E context + } + + }; // namespace Y + + class F : public QObject { + Q_OBJECT + inline void inlinefunc() { + tr("inline function", "X::F"); + } + }; +} // namespace X + +namespace ico { + namespace foo { + class A : public QObject { + A(); + }; + + A::A() { + tr("myfoo", "ico::foo::A"); + QObject::tr("task 161186", "QObject"); + } + } +} + +namespace AA { +class C {}; +} + +/** + * the context of a message should not be affected by any inherited classes + * + * Keep this disabled for now, but at a long-term range it should work. + */ +namespace Gui { + class MainWindow : public QMainWindow, + public AA::C + { + Q_OBJECT +public: + MainWindow() + { + tr("More bla", "Gui::MainWindow"); + } + + }; +} //namespace Gui + + +namespace A1 { + class AB : public QObject { + Q_OBJECT + public: + + friend class OtherClass; + + QString inlineFuncAfterFriendDeclaration() const { + return tr("inlineFuncAfterFriendDeclaration", "A1::AB"); + } + }; + class B : AB { + Q_OBJECT + public: + QString foo() const { return tr("foo", "A1::B"); } + }; + + // This is valid C++ too.... + class V : virtual AB { + Q_OBJECT + public: + QString bar() const { return tr("bar", "A1::V"); } + }; + + class W : virtual public AB { + Q_OBJECT + public: + QString baz() const { return tr("baz", "A1::W"); } + }; +} + +class ForwardDecl; + + +class B1 : public QObject { +}; + +class C1 : public QObject { +}; + +namespace A1 { + +class B2 : public QObject { +}; + +} + +void func1() +{ + B1::tr("test TRANSLATOR comment (1)", "B1"); + +} + +using namespace A1; +/* + TRANSLATOR A1::B2 +*/ +void func2() +{ + B2::tr("test TRANSLATOR comment (2)", "A1::B2"); + C1::tr("test TRANSLATOR comment (3)", "C1"); +} + +void func3() +{ + B2::tr("test TRANSLATOR comment (4)", "A1::B2"); +} + +/* + TRANSLATOR B2 + This is a comment to the translator. +*/ +void func4() +{ + B2::tr("test TRANSLATOR comment (5)", "A1::B2"); +} + +namespace A1 { +namespace B3 { +class C2 : public QObject { +QString foo(); +}; +} +} + +namespace D1 = A1::B3; +using namespace D1; + +// TRANSLATOR A1::B3::C2 +QString C2::foo() +{ + return tr("test TRANSLATOR comment (6)", "A1::B3::C2"); // 4.4 screws up +} + + + +int main(int /*argc*/, char ** /*argv*/) { + return 0; +} + +#include "main.moc" diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.pro new file mode 100644 index 0000000..7547a8d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES = main.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result new file mode 100644 index 0000000..04bb3ae --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result @@ -0,0 +1,192 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>A1::AB</name> + <message> + <location filename="main.cpp" line="137"/> + <source>inlineFuncAfterFriendDeclaration</source> + <comment>A1::AB</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>A1::B</name> + <message> + <location filename="main.cpp" line="143"/> + <source>foo</source> + <comment>A1::B</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>A1::B2</name> + <message> + <location filename="main.cpp" line="188"/> + <source>test TRANSLATOR comment (2)</source> + <comment>A1::B2</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="194"/> + <source>test TRANSLATOR comment (4)</source> + <comment>A1::B2</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="203"/> + <source>test TRANSLATOR comment (5)</source> + <comment>A1::B2</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>A1::B3::C2</name> + <message> + <location filename="main.cpp" line="220"/> + <source>test TRANSLATOR comment (6)</source> + <comment>A1::B3::C2</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>A1::V</name> + <message> + <location filename="main.cpp" line="150"/> + <source>bar</source> + <comment>A1::V</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>A1::W</name> + <message> + <location filename="main.cpp" line="156"/> + <source>baz</source> + <comment>A1::W</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>A::C</name> + <message> + <location filename="main.cpp" line="28"/> + <location filename="main.cpp" line="32"/> + <source>Bla</source> + <comment>A::C</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="37"/> + <source>Bla 2</source> + <comment>A::C</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>B1</name> + <message> + <location filename="main.cpp" line="178"/> + <source>test TRANSLATOR comment (1)</source> + <comment>B1</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>B2</name> + <message> + <location filename="main.cpp" line="197"/> + <source></source> + <comment>This is a comment to the translator.</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>C1</name> + <message> + <location filename="main.cpp" line="189"/> + <source>test TRANSLATOR comment (3)</source> + <comment>C1</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>D</name> + <message> + <location filename="main.cpp" line="14"/> + <source>test</source> + <comment>D</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Gui::MainWindow</name> + <message> + <location filename="main.cpp" line="122"/> + <source>More bla</source> + <comment>Gui::MainWindow</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="100"/> + <source>task 161186</source> + <comment>QObject</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>X::D</name> + <message> + <location filename="main.cpp" line="54"/> + <source>foo</source> + <comment>D</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="74"/> + <source>Bla</source> + <comment>X::D</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>X::F</name> + <message> + <location filename="main.cpp" line="87"/> + <source>inline function</source> + <comment>X::F</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>X::Y::C</name> + <message> + <location filename="main.cpp" line="70"/> + <source>Bla</source> + <comment>X::Y::C</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>X::Y::E</name> + <message> + <location filename="main.cpp" line="78"/> + <location filename="main.cpp" line="79"/> + <source>Bla</source> + <comment>X::Y::E</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>ico::foo::A</name> + <message> + <location filename="main.cpp" line="99"/> + <source>myfoo</source> + <comment>ico::foo::A</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/finddialog.cpp new file mode 100644 index 0000000..454c173 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/finddialog.cpp @@ -0,0 +1,156 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "finddialog.h" +#include "mainwindow.h" +#include "tabbedbrowser.h" +#include "helpwindow.h" + +#include <QTextBrowser> +#include <QTextCursor> +#include <QStatusBar> +#include <QLineEdit> +#include <QDateTime> +#include <QGridLayout> + +CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent) + : QStandardItemModel(rows, columns, parent) +{} +QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value, + int hits, Qt::MatchFlags flags) const +{ + if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) + flags |= Qt::MatchCaseSensitive; + + return QStandardItemModel::match(start, role, value, hits, flags); +} + +FindDialog::FindDialog(MainWindow *parent) + : QDialog(parent) +{ + contentsWidget = new QWidget(this); + ui.setupUi(contentsWidget); + ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); + + QVBoxLayout *l = new QVBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + l->addWidget(contentsWidget); + + lastBrowser = 0; + onceFound = false; + findExpr.clear(); + + sb = new QStatusBar(this); + l->addWidget(sb); + + sb->showMessage(tr("Enter the text you are looking for.")); + + connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); + connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); +} + +FindDialog::~FindDialog() +{ +} + +void FindDialog::findButtonClicked() +{ + doFind(ui.radioForward->isChecked()); +} + +void FindDialog::doFind(bool forward) +{ + QTextBrowser *browser = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser()); + sb->clearMessage(); + + if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) + onceFound = false; + findExpr = ui.comboFind->currentText(); + + QTextDocument::FindFlags flags = 0; + + if (ui.checkCase->isChecked()) + flags |= QTextDocument::FindCaseSensitively; + + if (ui.checkWords->isChecked()) + flags |= QTextDocument::FindWholeWords; + + QTextCursor c = browser->textCursor(); + if (!c.hasSelection()) { + if (forward) + c.movePosition(QTextCursor::Start); + else + c.movePosition(QTextCursor::End); + + browser->setTextCursor(c); + } + + QTextDocument::FindFlags options; + if (forward == false) + flags |= QTextDocument::FindBackward; + + QTextCursor found = browser->document()->find(findExpr, c, flags); + if (found.isNull()) { + if (onceFound) { + if (forward) + statusMessage(tr("Search reached end of the document")); + else + statusMessage(tr("Search reached start of the document")); + } else { + statusMessage(tr( "Text not found" )); + } + } else { + browser->setTextCursor(found); + } + onceFound |= !found.isNull(); + lastBrowser = browser; +} + +bool FindDialog::hasFindExpression() const +{ + return !findExpr.isEmpty(); +} + +void FindDialog::statusMessage(const QString &message) +{ + if (isVisible()) + sb->showMessage(message); + else + static_cast<MainWindow*>(parent())->statusBar()->showMessage(message, 2000); +} + +MainWindow *FindDialog::mainWindow() const +{ + return static_cast<MainWindow*>(parentWidget()); +} + +void FindDialog::reset() +{ + ui.comboFind->setFocus(); + ui.comboFind->lineEdit()->setSelection( + 0, ui.comboFind->lineEdit()->text().length()); + + QString s = QApplication::translate("QCoreApplication", "with comment", "comment"); + QString s = QApplication::translate("QCoreApplication", "empty comment", ""); + QString s = QApplication::translate("QCoreApplication", "null comment", 0); + QString s = tr("null comment"); + + QString s = QApplication::translate("QCoreApplication", "encoding, using QCoreApplication", 0, QCoreApplication::UnicodeUTF8); + QString s = QApplication::translate("QCoreApplication", "encoding, using QApplication", 0, QApplication::UnicodeUTF8); + + QString s = QApplication::translate("KÃ¥ntekst", "encoding, using QApplication", 0, QApplication::UnicodeUTF8); + +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp new file mode 100644 index 0000000..df75baf --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -0,0 +1,158 @@ +// 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!!! +int main(char **argv, int argc) +{ + Size size = QSize(1,1); +} + +QString qt_detectRTLLanguage() +{ + return QApplication::tr("QT_LAYOUT_DIRECTION", + "Translate this string to the string 'LTR' in left-to-right" + " languages or to 'RTL' in right-to-left languages (such as Hebrew" + " and Arabic) to get proper widget layout.") == QLatin1String("RTL"); +} + + +class Dialog2 : public QDialog +{ + Q_OBJECT + void func(); + void func3(); + int getCount() const { return 2; } + +}; + +void Dialog2::func() +{ + int n = getCount(); + tr("%n files", "plural form", n); + tr("%n cars", 0, n); + tr("&Find %n cars", 0, n); + tr("Search in %n items?", 0, n); + tr("%1. Search in %n items?", 0, n); + tr("Age: %1"); + tr("There are %n house(s)", "Plurals and function call", getCount()); + + + + + QCoreApplication::translate("Plurals, QCoreApplication", "%n house(s)", "Plurals and identifier", QCoreApplication::UnicodeUTF8, n); + QCoreApplication::translate("Plurals, QCoreApplication", "%n car(s)", "Plurals and literal number", QCoreApplication::UnicodeUTF8, 1); + QCoreApplication::translate("Plurals, QCoreApplication", "%n horse(s)", "Plurals and function call", QCoreApplication::UnicodeUTF8, getCount()); + + + + + + + + + QTranslator trans; + trans.translate("QTranslator", "Simple"); + trans.translate("QTranslator", "Simple", 0); + trans.translate("QTranslator", "Simple with comment", "with comment"); + trans.translate("QTranslator", "Plural without comment", 0, 1); + trans.translate("QTranslator", "Plural with comment", "comment 1", n); + trans.translate("QTranslator", "Plural with comment", "comment 2", getCount()); + + + + + + + + + + + + +} + + + + +/* This is actually a test of how many alternative ways a struct/class can be found in a source file. + * Due to the simple parser in lupdate, it will actually not treat the remaining lines in the define + * as a macro, which is a case the 'Tok_Class' parser block might not consider, and it might loop infinite + * if it just tries to fetch the next token until it gets a '{' or a ';'. Another pitfall is that the + * context of tr("func3") might not be parsed, it won't resume normal evaluation until the '{' after the function + * signature. + * + */ +typedef struct S_ +{ +int a; +} S, *SPtr; +class ForwardDecl; + + +#define FT_DEFINE_SERVICE( name ) \ + typedef struct FT_Service_ ## name ## Rec_ \ + FT_Service_ ## name ## Rec ; \ + typedef struct FT_Service_ ## name ## Rec_ \ + const * FT_Service_ ## name ; \ + struct FT_Service_ ## name ## Rec_ + + +/* removing this comment will break this test */ + +void Dialog2::func3() +{ + tr("func3"); +} + + + + +namespace Gui { class BaseClass {}; } + + +class TestClass : QObject { + Q_OBJECT + + + inline QString inlineFunc1() { + return tr("inline function", "TestClass"); + } + + QString inlineFunc2() { + return tr("inline function 2", "TestClass"); + } + + static inline QString staticInlineFunc() { + return tr("static inline function", "TestClass"); + } + + class NoQObject : public Gui::BaseClass { + public: + inline QString hello() { return QString("hello"); } + + }; + +}; + + +class Testing : QObject { + Q_OBJECT + + inline QString f1() { + //: this is an extra comment for the translator + return tr("extra-commented string"); + return tr("not extra-commented string"); + /*: another extra-comment */ + return tr("another extra-commented string"); + /*: blah! */ + return QApplication::translate("scope", "works in translate, too", "blabb", 0); + } + +}; + +//: extra comment for NOOP +//: which spans multiple lines +QT_TRANSLATE_NOOP("scope", "string") // 4.4 says the line of this is at the next statement +//: extra comment for NOOP3 +QT_TRANSLATE_NOOP3_UTF8("scope", "string", "comment") // 4.4 doesn't see this + +QT_TRANSLATE_NOOP("scope", "string " // this is an interleaved comment + "continuation on next line") diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro new file mode 100644 index 0000000..4582705 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp +SOURCES += finddialog.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result new file mode 100644 index 0000000..9386c19 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -0,0 +1,271 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>Dialog2</name> + <message numerus="yes"> + <location filename="main.cpp" line="29"/> + <source>%n files</source> + <comment>plural form</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="30"/> + <source>%n cars</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="31"/> + <source>&Find %n cars</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="32"/> + <source>Search in %n items?</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="33"/> + <source>%1. Search in %n items?</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message> + <location filename="main.cpp" line="34"/> + <source>Age: %1</source> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="35"/> + <source>There are %n house(s)</source> + <comment>Plurals and function call</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message> + <location filename="main.cpp" line="102"/> + <source>func3</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>FindDialog</name> + <message> + <location filename="finddialog.cpp" line="57"/> + <source>Enter the text you are looking for.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="107"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="109"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="111"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="147"/> + <source>null comment</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>KÃ¥ntekst</name> + <message utf8="true"> + <location filename="finddialog.cpp" line="152"/> + <source>encoding, using QApplication</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Plurals, QCoreApplication</name> + <message numerus="yes"> + <location filename="main.cpp" line="40"/> + <source>%n house(s)</source> + <comment>Plurals and identifier</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="41"/> + <source>%n car(s)</source> + <comment>Plurals and literal number</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="42"/> + <source>%n horse(s)</source> + <comment>Plurals and function call</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> +</context> +<context> + <name>QApplication</name> + <message> + <location filename="main.cpp" line="10"/> + <source>QT_LAYOUT_DIRECTION</source> + <comment>Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>QCoreApplication</name> + <message> + <location filename="finddialog.cpp" line="144"/> + <source>with comment</source> + <comment>comment</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="145"/> + <source>empty comment</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="146"/> + <source>null comment</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="149"/> + <source>encoding, using QCoreApplication</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="finddialog.cpp" line="150"/> + <source>encoding, using QApplication</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>QTranslator</name> + <message> + <location filename="main.cpp" line="52"/> + <location filename="main.cpp" line="53"/> + <source>Simple</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="54"/> + <source>Simple with comment</source> + <comment>with comment</comment> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="55"/> + <source>Plural without comment</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="56"/> + <source>Plural with comment</source> + <comment>comment 1</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.cpp" line="57"/> + <source>Plural with comment</source> + <comment>comment 2</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> +</context> +<context> + <name>TestClass</name> + <message> + <location filename="main.cpp" line="116"/> + <source>inline function</source> + <comment>TestClass</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="120"/> + <source>inline function 2</source> + <comment>TestClass</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="124"/> + <source>static inline function</source> + <comment>TestClass</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>Testing</name> + <message> + <location filename="main.cpp" line="141"/> + <source>extra-commented string</source> + <extracomment>this is an extra comment for the translator</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="142"/> + <source>not extra-commented string</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="144"/> + <source>another extra-commented string</source> + <extracomment>another extra-comment</extracomment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>scope</name> + <message numerus="yes"> + <location filename="main.cpp" line="146"/> + <source>works in translate, too</source> + <comment>blabb</comment> + <extracomment>blah!</extracomment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message> + <location filename="main.cpp" line="153"/> + <source>string</source> + <extracomment>extra comment for NOOP which spans multiple lines</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="155"/> + <source>string</source> + <comment>comment</comment> + <extracomment>extra comment for NOOP3</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="157"/> + <source>string continuation on next line</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejava/main.java b/tests/auto/linguist/lupdate/testdata/good/parsejava/main.java new file mode 100644 index 0000000..07681d2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsejava/main.java @@ -0,0 +1,54 @@ +// 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!!! + +package com.trolltech.examples; + +public class I18N extends QDialog { + + private class MainWindow extends QMainWindow { + private String foo = tr("pack class class"); + + //: extra comment for t-tor + private String bar = tr("pack class class extra"); + + public MainWindow(QWidget parent) { + super(parent); + + listWidget = new QListWidget(); + listWidget.addItem(tr("pack class class method")); + + } + } + + public I18N(QWidget parent) { + super(parent, new Qt.WindowFlags(Qt.WindowType.WindowStaysOnTopHint)); + + tr("pack class method"); + + tr("QT_LAYOUT_DIRECTION", + "Translate this string to the string 'LTR' in left-to-right" + + " languages or to 'RTL' in right-to-left languages (such as Hebrew" + + " and Arabic) to get proper widget layout."); + + tr("%n files", "plural form", n); + tr("%n cars", null, n); + tr("Age: %1"); + tr("There are %n house(s)", "Plurals and function call", getCount()); + + QTranslator trans; + trans.translate("QTranslator", "Simple"); + trans.translate("QTranslator", "Simple", null); + trans.translate("QTranslator", "Simple with comment", "with comment"); + trans.translate("QTranslator", "Plural without comment", null, 1); + trans.translate("QTranslator", "Plural with comment", "comment 1", n); + trans.translate("QTranslator", "Plural with comment", "comment 2", getCount()); + + /*: with extra comment! */ + QCoreApplication.translate("Plurals, QCoreApplication", "%n house(s)", "Plurals and identifier", n); + + // FIXME: This will fail. + //QApplication.tr("QT_LAYOUT_DIRECTION", "scoped to qapp"); + + } + +} diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejava/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsejava/project.pro new file mode 100644 index 0000000..7e64c80 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsejava/project.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = Java + +SOURCES += main.java + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejava/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsejava/project.ts.result new file mode 100644 index 0000000..69c0a00 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parsejava/project.ts.result @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>Plurals, QCoreApplication</name> + <message numerus="yes"> + <location filename="main.java" line="47"/> + <source>%n house(s)</source> + <comment>Plurals and identifier</comment> + <extracomment>with extra comment!</extracomment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> +</context> +<context> + <name>QTranslator</name> + <message> + <location filename="main.java" line="39"/> + <location filename="main.java" line="40"/> + <source>Simple</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.java" line="41"/> + <source>Simple with comment</source> + <comment>with comment</comment> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location filename="main.java" line="42"/> + <source>Plural without comment</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.java" line="43"/> + <source>Plural with comment</source> + <comment>comment 1</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.java" line="44"/> + <source>Plural with comment</source> + <comment>comment 2</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> +</context> +<context> + <name>com.trolltech.examples.I18N</name> + <message> + <location filename="main.java" line="26"/> + <source>pack class method</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.java" line="31"/> + <source>QT_LAYOUT_DIRECTION</source> + <comment>Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.</comment> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location filename="main.java" line="33"/> + <source>%n files</source> + <comment>plural form</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message numerus="yes"> + <location filename="main.java" line="34"/> + <source>%n cars</source> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> + <message> + <location filename="main.java" line="35"/> + <source>Age: %1</source> + <translation type="unfinished"></translation> + </message> + <message numerus="yes"> + <location filename="main.java" line="36"/> + <source>There are %n house(s)</source> + <comment>Plurals and function call</comment> + <translation type="unfinished"> + <numerusform></numerusform> + </translation> + </message> +</context> +<context> + <name>com.trolltech.examples.I18N$MainWindow</name> + <message> + <location filename="main.java" line="9"/> + <source>pack class class</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.java" line="12"/> + <source>pack class class extra</source> + <extracomment>extra comment for t-tor</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.java" line="18"/> + <source>pack class class method</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/parseui/project.pro b/tests/auto/linguist/lupdate/testdata/good/parseui/project.pro new file mode 100644 index 0000000..bdc06e7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseui/project.pro @@ -0,0 +1,13 @@ +TEMPLATE = app +LANGUAGE = C++ + +FORMS += project.ui + +TRANSLATIONS = project.ts + +exists( $$TRANSLATIONS ) { + win32 : system(del $$TRANSLATIONS) + unix : system(rm $$TRANSLATIONS) +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result new file mode 100644 index 0000000..ddf58c3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <location filename="project.ui" line="27"/> + <source>Qt Assistant - Finn text</source> + <translation type="unfinished"></translation> + </message> + <message utf8="true"> + <location filename="project.ui" line="30"/> + <source>Finn tekst - Der Bjørn möchte auch mal.</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ui b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ui new file mode 100644 index 0000000..19fcaf5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ui @@ -0,0 +1,44 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>FindDialog</class> + <widget class="QWidget" name="FindDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>172</height> + </rect> + </property> + <property name="windowTitle" > + <string>Qt Assistant - Finn text</string> + </property> + <property name="height" > + <string>Finn tekst - Der Bjørn möchte auch mal.</string> + </property> + </widget> + <tabstops> + <tabstop>comboFind</tabstop> + <tabstop>checkWords</tabstop> + <tabstop>checkCase</tabstop> + <tabstop>radioForward</tabstop> + <tabstop>radioBackward</tabstop> + <tabstop>findButton</tabstop> + <tabstop>closeButton</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/linguist/lupdate/testdata/good/prefix/main.cpp b/tests/auto/linguist/lupdate/testdata/good/prefix/main.cpp new file mode 100644 index 0000000..d845853 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/prefix/main.cpp @@ -0,0 +1,17 @@ + + + +QString foo() +{ + QCoreApplication::translate("Foo","XXX","YYY"); +} + +Foo::Foo() +{ + tr("CTOR"); +} + +void Foo::bar() +{ + tr("BAR"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/prefix/project.pro b/tests/auto/linguist/lupdate/testdata/good/prefix/project.pro new file mode 100644 index 0000000..7547a8d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/prefix/project.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES = main.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result new file mode 100644 index 0000000..5ced00d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result @@ -0,0 +1,23 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>Foo</name> + <message> + <location filename="main.cpp" line="6"/> + <source>XXX</source> + <comment>YYY</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="11"/> + <source>CTOR</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="16"/> + <source>BAR</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/preprocess/main.cpp b/tests/auto/linguist/lupdate/testdata/good/preprocess/main.cpp new file mode 100644 index 0000000..9abfa5e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/preprocess/main.cpp @@ -0,0 +1,37 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "Platform-independent file"); +} + + + + +void func2() { +#ifdef Q_OS_WIN + QApplication::tr("Kind", "Windows only, see Type"); +#else + QApplication::tr("Type", "Not used on windows, see Kind"); +#endif + +} + + + +void stringconcatenation() +{ + QApplication::tr("One string," + " three" + " lines"); + + QApplication::tr("a backslash followed by newline \ +should be ignored \ +and the next line should be syntactically considered to be \ +on the same line"); + +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/preprocess/project.pro b/tests/auto/linguist/lupdate/testdata/good/preprocess/project.pro new file mode 100644 index 0000000..012c7e0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/preprocess/project.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm -f $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/preprocess/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/preprocess/project.ts.result new file mode 100644 index 0000000..3aec045 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/preprocess/project.ts.result @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QApplication</name> + <message> + <location filename="main.cpp" line="6"/> + <source>Hello world</source> + <comment>Platform-independent file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="14"/> + <source>Kind</source> + <comment>Windows only, see Type</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="16"/> + <source>Type</source> + <comment>Not used on windows, see Kind</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="25"/> + <source>One string, three lines</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="29"/> + <source>a backslash followed by newline should be ignored and the next line should be syntactically considered to be on the same line</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/main.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/main.cpp new file mode 100644 index 0000000..236bbe7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/main.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "Platform-independent file"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/main_mac.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/main_mac.cpp new file mode 100644 index 0000000..845aaa6 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/main_mac.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello macworld", "mac-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/main_unix.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/main_unix.cpp new file mode 100644 index 0000000..229e154 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/main_unix.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello unixworld", "unix-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/main_win.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/main_win.cpp new file mode 100644 index 0000000..4eb39f7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/main_win.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello windowsworld", "Windows-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/project.pro b/tests/auto/linguist/lupdate/testdata/good/proparsing/project.pro new file mode 100644 index 0000000..3078817 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/project.pro @@ -0,0 +1,40 @@ +TEMPLATE = app +LANGUAGE = C++ + +# Try to reference a variable that does not exist: +MYVAR=$$THIS_VARIABLE_IS_NOT_DEFINED + +SOURCES += main.cpp + +win32 { + SOURCES += main_win.cpp +} + +unix { + SOURCES += main_unix.cpp +} + +mac { + SOURCES += main_mac.cpp +} + +SOURCES += wildcard/main*.cpp \ +# yadiyada it should also parse the next line + wildcard*.cpp + + +DEPENDPATH = vpaths/dependpath + +# The purpose of this test is to test expansion of environment variables, +# and to test if the DEPENDPATH variable is considered correctly. +if (exists($$member($$(PATH), 0))) { + SOURCES += main_dependpath.cpp +} + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm -f $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/proparsing/project.ts.result new file mode 100644 index 0000000..ef98596 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/project.ts.result @@ -0,0 +1,64 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QApplication</name> + <message> + <location filename="main.cpp" line="6"/> + <source>Hello world</source> + <comment>Platform-independent file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main_mac.cpp" line="6"/> + <source>Hello macworld</source> + <comment>mac-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main_unix.cpp" line="6"/> + <source>Hello unixworld</source> + <comment>unix-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main_win.cpp" line="6"/> + <source>Hello windowsworld</source> + <comment>Windows-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="wildcard/main1.cpp" line="6"/> + <source>Hello world</source> + <comment>wildcard/main1.cpp</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="wildcard/mainfile.cpp" line="6"/> + <source>Hello world</source> + <comment>wildcard/main2.cpp</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="wildcard1.cpp" line="6"/> + <source>Hello world</source> + <comment>wildcard1.cpp</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="wildcard99.cpp" line="6"/> + <source>Hello world</source> + <comment>wildcard99.cpp</comment> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>QCoreApplication</name> + <message> + <location filename="vpaths/dependpath/main_dependpath.cpp" line="7"/> + <source>Hello from a DEPENDPATH</source> + <comment>See if the DEPENDPATH thing works</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/vpaths/dependpath/main_dependpath.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/vpaths/dependpath/main_dependpath.cpp new file mode 100644 index 0000000..f019c79 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/vpaths/dependpath/main_dependpath.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +int main(int argc, char **argv) +{ + QCoreApplication::tr("Hello from a DEPENDPATH", "See if the DEPENDPATH thing works"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/main1.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/main1.cpp new file mode 100644 index 0000000..506ae42 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/main1.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "wildcard/main1.cpp"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/mainfile.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/mainfile.cpp new file mode 100644 index 0000000..f4cd00a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/mainfile.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "wildcard/main2.cpp"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard1.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard1.cpp new file mode 100644 index 0000000..c7790c5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard1.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "wildcard1.cpp"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard99.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard99.cpp new file mode 100644 index 0000000..93febda --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard99.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "wildcard99.cpp"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/a b/tests/auto/linguist/lupdate/testdata/good/proparsing2/a new file mode 100644 index 0000000..5966392 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/a @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("a"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/a.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing2/a.cpp new file mode 100644 index 0000000..1d80ed3 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/a.cpp @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("a.cpp"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/b b/tests/auto/linguist/lupdate/testdata/good/proparsing2/b new file mode 100644 index 0000000..d0fe066 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/b @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("b"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/b.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing2/b.cpp new file mode 100644 index 0000000..a5c386d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/b.cpp @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("b.cpp"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/e b/tests/auto/linguist/lupdate/testdata/good/proparsing2/e new file mode 100644 index 0000000..66e89a8 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/e @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("e"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/f/g.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsing2/f/g.cpp new file mode 100644 index 0000000..d86bee2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/f/g.cpp @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("f/g.cpp"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/files-cc.txt b/tests/auto/linguist/lupdate/testdata/good/proparsing2/files-cc.txt new file mode 100644 index 0000000..5bd8d03 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/files-cc.txt @@ -0,0 +1 @@ +a.cpp b.cpp diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/project.pro b/tests/auto/linguist/lupdate/testdata/good/proparsing2/project.pro new file mode 100644 index 0000000..1d6895a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/project.pro @@ -0,0 +1,42 @@ +# This is to test if quoted elements with spaces are treated as elements (and not splitted up due +# to the spaces.) +# It also tries to verify the behaviour of combining quoted and non-quoted elements with literals. +# + +TEMPLATE = app +LANGUAGE = C++ + +QUOTED = $$quote(variable with spaces) +VERSIONAB = "a.b" +VAB = $$split(VERSIONAB, ".") +V += $$VAB +V += $$QUOTED + +# this is just to make p4 happy with no spaces in filename +SOURCES += $$member(V,0,1) +V2 = $$member(V,2) +V2S = $$split(V2, " ") +SOURCES += $$join(V2S,"_") +message($$SOURCES) +# SOURCES += [a, b, variable_with_spaces] + +LIST = d e f +L2 = x/$$LIST/g.cpp +SOURCES += $$L2 +# SOURCES += [x/d, e, f/g.cpp] + +QUOTEDEXTRA = x/$$QUOTED/z +Q3 = $$split(QUOTEDEXTRA, " ") +SOURCES += $$Q3 +# SOURCES += [x/variable, with, spaces/z] + +win32: SOURCES += $$system(type files-cc.txt) +unix: SOURCES += $$system(cat files-cc.txt) + +TRANSLATIONS += project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/proparsing2/project.ts.result new file mode 100644 index 0000000..2e60696 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/project.ts.result @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QLineEdit</name> + <message> + <location filename="a" line="3"/> + <source>a</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="a.cpp" line="3"/> + <source>a.cpp</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="b" line="3"/> + <source>b</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="b.cpp" line="3"/> + <source>b.cpp</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="e" line="3"/> + <source>e</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="f/g.cpp" line="3"/> + <source>f/g.cpp</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="spaces/z" line="3"/> + <source>spaces/z</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="variable_with_spaces" line="3"/> + <source>variable with spaces</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="with" line="3"/> + <source>with</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="x/d" line="3"/> + <source>x/d</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="x/variable" line="3"/> + <source>x/variable</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/spaces/z b/tests/auto/linguist/lupdate/testdata/good/proparsing2/spaces/z new file mode 100644 index 0000000..34364d6 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/spaces/z @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("spaces/z"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/variable_with_spaces b/tests/auto/linguist/lupdate/testdata/good/proparsing2/variable_with_spaces new file mode 100644 index 0000000..cf56fc4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/variable_with_spaces @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("variable with spaces"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/with b/tests/auto/linguist/lupdate/testdata/good/proparsing2/with new file mode 100644 index 0000000..a156ca1 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/with @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("with"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/x/d b/tests/auto/linguist/lupdate/testdata/good/proparsing2/x/d new file mode 100644 index 0000000..e2effde --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/x/d @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("x/d"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsing2/x/variable b/tests/auto/linguist/lupdate/testdata/good/proparsing2/x/variable new file mode 100644 index 0000000..a86e387 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsing2/x/variable @@ -0,0 +1,4 @@ +QString func() +{ + return QLineEdit::tr("x/variable"); +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/common.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/common.pri new file mode 100644 index 0000000..ba3169d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/common.pri @@ -0,0 +1 @@ +include(main.pri) diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.cpp new file mode 100644 index 0000000..236bbe7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "Platform-independent file"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.pri new file mode 100644 index 0000000..a8d4a2b --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.pri @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += $$PWD/main.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/mac.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/mac.pri new file mode 100644 index 0000000..549eab5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/mac.pri @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += $$PWD/main_mac.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/main_mac.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/main_mac.cpp new file mode 100644 index 0000000..845aaa6 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/main_mac.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello macworld", "mac-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.pro new file mode 100644 index 0000000..3810a02 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.pro @@ -0,0 +1,16 @@ +TEMPLATE = app +LANGUAGE = C++ + +include(win/win.pri) +include(mac/mac.pri) +include(unix/unix.pri) +include (common/common.pri) # Important: keep the space before the '(' +include(relativity/relativity.pri) + +message($$SOURCES) +TRANSLATIONS = project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm $$TRANSLATIONS) +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.ts.result new file mode 100644 index 0000000..c64ba82 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.ts.result @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QApplication</name> + <message> + <location filename="common/main.cpp" line="6"/> + <source>Hello world</source> + <comment>Platform-independent file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="mac/main_mac.cpp" line="6"/> + <source>Hello macworld</source> + <comment>mac-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="relativity/relativity.cpp" line="6"/> + <source>relativity.pri</source> + <comment>Platform-independent file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="unix/main_unix.cpp" line="6"/> + <source>Hello unixworld</source> + <comment>unix-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="win/main_win.cpp" line="6"/> + <source>Hello windowsworld</source> + <comment>Windows-only file</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.cpp new file mode 100644 index 0000000..83ae7d5 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("relativity.pri", "Platform-independent file"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.pri new file mode 100644 index 0000000..42658f0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.pri @@ -0,0 +1,3 @@ +# Lets test how well the proparser can walk the tree of includes... + +include(sub/sub.pri) diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub/sub.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub/sub.pri new file mode 100644 index 0000000..17055a7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub/sub.pri @@ -0,0 +1 @@ +include(../sub2/sub2.pri) diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub2/sub2.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub2/sub2.pri new file mode 100644 index 0000000..e2876b1 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub2/sub2.pri @@ -0,0 +1,2 @@ +SOURCES += $$PWD/../relativity.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/main_unix.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/main_unix.cpp new file mode 100644 index 0000000..229e154 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/main_unix.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello unixworld", "unix-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/unix.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/unix.pri new file mode 100644 index 0000000..99777d7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/unix.pri @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += $$PWD/main_unix.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/main_win.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/main_win.cpp new file mode 100644 index 0000000..4eb39f7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/main_win.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello windowsworld", "Windows-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/win.pri b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/win.pri new file mode 100644 index 0000000..742417c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/win.pri @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += $$PWD/main_win.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.pro new file mode 100644 index 0000000..4de6622 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.pro @@ -0,0 +1,3 @@ +TEMPLATE =subdirs + +SUBDIRS = sub1 diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.ts.result new file mode 100644 index 0000000..5914d0b --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.ts.result @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QApplication</name> + <message> + <location filename="sub1/main.cpp" line="6"/> + <source>Hello world</source> + <comment>Platform-independent file</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/main.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/main.cpp new file mode 100644 index 0000000..236bbe7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/main.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "Platform-independent file"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/sub1.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/sub1.pro new file mode 100644 index 0000000..1d50c2b --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/sub1.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp + +TRANSLATIONS += ../project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm -f $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/common.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/common.pro new file mode 100644 index 0000000..a8b3106 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/common.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/main.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/main.cpp new file mode 100644 index 0000000..236bbe7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/main.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world", "Platform-independent file"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/mac.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/mac.pro new file mode 100644 index 0000000..87478bf --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/mac.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main_mac.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/main_mac.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/main_mac.cpp new file mode 100644 index 0000000..845aaa6 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/main_mac.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello macworld", "mac-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro new file mode 100644 index 0000000..668ecf4 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro @@ -0,0 +1,7 @@ +TEMPLATE = subdirs +SUBDIRS = win mac unix common + +exists( project.ts ) { + win32: system(del project.ts) + unix: system(rm project.ts) +} diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.ts.result new file mode 100644 index 0000000..c0352fb --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.ts.result @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QApplication</name> + <message> + <location filename="win/main_win.cpp" line="6"/> + <source>Hello windowsworld</source> + <comment>Windows-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="mac/main_mac.cpp" line="6"/> + <source>Hello macworld</source> + <comment>mac-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="unix/main_unix.cpp" line="6"/> + <source>Hello unixworld</source> + <comment>unix-only file</comment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="common/main.cpp" line="6"/> + <source>Hello world</source> + <comment>Platform-independent file</comment> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/main_unix.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/main_unix.cpp new file mode 100644 index 0000000..229e154 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/main_unix.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello unixworld", "unix-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/unix.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/unix.pro new file mode 100644 index 0000000..d0ebec7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/unix.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main_unix.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/main_win.cpp b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/main_win.cpp new file mode 100644 index 0000000..4eb39f7 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/main_win.cpp @@ -0,0 +1,10 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello windowsworld", "Windows-only file"); +} + + + diff --git a/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/win.pro b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/win.pro new file mode 100644 index 0000000..a9a9751 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/win.pro @@ -0,0 +1,5 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main_win.cpp + diff --git a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.pro b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.pro new file mode 100644 index 0000000..28ba291 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.pro @@ -0,0 +1,14 @@ +TEMPLATE = app +LANGUAGE = C++ + +FORMS += project.ui + +TRANSLATIONS = project.ts + +# Copy the ts to a temp file because: +# 1. The depot file is usually read-only +# 2. We don't want to modify the original file, since then it won't be possible to run the test twice +# without reverting the original file again. + +win32: system(copy /Y project.ts.before $$TRANSLATIONS) +unix: system(cp -f project.ts.before $$TRANSLATIONS && chmod a+w $$TRANSLATIONS) diff --git a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.before b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.before new file mode 100644 index 0000000..f06c22c --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.before @@ -0,0 +1,16 @@ +<?xml version="1.0"?> +<!DOCTYPE TS><TS version="1.1"> +<context> + <name>FindDialog</name> + <message> + <location filename="project.ui" line="20"/> + <source>Test similarity</source> + <translation type="unfinished">Test likhet (test1)</translation> + </message> + <message> + <location filename="project.ui" line="23"/> + <source>Similarity should have kicked in here!</source> + <translation type="unfinished">Test likhet (test2)</translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result new file mode 100644 index 0000000..d65110a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <source>Test similarity</source> + <translation type="obsolete">Test likhet (test1)</translation> + </message> + <message> + <location filename="project.ui" line="20"/> + <source>This should not be considered to be more or less equal to the corresponding one in the ts file.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="project.ui" line="23"/> + <source>Here, similarity should kick in!</source> + <oldsource>Similarity should have kicked in here!</oldsource> + <translation type="unfinished">Test likhet (test2)</translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui new file mode 100644 index 0000000..0d0defd --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui @@ -0,0 +1,26 @@ +<ui version="4.0" > + <author></author> + <comment><!-- +********************************************************************* +** +** Do not change the location (linenumber) of the <string> elements in this file! +** That will make the test break! +** +** If you need to add some tests, please add them to the end of the file! +** +** +********************************************************************* +--> +</comment> + <exportmacro></exportmacro> + <class>FindDialog</class> + <widget class="QWidget" name="FindDialog" > + <property name="test1"> + <!-- If the sourcetext is not similar to the vernacular sourcetext, mark the old one as obsolete and the new one as unfinished --> + <string>This should not be considered to be more or less equal to the corresponding one in the ts file.</string> + </property> + <property name="test2"> + <string>Here, similarity should kick in!</string> + </property> + </widget> +</ui> diff --git a/tests/auto/linguist/lupdate/testdata/output_ts/lupdatecmd b/tests/auto/linguist/lupdate/testdata/output_ts/lupdatecmd new file mode 100644 index 0000000..80319de --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/output_ts/lupdatecmd @@ -0,0 +1,5 @@ +# Add the command that lupdate should run here. If it can't find anything it will default to +# 'lupdate project.pro -ts project.ts' + +# lupdate project.pro +lupdate toplevel/library/tools/tools.pro diff --git a/tests/auto/linguist/lupdate/testdata/output_ts/project.ts.result b/tests/auto/linguist/lupdate/testdata/output_ts/project.ts.result new file mode 100644 index 0000000..7fde820 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/output_ts/project.ts.result @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>QApplication</name> + <message> + <location filename="../main.cpp" line="6"/> + <source>Hello world</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/main.cpp b/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/main.cpp new file mode 100644 index 0000000..477f5ec --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/main.cpp @@ -0,0 +1,9 @@ +// 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!!! + + +void func1() { + QApplication::tr("Hello world"); +} + + diff --git a/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/tools.pro b/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/tools.pro new file mode 100644 index 0000000..ec6c01d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/tools.pro @@ -0,0 +1,12 @@ +TEMPLATE = app +LANGUAGE = C++ + +SOURCES += main.cpp + +TRANSLATIONS += translations/project.ts + +exists( $$TRANSLATIONS ) { + win32: system(del $$TRANSLATIONS) + unix: system(rm -f $$TRANSLATIONS) +} + diff --git a/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/translations/readme.txt b/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/translations/readme.txt new file mode 100644 index 0000000..83adcd2 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/translations/readme.txt @@ -0,0 +1,2 @@ +This is just a dummy file so that GIT creates this folder + diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result new file mode 100644 index 0000000..e132342 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <location filename="sub/finddialog.cpp" line="57"/> + <source>Enter the text you want to find.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="sub/finddialog.cpp" line="107"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="sub/finddialog.cpp" line="109"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="sub/finddialog.cpp" line="111"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result new file mode 100644 index 0000000..6646014 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result @@ -0,0 +1,115 @@ +<?xml version="1.0" encoding="utf-8"?> +<!DOCTYPE TS> +<TS version="2.0"> +<context> + <name>FindDialog</name> + <message> + <location filename="project.ui" line="27"/> + <source>Qt Assistant - Finn text</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="project.ui" line="30"/> + <source>Finn tekst</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="sub/finddialog.cpp" line="57"/> + <source>Enter the text you want to find.</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="sub/finddialog.cpp" line="107"/> + <source>Search reached end of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="sub/finddialog.cpp" line="109"/> + <source>Search reached start of the document</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="sub/finddialog.cpp" line="111"/> + <source>Text not found</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>QObject</name> + <message> + <location filename="main.cpp" line="12"/> + <source> +newline at the start</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="13"/> + <source>newline at the end +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="14"/> + <source>newline and space at the end + </source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="15"/> + <source>space and newline at the end +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="16"/> + <source> Tab at the start and newline at the end +</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="17"/> + <source> + newline and tab at the start</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="18"/> + <source> space and tab at the start</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="19"/> + <source> space_first</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="20"/> + <source>space_last </source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>text/c++</name> + <message> + <location filename="sub/filetypes/main.c++" line="6"/> + <source>test</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>text/cpp</name> + <message> + <location filename="sub/filetypes/main.cpp" line="6"/> + <source>test</source> + <translation type="unfinished"></translation> + </message> +</context> +<context> + <name>text/cxx</name> + <message> + <location filename="sub/filetypes/main.cxx" line="6"/> + <source>test</source> + <translation type="unfinished"></translation> + </message> +</context> +</TS> diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/main.cpp b/tests/auto/linguist/lupdate/testdata/recursivescan/main.cpp new file mode 100644 index 0000000..905cccd --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/main.cpp @@ -0,0 +1,22 @@ +#include <QApplication> +#include <QDebug> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QTranslator translator; + translator.load("whitespace"); + app.installTranslator(&translator); + + QObject::tr("\nnewline at the start"); + QObject::tr("newline at the end\n"); + QObject::tr("newline and space at the end\n "); + QObject::tr("space and newline at the end \n"); + QObject::tr("\tTab at the start and newline at the end\n"); + QObject::tr("\n\tnewline and tab at the start"); + QObject::tr(" \tspace and tab at the start"); + QObject::tr(" space_first"); + QObject::tr("space_last "); + return app.exec(); +} diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui b/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui new file mode 100644 index 0000000..e03a66e --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui @@ -0,0 +1,44 @@ +<ui version="4.0" > + <author></author> + <comment>********************************************************************* +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +*********************************************************************</comment> + <exportmacro></exportmacro> + <class>FindDialog</class> + <widget class="QWidget" name="FindDialog" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>400</width> + <height>172</height> + </rect> + </property> + <property name="windowTitle" > + <string>Qt Assistant - Finn text</string> + </property> + <property name="height" > + <string>Finn tekst</string> + </property> + </widget> + <tabstops> + <tabstop>comboFind</tabstop> + <tabstop>checkWords</tabstop> + <tabstop>checkCase</tabstop> + <tabstop>radioForward</tabstop> + <tabstop>radioBackward</tabstop> + <tabstop>findButton</tabstop> + <tabstop>closeButton</tabstop> + </tabstops> + <resources/> + <connections/> +</ui> diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.c++ b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.c++ new file mode 100644 index 0000000..4da3ded --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.c++ @@ -0,0 +1,8 @@ +#include <QApplication> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QApplication::translate("text/c++", "test"); + return app.exec(); +} diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cpp b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cpp new file mode 100644 index 0000000..9b3207d --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cpp @@ -0,0 +1,8 @@ +#include <QApplication> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QApplication::translate("text/cpp", "test"); + return app.exec(); +} diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cxx b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cxx new file mode 100644 index 0000000..b741ff0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cxx @@ -0,0 +1,8 @@ +#include <QApplication> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + QApplication::translate("text/cxx", "test"); + return app.exec(); +} diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp new file mode 100644 index 0000000..8e92a2a --- /dev/null +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** Copyright (C) 1992-$THISYEAR$ Trolltech AS. All rights reserved. +** +** This file is part of the $MODULE$ of the Qt Toolkit. +** +** $LICENSE$ +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +****************************************************************************/ + +#include "finddialog.h" +#include "mainwindow.h" +#include "tabbedbrowser.h" +#include "helpwindow.h" + +#include <QTextBrowser> +#include <QTextCursor> +#include <QStatusBar> +#include <QLineEdit> +#include <QDateTime> +#include <QGridLayout> + +CaseSensitiveModel::CaseSensitiveModel(int rows, int columns, QObject *parent) + : QStandardItemModel(rows, columns, parent) +{} +QModelIndexList CaseSensitiveModel::match(const QModelIndex &start, int role, const QVariant &value, + int hits, Qt::MatchFlags flags) const +{ + if (flags == Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) + flags |= Qt::MatchCaseSensitive; + + return QStandardItemModel::match(start, role, value, hits, flags); +} + +FindDialog::FindDialog(MainWindow *parent) + : QDialog(parent) +{ + contentsWidget = new QWidget(this); + ui.setupUi(contentsWidget); + ui.comboFind->setModel(new CaseSensitiveModel(0, 1, ui.comboFind)); + + QVBoxLayout *l = new QVBoxLayout(this); + l->setMargin(0); + l->setSpacing(0); + l->addWidget(contentsWidget); + + lastBrowser = 0; + onceFound = false; + findExpr.clear(); + + sb = new QStatusBar(this); + l->addWidget(sb); + + sb->showMessage(tr("Enter the text you want to find.")); + + connect(ui.findButton, SIGNAL(clicked()), this, SLOT(findButtonClicked())); + connect(ui.closeButton, SIGNAL(clicked()), this, SLOT(reject())); +} + +FindDialog::~FindDialog() +{ +} + +void FindDialog::findButtonClicked() +{ + doFind(ui.radioForward->isChecked()); +} + +void FindDialog::doFind(bool forward) +{ + QTextBrowser *browser = static_cast<QTextBrowser*>(mainWindow()->browsers()->currentBrowser()); + sb->clearMessage(); + + if (ui.comboFind->currentText() != findExpr || lastBrowser != browser) + onceFound = false; + findExpr = ui.comboFind->currentText(); + + QTextDocument::FindFlags flags = 0; + + if (ui.checkCase->isChecked()) + flags |= QTextDocument::FindCaseSensitively; + + if (ui.checkWords->isChecked()) + flags |= QTextDocument::FindWholeWords; + + QTextCursor c = browser->textCursor(); + if (!c.hasSelection()) { + if (forward) + c.movePosition(QTextCursor::Start); + else + c.movePosition(QTextCursor::End); + + browser->setTextCursor(c); + } + + QTextDocument::FindFlags options; + if (forward == false) + flags |= QTextDocument::FindBackward; + + QTextCursor found = browser->document()->find(findExpr, c, flags); + if (found.isNull()) { + if (onceFound) { + if (forward) + statusMessage(tr("Search reached end of the document")); + else + statusMessage(tr("Search reached start of the document")); + } else { + statusMessage(tr( "Text not found" )); + } + } else { + browser->setTextCursor(found); + } + onceFound |= !found.isNull(); + lastBrowser = browser; +} + +bool FindDialog::hasFindExpression() const +{ + return !findExpr.isEmpty(); +} + +void FindDialog::statusMessage(const QString &message) +{ + if (isVisible()) + sb->showMessage(message); + else + static_cast<MainWindow*>(parent())->statusBar()->showMessage(message, 2000); +} + +MainWindow *FindDialog::mainWindow() const +{ + return static_cast<MainWindow*>(parentWidget()); +} + +void FindDialog::reset() +{ + ui.comboFind->setFocus(); + ui.comboFind->lineEdit()->setSelection( + 0, ui.comboFind->lineEdit()->text().length()); +} diff --git a/tests/auto/linguist/lupdate/testlupdate.cpp b/tests/auto/linguist/lupdate/testlupdate.cpp new file mode 100644 index 0000000..8abc2b0 --- /dev/null +++ b/tests/auto/linguist/lupdate/testlupdate.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "testlupdate.h" +#include <stdlib.h> +#include <QtGui/QApplication> +#include <QtCore/QProcess> +#include <QtCore/QTimer> +#include <QtCore/QDir> + +#ifdef Q_OS_WIN32 +# include <windows.h> +#endif + +#include <QtTest/QtTest> + + +TestLUpdate::TestLUpdate() +{ + childProc = 0; + m_cmdLupdate = QLatin1String("lupdate"); + m_cmdQMake = QLatin1String("qmake"); +} + +TestLUpdate::~TestLUpdate() +{ + if (childProc) + delete childProc; +} + +void TestLUpdate::setWorkingDirectory(const QString &workDir) +{ + m_workDir = workDir; + QDir::setCurrent(m_workDir); +} + +void TestLUpdate::addMakeResult( const QString &result ) +{ + make_result.append( result ); +} + +bool TestLUpdate::runChild( bool showOutput, const QString &program, const QStringList &argList) +{ + make_result.clear(); + exit_ok = FALSE; + if (childProc) + delete childProc; + + child_show = showOutput; + if ( showOutput ) { + QString S = argList.join(" "); + addMakeResult( program + QLatin1String(" ") + S ); + } + + childProc = new QProcess(); + Q_ASSERT(childProc); + + childProc->setWorkingDirectory(m_workDir); + connect(childProc, SIGNAL(finished(int)), this, SLOT(childReady(int))); + childProc->setProcessChannelMode(QProcess::MergedChannels); + if (argList.isEmpty()) { + childProc->start( program ); + } else { + childProc->start( program, argList ); + } + bool ok; + + ok = childProc->waitForStarted(); + + if (ok) + ok = childProc->waitForFinished(); + + if (!ok) + addMakeResult( "Error executing '" + program + "'." ); + + childReady(ok ? 0 : -1); + + return ok; +} + +void TestLUpdate::childReady(int /*exitCode*/) +{ + if (childProc != 0) { + childHasData(); + exit_ok = childProc->state() == QProcess::NotRunning + && childProc->exitStatus() == 0; + childProc->deleteLater(); + } + childProc = 0; +} + +void TestLUpdate::childHasData() +{ + //QByteArray ba = childProc->readAllStandardError(); + //qDebug() << "ERROR:" << ba; + QString stdoutput = childProc->readAllStandardOutput(); + stdoutput = stdoutput.replace("\t", " "); + if (child_show) + addMakeResult(stdoutput); +} + +bool TestLUpdate::run(const QString &commandline) +{ + return runChild(true, m_cmdLupdate + QLatin1String(" ") + commandline); +} + + +bool TestLUpdate::updateProFile(const QString &arguments) +{ + QStringList args = arguments.split(QChar(' ')); + return runChild( true, m_cmdLupdate, args ); +} + +bool TestLUpdate::qmake() +{ + QStringList args; + args << "-r"; + return runChild(true, m_cmdQMake, args); +} diff --git a/tests/auto/linguist/lupdate/testlupdate.h b/tests/auto/linguist/lupdate/testlupdate.h new file mode 100644 index 0000000..efe9d85 --- /dev/null +++ b/tests/auto/linguist/lupdate/testlupdate.h @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef TESTLUPDATE_H +#define TESTLUPDATE_H + +#include <QObject> +#include <QProcess> +#include <QStringList> + +class TestLUpdate : public QObject +{ + Q_OBJECT + +public: + TestLUpdate(); + virtual ~TestLUpdate(); + + void setWorkingDirectory( const QString &workDir); + bool run( const QString &commandline); + bool updateProFile( const QString &arguments); + bool qmake(); + QStringList getErrorMessages() { + return make_result; + } + void clearResult() { + make_result.clear(); + } +private: + QString m_cmdLupdate; + QString m_cmdQMake; + QString m_workDir; + QProcess *childProc; + QStringList env_list; + QStringList make_result; + + bool child_show; + bool qws_mode; + bool exit_ok; + + bool runChild( bool showOutput, const QString &program, const QStringList &argList = QStringList()); + void addMakeResult( const QString &result ); + void childHasData(); + +private slots: + void childReady(int exitCode); +}; + +#endif // TESTLUPDATE_H diff --git a/tests/auto/linguist/lupdate/tst_lupdate.cpp b/tests/auto/linguist/lupdate/tst_lupdate.cpp new file mode 100644 index 0000000..fcf8582 --- /dev/null +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -0,0 +1,318 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the Qt Linguist 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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://www.qtsoftware.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "testlupdate.h" +#if CHECK_SIMTEXTH +#include "../shared/simtexth.h" +#endif + +#include <QtCore/QDir> +#include <QtCore/QDebug> +#include <QtCore/QFile> +#include <QtCore/QByteArray> + +#include <QtTest/QtTest> + +class tst_lupdate : public QObject +{ + Q_OBJECT +public: + tst_lupdate() { m_basePath = QDir::currentPath() + QLatin1String("/testdata/"); } + +private slots: + void good_data(); + void good(); + void output_ts(); + void commandline_data(); + void commandline(); +#if CHECK_SIMTEXTH + void simtexth(); + void simtexth_data(); +#endif + +private: + TestLUpdate m_lupdate; + QString m_basePath; + + void doCompare(const QStringList &actual, const QString &expectedFn, bool err); + void doCompare(const QString &actualFn, const QString &expectedFn, bool err); +}; + + +void tst_lupdate::doCompare(const QStringList &actual, const QString &expectedFn, bool err) +{ + QFile file(expectedFn); + QVERIFY(file.open(QIODevice::ReadOnly)); + QStringList expected = QString(file.readAll()).trimmed().remove('\r').split('\n'); + + int i = 0, ei = expected.size(), gi = actual.size(); + for (; ; i++) { + if (i == gi) { + if (i == ei) + return; + gi = 0; + break; + } else if (i == ei) { + ei = 0; + break; + } else if (err ? !QRegExp(expected.at(i)).exactMatch(actual.at(i)) : + (actual.at(i) != expected.at(i))) { + while ((ei - 1) >= i && (gi - 1) >= i && + (err ? QRegExp(expected.at(ei - 1)).exactMatch(actual.at(gi - 1)) : + (actual.at(gi - 1) == expected.at(ei - 1)))) + ei--, gi--; + break; + } + } + QByteArray diff; + for (int j = qMax(0, i - 3); j < i; j++) + diff += expected.at(j) + '\n'; + diff += "<<<<<<< got\n"; + for (int j = i; j < gi; j++) { + diff += actual.at(j) + '\n'; + if (j >= i + 5) { + diff += "...\n"; + break; + } + } + diff += "=========\n"; + for (int j = i; j < ei; j++) { + diff += expected.at(j) + '\n'; + if (j >= i + 5) { + diff += "...\n"; + break; + } + } + diff += ">>>>>>> expected\n"; + for (int j = ei; j < qMin(ei + 3, expected.size()); j++) + diff += expected.at(j) + '\n'; + QFAIL(qPrintable((err ? "Output for " : "Result for ") + expectedFn + " does not meet expectations:\n" + diff)); +} + +void tst_lupdate::doCompare(const QString &actualFn, const QString &expectedFn, bool err) +{ + QFile afile(actualFn); + QVERIFY(afile.open(QIODevice::ReadOnly)); + QStringList actual = QString(afile.readAll()).trimmed().remove('\r').split('\n'); + + doCompare(actual, expectedFn, err); +} + +void tst_lupdate::good_data() +{ + QTest::addColumn<QString>("directory"); + + QDir parsingDir(m_basePath + "good"); + QStringList dirs = parsingDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot, QDir::Name); + +#ifndef Q_OS_WIN + dirs.removeAll(QLatin1String("backslashes")); +#endif + + foreach (const QString &dir, dirs) + QTest::newRow(dir.toLocal8Bit()) << dir; +} + +void tst_lupdate::good() +{ + QFETCH(QString, directory); + + QString dir = m_basePath + "good/" + directory; + QString expectedFile = dir + QLatin1String("/project.ts.result"); + + qDebug() << "Checking..."; + + // qmake will delete the previous one, to ensure that we don't do any merging.... + QString generatedtsfile(QLatin1String("project.ts")); + + m_lupdate.setWorkingDirectory(dir); + m_lupdate.qmake(); + // look for a command + QString lupdatecmd; + QFile file(dir + "/lupdatecmd"); + if (file.exists()) { + QVERIFY(file.open(QIODevice::ReadOnly)); + while (!file.atEnd()) { + QByteArray cmdstring = file.readLine().simplified(); + if (cmdstring.startsWith('#')) + continue; + if (cmdstring.startsWith("lupdate")) { + cmdstring.remove(0, 8); + lupdatecmd.append(cmdstring); + break; + } else if (cmdstring.startsWith("TRANSLATION:")) { + cmdstring.remove(0, 12); + generatedtsfile = dir + QLatin1Char('/') + cmdstring.trimmed(); + } + } + file.close(); + } + + if (lupdatecmd.isEmpty()) { + lupdatecmd = QLatin1String("project.pro -ts project.ts"); + } + lupdatecmd.prepend("-silent "); + m_lupdate.updateProFile(lupdatecmd); + + // If the file expectedoutput.txt exists, compare the + // console output with the content of that file + QFile outfile(dir + "/expectedoutput.txt"); + if (outfile.exists()) { + QString errs = m_lupdate.getErrorMessages().at(1).trimmed(); + QStringList errslist = errs.split(QLatin1Char('\n')); + doCompare(errslist, outfile.fileName(), true); + if (QTest::currentTestFailed()) + return; + } + + doCompare(generatedtsfile, expectedFile, false); +} + +void tst_lupdate::output_ts() +{ + QString dir = m_basePath + "output_ts"; + m_lupdate.setWorkingDirectory(dir); + + // look for a command + QString lupdatecmd; + QFile file(dir + "/lupdatecmd"); + if (file.exists()) { + QVERIFY(file.open(QIODevice::ReadOnly)); + while (!file.atEnd()) { + QByteArray cmdstring = file.readLine().simplified(); + if (cmdstring.startsWith('#')) + continue; + if (cmdstring.startsWith("lupdate")) { + cmdstring.remove(0, 8); + lupdatecmd.append(cmdstring); + break; + } + } + file.close(); + } + + QDir parsingDir(m_basePath + "output_ts"); + + QString generatedtsfile = + dir + QLatin1String("/toplevel/library/tools/translations/project.ts"); + + QFile::remove(generatedtsfile); + + lupdatecmd.prepend("-silent "); + m_lupdate.qmake(); + m_lupdate.updateProFile(lupdatecmd); + + // If the file expectedoutput.txt exists, compare the + // console output with the content of that file + QFile outfile(dir + "/expectedoutput.txt"); + if (outfile.exists()) { + QString errs = m_lupdate.getErrorMessages().at(1).trimmed(); + QStringList errslist = errs.split(QLatin1Char('\n')); + doCompare(errslist, outfile.fileName(), true); + if (QTest::currentTestFailed()) + return; + } + + doCompare(generatedtsfile, dir + QLatin1String("/project.ts.result"), false); +} + +void tst_lupdate::commandline_data() +{ + QTest::addColumn<QString>("currentPath"); + QTest::addColumn<QString>("commandline"); + QTest::addColumn<QString>("generatedtsfile"); + QTest::addColumn<QString>("expectedtsfile"); + + QTest::newRow("Recursive scan") << QString("recursivescan") + << QString(". -ts foo.ts") << QString("foo.ts") << QString("foo.ts.result"); + QTest::newRow("Deep path argument") << QString("recursivescan") + << QString("sub/finddialog.cpp -ts bar.ts") << QString("bar.ts") << QString("bar.ts.result"); +} + +void tst_lupdate::commandline() +{ + QFETCH(QString, currentPath); + QFETCH(QString, commandline); + QFETCH(QString, generatedtsfile); + QFETCH(QString, expectedtsfile); + + m_lupdate.setWorkingDirectory(m_basePath + currentPath); + QString generated = + m_basePath + currentPath + QLatin1Char('/') + generatedtsfile; + QFile gen(generated); + if (gen.exists()) + QVERIFY(gen.remove()); + if (!m_lupdate.run("-silent " + commandline)) + qDebug() << m_lupdate.getErrorMessages().last(); + + doCompare(generated, m_basePath + currentPath + QLatin1Char('/') + expectedtsfile, false); +} + +#if CHECK_SIMTEXTH +void tst_lupdate::simtexth() +{ + QFETCH(QString, one); + QFETCH(QString, two); + QFETCH(int, expected); + + int measured = getSimilarityScore(one, two.toLatin1()); + QCOMPARE(measured, expected); +} + + +void tst_lupdate::simtexth_data() +{ + using namespace QTest; + + addColumn<QString>("one"); + addColumn<QString>("two"); + addColumn<int>("expected"); + + newRow("00") << "" << "" << 1024; + newRow("01") << "a" << "a" << 1024; + newRow("02") << "ab" << "ab" << 1024; + newRow("03") << "abc" << "abc" << 1024; + newRow("04") << "abcd" << "abcd" << 1024; +} +#endif + +QTEST_MAIN(tst_lupdate) +#include "tst_lupdate.moc" |