From 4be64775a5b3964e611e7fdb334edd33b1ef6b9b Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 30 Jun 2009 13:12:12 +0200 Subject: fix crash in QLocalServer on WinCE when waitForNewConnection times out Reviewed-by: mauricek --- src/network/socket/qlocalserver_tcp.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/network/socket/qlocalserver_tcp.cpp b/src/network/socket/qlocalserver_tcp.cpp index b248f2f..bcf822e 100644 --- a/src/network/socket/qlocalserver_tcp.cpp +++ b/src/network/socket/qlocalserver_tcp.cpp @@ -92,7 +92,7 @@ void QLocalServerPrivate::waitForNewConnection(int msec, bool *timedOut) { if (pendingConnections.isEmpty()) tcpServer.waitForNewConnection(msec, timedOut); - else + else if (timedOut) *timedOut = false; } -- cgit v0.12 From 1fc1eafc9bc5e8e7e69c04b9fac93d45a74ebfbf Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 30 Jun 2009 14:37:16 +0200 Subject: Doc: About menu on the Mac gets the application name from Info.plist. Task-number: 256818 Reviewed-by: Trenton Schulz --- src/gui/kernel/qaction.cpp | 4 +++- src/gui/widgets/qmenubar.cpp | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index a7f458f..26baad5 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -249,7 +249,9 @@ void QActionPrivate::setShortcutEnabled(bool enable, QShortcutMap &map) as described in the QMenuBar documentation. \value ApplicationSpecificRole This action should be put in the application menu with an application specific role \value AboutQtRole This action matches handles the "About Qt" menu item. - \value AboutRole This action should be placed where the "About" menu item is in the application menu. + \value AboutRole This action should be placed where the "About" menu item is in the application menu. The text of + the menu item will be set to "About ". The application name is fetched from the + \c{Info.plist} file in the application's bundle (See \l{Deploying an Application on Mac OS X}). \value PreferencesRole This action should be placed where the "Preferences..." menu item is in the application menu. \value QuitRole This action should be placed where the Quit menu item is in the application menu. */ diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index f58ea50..741916a 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -661,8 +661,9 @@ void QMenuBar::initStyleOption(QStyleOptionMenuItem *option, const QAction *acti \header \i String matches \i Placement \i Notes \row \i about.* \i Application Menu | About - \i If this entry is not found no About item will appear in - the Application Menu + \i The application name is fetched from the \c {Info.plist} file + (see note below). If this entry is not found no About item + will appear in the Application Menu. \row \i config, options, setup, settings or preferences \i Application Menu | Preferences \i If this entry is not found the Settings item will be disabled -- cgit v0.12 From 79ea2c5956f0200fc8754f82b83ca8433c11008a Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 30 Jun 2009 15:16:41 +0200 Subject: Doc: Fixed a doc bug in QPlainTextEdit class description. Task-number: 256762 Reviewed-by: TrustMe --- src/gui/widgets/qplaintextedit.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qplaintextedit.cpp b/src/gui/widgets/qplaintextedit.cpp index 465b377..7c077df 100644 --- a/src/gui/widgets/qplaintextedit.cpp +++ b/src/gui/widgets/qplaintextedit.cpp @@ -999,14 +999,13 @@ void QPlainTextEditPrivate::ensureViewportLayouted() QPlainText uses very much the same technology and concepts as QTextEdit, but is optimized for plain text handling. - QPlainTextEdit works on paragraphs and characters. A paragraph is a - formatted string which is word-wrapped to fit into the width of + QPlainTextEdit works on paragraphs and characters. A paragraph is + a formatted string which is word-wrapped to fit into the width of the widget. By default when reading plain text, one newline signifies a paragraph. A document consists of zero or more - paragraphs. The words in the paragraph are aligned in accordance - with the paragraph's alignment. Paragraphs are separated by hard - line breaks. Each character within a paragraph has its own - attributes, for example, font and color. + paragraphs. Paragraphs are separated by hard line breaks. Each + character within a paragraph has its own attributes, for example, + font and color. The shape of the mouse cursor on a QPlainTextEdit is Qt::IBeamCursor by default. It can be changed through the @@ -1148,7 +1147,8 @@ void QPlainTextEditPrivate::ensureViewportLayouted() \sa QTextDocument, QTextCursor, {Application Example}, - {Syntax Highlighter Example}, {Rich Text Processing} + {Code Editor Example}, {Syntax Highlighter Example}, + {Rich Text Processing} */ -- cgit v0.12 From 5d40eff80123b2739987fbf7fc720b0c6ad91226 Mon Sep 17 00:00:00 2001 From: Geir Vattekar Date: Tue, 30 Jun 2009 17:04:36 +0200 Subject: Doc: Said which formats we support for a QIODevice driven MediaSource Task-number: 253902 Reviewed-by: Thierry Bastian --- doc/src/phonon-api.qdoc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/src/phonon-api.qdoc b/doc/src/phonon-api.qdoc index 9d49c3f..66314de 100644 --- a/doc/src/phonon-api.qdoc +++ b/doc/src/phonon-api.qdoc @@ -1114,6 +1114,11 @@ \note Sequential devices can also be used, but MediaObject::isSeekable() will return false as a result. + \warning On Windows, we only support \l{QIODevice}s containing the + \c avi, \c mp3, or \c mpg formats. Use the constructor that takes + a file name to open files (the Qt backend does not use a QFile + internally). + \sa setAutoDelete() */ @@ -1863,7 +1868,7 @@ \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 14 - \sa currentSource() + \sa currentSource(), MediaSource */ /*! -- cgit v0.12 From 11ee32888b1b2370c70708e1385c26dc3a0a367c Mon Sep 17 00:00:00 2001 From: Norwegian Rock Cat Date: Tue, 30 Jun 2009 17:07:16 +0200 Subject: Fix Toolbars in unified toolbar looking bad Carbon w/Fullscreen changes There was a bug in the Carbon code when an item went in full-screen, than out with a unified toolbar. In those cases the toolbars would end up getting but into the mainwindow area. The reason this was happening was that we were calling transferChildren() after we had set up our toolbar. This cause problems because we end up pulling the QToolbars right out of the unified toolbar. The easiest way to solve this is to just update the status on it again. This should solve any issues. I also added some logic to avoid calling this too many times in that one case. Luckily, this seems to only affect Carbon. Task-number: 254462 Reviewed-by: Jens Bache-Wiig --- src/gui/kernel/qwidget_mac.mm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm index 1c71fbd..ec9a049 100644 --- a/src/gui/kernel/qwidget_mac.mm +++ b/src/gui/kernel/qwidget_mac.mm @@ -2730,10 +2730,15 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) createWinId(); if (q->isWindow()) { #ifndef QT_MAC_USE_COCOA - if (QMainWindowLayout *mwl = qobject_cast(q->layout())) { - mwl->updateHIToolBarStatus(); + // We do this down below for wasCreated, so avoid doing this twice + // (only for performance, it gets called a lot anyway). + if (!wasCreated) { + if (QMainWindowLayout *mwl = qobject_cast(q->layout())) { + mwl->updateHIToolBarStatus(); + } } #else + // Simply transfer our toolbar over. Everything should stay put, unlike in Carbon. if (oldToolbar && !(f & Qt::FramelessWindowHint)) { OSWindowRef newWindow = qt_mac_window_for(q); [newWindow setToolbar:oldToolbar]; @@ -2748,6 +2753,16 @@ void QWidgetPrivate::setParent_sys(QWidget *parent, Qt::WindowFlags f) if (wasCreated) { transferChildren(); +#ifndef QT_MAC_USE_COCOA + // If we were a unified window, We just transfered our toolbars out of the unified toolbar. + // So redo the status one more time. It apparently is not an issue with Cocoa. + if (q->isWindow()) { + if (QMainWindowLayout *mwl = qobject_cast(q->layout())) { + mwl->updateHIToolBarStatus(); + } + } +#endif + if (topData && (!topData->caption.isEmpty() || !topData->filePath.isEmpty())) setWindowTitle_helper(q->windowTitle()); -- cgit v0.12 From cd796aa6dcdf83fa50ced56a9885835fda851a09 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 30 Jun 2009 16:17:56 +0200 Subject: integrate linguist tool autotests into the qt testsuite Task-number: 218935 --- tests/auto/auto.pro | 1 + tests/auto/linguist/lconvert/data/codec-cp1252.ts | 28 ++ tests/auto/linguist/lconvert/data/codec-utf8.ts | 28 ++ tests/auto/linguist/lconvert/data/dual-encoding.ts | 11 + .../auto/linguist/lconvert/data/endless-po-loop.ts | 16 ++ tests/auto/linguist/lconvert/data/makeplurals.sh | 43 +++ tests/auto/linguist/lconvert/data/msgid.ts | 27 ++ tests/auto/linguist/lconvert/data/plurals-cn.ts | 17 ++ tests/auto/linguist/lconvert/data/plurals-de.ts | 18 ++ tests/auto/linguist/lconvert/data/relative.ts | 74 +++++ tests/auto/linguist/lconvert/data/singular.po | 42 +++ .../linguist/lconvert/data/test-broken-utf8.po | 9 + .../linguist/lconvert/data/test-broken-utf8.po.out | 9 + .../lconvert/data/test-developer-comment.po | 23 ++ .../linguist/lconvert/data/test-empty-comment.po | 24 ++ tests/auto/linguist/lconvert/data/test-escapes.po | 11 + .../linguist/lconvert/data/test-escapes.po.out | 13 + tests/auto/linguist/lconvert/data/test-kde-ctxt.po | 25 ++ .../auto/linguist/lconvert/data/test-kde-fuzzy.po | 31 +++ .../linguist/lconvert/data/test-kde-multiline.po | 32 +++ .../linguist/lconvert/data/test-kde-plurals.po | 27 ++ tests/auto/linguist/lconvert/data/test-slurp.po | 19 ++ .../auto/linguist/lconvert/data/test-slurp.po.out | 19 ++ .../lconvert/data/test-translator-comment.po | 41 +++ tests/auto/linguist/lconvert/data/test1-cn.po | 67 +++++ tests/auto/linguist/lconvert/data/test1-de.po | 75 ++++++ tests/auto/linguist/lconvert/data/test11.ts | 32 +++ tests/auto/linguist/lconvert/data/test20.ts | 150 +++++++++++ tests/auto/linguist/lconvert/data/variants.ts | 24 ++ tests/auto/linguist/lconvert/data/wrapping.po | 58 ++++ tests/auto/linguist/lconvert/lconvert.pro | 8 + tests/auto/linguist/lconvert/tst_lconvert.cpp | 300 +++++++++++++++++++++ tests/auto/linguist/linguist.pro | 2 + tests/auto/linguist/lrelease/lrelease.pro | 5 + .../auto/linguist/lrelease/testdata/compressed.ts | 46 ++++ tests/auto/linguist/lrelease/testdata/dupes.errors | 4 + tests/auto/linguist/lrelease/testdata/dupes.ts | 25 ++ .../linguist/lrelease/testdata/mixedcodecs-ts11.ts | 18 ++ .../linguist/lrelease/testdata/mixedcodecs-ts20.ts | 18 ++ tests/auto/linguist/lrelease/testdata/translate.ts | 136 ++++++++++ tests/auto/linguist/lrelease/tst_lrelease.cpp | 163 +++++++++++ tests/auto/linguist/lupdate/lupdate.pro | 7 + .../lupdate/testdata/good/backslashes/lupdatecmd | 3 + .../lupdate/testdata/good/backslashes/project.pro | 19 ++ .../testdata/good/backslashes/project.ts.result | 13 + .../lupdate/testdata/good/backslashes/src/main.cpp | 15 ++ .../lupdate/testdata/good/codecforsrc/main.cpp | 18 ++ .../lupdate/testdata/good/codecforsrc/project.pro | 20 ++ .../testdata/good/codecforsrc/project.ts.result | 20 ++ .../lupdate/testdata/good/codecfortr/main.cpp | 24 ++ .../lupdate/testdata/good/codecfortr/project.pro | 19 ++ .../testdata/good/codecfortr/project.ts.result | 13 + .../lupdate/testdata/good/codecfortr1/main.cpp | 20 ++ .../lupdate/testdata/good/codecfortr1/project.pro | 15 ++ .../testdata/good/codecfortr1/project.ts.result | 28 ++ .../lupdate/testdata/good/codecfortr2/main.cpp | 20 ++ .../lupdate/testdata/good/codecfortr2/project.pro | 16 ++ .../testdata/good/codecfortr2/project.ts.result | 28 ++ .../testdata/good/lacksqobject/expectedoutput.txt | 4 + .../lupdate/testdata/good/lacksqobject/main.cpp | 47 ++++ .../lupdate/testdata/good/lacksqobject/project.pro | 12 + .../testdata/good/lacksqobject/project.ts.result | 40 +++ .../lupdate/testdata/good/merge_ordering/foo.cpp | 28 ++ .../testdata/good/merge_ordering/lupdatecmd | 5 + .../testdata/good/merge_ordering/project.pro | 14 + .../testdata/good/merge_ordering/project.ts.before | 74 +++++ .../testdata/good/merge_ordering/project.ts.result | 82 ++++++ .../testdata/good/merge_versions/project.pro | 14 + .../testdata/good/merge_versions/project.ts.before | 14 + .../testdata/good/merge_versions/project.ts.result | 15 ++ .../testdata/good/merge_versions/project.ui | 44 +++ .../testdata/good/merge_whitespace/main.cpp | 23 ++ .../testdata/good/merge_whitespace/project.pro | 14 + .../good/merge_whitespace/project.ts.before | 70 +++++ .../good/merge_whitespace/project.ts.result | 71 +++++ .../lupdate/testdata/good/mergecpp/finddialog.cpp | 25 ++ .../lupdate/testdata/good/mergecpp/project.pro | 14 + .../testdata/good/mergecpp/project.ts.before | 48 ++++ .../testdata/good/mergecpp/project.ts.result | 49 ++++ .../good/mergecpp_noobsolete/finddialog.cpp | 123 +++++++++ .../testdata/good/mergecpp_noobsolete/lupdatecmd | 5 + .../testdata/good/mergecpp_noobsolete/project.pro | 14 + .../good/mergecpp_noobsolete/project.ts.before | 31 +++ .../good/mergecpp_noobsolete/project.ts.result | 27 ++ .../testdata/good/mergecpp_obsolete/finddialog.cpp | 146 ++++++++++ .../testdata/good/mergecpp_obsolete/project.pro | 14 + .../good/mergecpp_obsolete/project.ts.before | 26 ++ .../good/mergecpp_obsolete/project.ts.result | 31 +++ .../lupdate/testdata/good/mergeui/project.pro | 14 + .../testdata/good/mergeui/project.ts.before | 22 ++ .../testdata/good/mergeui/project.ts.result | 23 ++ .../lupdate/testdata/good/mergeui/project.ui | 47 ++++ .../testdata/good/mergeui_obsolete/project.pro | 14 + .../good/mergeui_obsolete/project.ts.before | 16 ++ .../good/mergeui_obsolete/project.ts.result | 22 ++ .../testdata/good/mergeui_obsolete/project.ui | 26 ++ .../good/multiple_locations/finddialog.cpp | 7 + .../testdata/good/multiple_locations/main.cpp | 13 + .../testdata/good/multiple_locations/project.pro | 13 + .../good/multiple_locations/project.ts.result | 17 ++ .../lupdate/testdata/good/namespaces/main.cpp | 97 +++++++ .../lupdate/testdata/good/namespaces/project.pro | 12 + .../testdata/good/namespaces/project.ts.result | 82 ++++++ .../testdata/good/parse_special_chars/main.cpp | 18 ++ .../testdata/good/parse_special_chars/project.pro | 12 + .../good/parse_special_chars/project.ts.result | 17 ++ .../lupdate/testdata/good/parsecontexts/main.cpp | 229 ++++++++++++++++ .../testdata/good/parsecontexts/project.pro | 12 + .../testdata/good/parsecontexts/project.ts.result | 192 +++++++++++++ .../lupdate/testdata/good/parsecpp/finddialog.cpp | 156 +++++++++++ .../lupdate/testdata/good/parsecpp/main.cpp | 158 +++++++++++ .../lupdate/testdata/good/parsecpp/project.pro | 13 + .../testdata/good/parsecpp/project.ts.result | 271 +++++++++++++++++++ .../lupdate/testdata/good/parsejava/main.java | 54 ++++ .../lupdate/testdata/good/parsejava/project.pro | 12 + .../testdata/good/parsejava/project.ts.result | 115 ++++++++ .../lupdate/testdata/good/parseui/project.pro | 13 + .../testdata/good/parseui/project.ts.result | 17 ++ .../lupdate/testdata/good/parseui/project.ui | 44 +++ .../linguist/lupdate/testdata/good/prefix/main.cpp | 17 ++ .../lupdate/testdata/good/prefix/project.pro | 12 + .../lupdate/testdata/good/prefix/project.ts.result | 23 ++ .../lupdate/testdata/good/preprocess/main.cpp | 37 +++ .../lupdate/testdata/good/preprocess/project.pro | 12 + .../testdata/good/preprocess/project.ts.result | 35 +++ .../lupdate/testdata/good/proparsing/main.cpp | 9 + .../lupdate/testdata/good/proparsing/main_mac.cpp | 10 + .../lupdate/testdata/good/proparsing/main_unix.cpp | 10 + .../lupdate/testdata/good/proparsing/main_win.cpp | 10 + .../lupdate/testdata/good/proparsing/project.pro | 40 +++ .../testdata/good/proparsing/project.ts.result | 64 +++++ .../vpaths/dependpath/main_dependpath.cpp | 10 + .../testdata/good/proparsing/wildcard/main1.cpp | 9 + .../testdata/good/proparsing/wildcard/mainfile.cpp | 9 + .../lupdate/testdata/good/proparsing/wildcard1.cpp | 9 + .../testdata/good/proparsing/wildcard99.cpp | 9 + .../linguist/lupdate/testdata/good/proparsing2/a | 4 + .../lupdate/testdata/good/proparsing2/a.cpp | 4 + .../linguist/lupdate/testdata/good/proparsing2/b | 4 + .../lupdate/testdata/good/proparsing2/b.cpp | 4 + .../linguist/lupdate/testdata/good/proparsing2/e | 4 + .../lupdate/testdata/good/proparsing2/f/g.cpp | 4 + .../lupdate/testdata/good/proparsing2/files-cc.txt | 1 + .../lupdate/testdata/good/proparsing2/project.pro | 42 +++ .../testdata/good/proparsing2/project.ts.result | 62 +++++ .../lupdate/testdata/good/proparsing2/spaces/z | 4 + .../testdata/good/proparsing2/variable_with_spaces | 4 + .../lupdate/testdata/good/proparsing2/with | 4 + .../linguist/lupdate/testdata/good/proparsing2/x/d | 4 + .../lupdate/testdata/good/proparsing2/x/variable | 4 + .../testdata/good/proparsingpri/common/common.pri | 1 + .../testdata/good/proparsingpri/common/main.cpp | 9 + .../testdata/good/proparsingpri/common/main.pri | 5 + .../testdata/good/proparsingpri/mac/mac.pri | 5 + .../testdata/good/proparsingpri/mac/main_mac.cpp | 10 + .../testdata/good/proparsingpri/project.pro | 16 ++ .../testdata/good/proparsingpri/project.ts.result | 37 +++ .../good/proparsingpri/relativity/relativity.cpp | 9 + .../good/proparsingpri/relativity/relativity.pri | 3 + .../good/proparsingpri/relativity/sub/sub.pri | 1 + .../good/proparsingpri/relativity/sub2/sub2.pri | 2 + .../testdata/good/proparsingpri/unix/main_unix.cpp | 10 + .../testdata/good/proparsingpri/unix/unix.pri | 5 + .../testdata/good/proparsingpri/win/main_win.cpp | 10 + .../testdata/good/proparsingpri/win/win.pri | 5 + .../testdata/good/proparsingsubdirs/project.pro | 3 + .../good/proparsingsubdirs/project.ts.result | 13 + .../testdata/good/proparsingsubdirs/sub1/main.cpp | 9 + .../testdata/good/proparsingsubdirs/sub1/sub1.pro | 12 + .../testdata/good/proparsingsubs/common/common.pro | 5 + .../testdata/good/proparsingsubs/common/main.cpp | 9 + .../testdata/good/proparsingsubs/mac/mac.pro | 5 + .../testdata/good/proparsingsubs/mac/main_mac.cpp | 10 + .../testdata/good/proparsingsubs/project.pro | 7 + .../testdata/good/proparsingsubs/project.ts.result | 31 +++ .../good/proparsingsubs/unix/main_unix.cpp | 10 + .../testdata/good/proparsingsubs/unix/unix.pro | 5 + .../testdata/good/proparsingsubs/win/main_win.cpp | 10 + .../testdata/good/proparsingsubs/win/win.pro | 5 + .../testdata/good/textsimilarity/project.pro | 14 + .../testdata/good/textsimilarity/project.ts.before | 16 ++ .../testdata/good/textsimilarity/project.ts.result | 22 ++ .../testdata/good/textsimilarity/project.ui | 26 ++ .../linguist/lupdate/testdata/output_ts/lupdatecmd | 5 + .../lupdate/testdata/output_ts/project.ts.result | 12 + .../output_ts/toplevel/library/tools/main.cpp | 9 + .../output_ts/toplevel/library/tools/tools.pro | 12 + .../toplevel/library/tools/translations/readme.txt | 2 + .../lupdate/testdata/recursivescan/bar.ts.result | 27 ++ .../lupdate/testdata/recursivescan/foo.ts.result | 115 ++++++++ .../lupdate/testdata/recursivescan/main.cpp | 22 ++ .../lupdate/testdata/recursivescan/project.ui | 44 +++ .../testdata/recursivescan/sub/filetypes/main.c++ | 8 + .../testdata/recursivescan/sub/filetypes/main.cpp | 8 + .../testdata/recursivescan/sub/filetypes/main.cxx | 8 + .../testdata/recursivescan/sub/finddialog.cpp | 143 ++++++++++ tests/auto/linguist/lupdate/testlupdate.cpp | 116 ++++++++ tests/auto/linguist/lupdate/testlupdate.h | 46 ++++ tests/auto/linguist/lupdate/tst_lupdate.cpp | 277 +++++++++++++++++++ tests/auto/tests.xml | 6 + 200 files changed, 6573 insertions(+) create mode 100644 tests/auto/linguist/lconvert/data/codec-cp1252.ts create mode 100644 tests/auto/linguist/lconvert/data/codec-utf8.ts create mode 100644 tests/auto/linguist/lconvert/data/dual-encoding.ts create mode 100644 tests/auto/linguist/lconvert/data/endless-po-loop.ts create mode 100755 tests/auto/linguist/lconvert/data/makeplurals.sh create mode 100644 tests/auto/linguist/lconvert/data/msgid.ts create mode 100644 tests/auto/linguist/lconvert/data/plurals-cn.ts create mode 100644 tests/auto/linguist/lconvert/data/plurals-de.ts create mode 100644 tests/auto/linguist/lconvert/data/relative.ts create mode 100644 tests/auto/linguist/lconvert/data/singular.po create mode 100644 tests/auto/linguist/lconvert/data/test-broken-utf8.po create mode 100644 tests/auto/linguist/lconvert/data/test-broken-utf8.po.out create mode 100644 tests/auto/linguist/lconvert/data/test-developer-comment.po create mode 100644 tests/auto/linguist/lconvert/data/test-empty-comment.po create mode 100644 tests/auto/linguist/lconvert/data/test-escapes.po create mode 100644 tests/auto/linguist/lconvert/data/test-escapes.po.out create mode 100644 tests/auto/linguist/lconvert/data/test-kde-ctxt.po create mode 100644 tests/auto/linguist/lconvert/data/test-kde-fuzzy.po create mode 100644 tests/auto/linguist/lconvert/data/test-kde-multiline.po create mode 100644 tests/auto/linguist/lconvert/data/test-kde-plurals.po create mode 100644 tests/auto/linguist/lconvert/data/test-slurp.po create mode 100644 tests/auto/linguist/lconvert/data/test-slurp.po.out create mode 100644 tests/auto/linguist/lconvert/data/test-translator-comment.po create mode 100644 tests/auto/linguist/lconvert/data/test1-cn.po create mode 100644 tests/auto/linguist/lconvert/data/test1-de.po create mode 100644 tests/auto/linguist/lconvert/data/test11.ts create mode 100644 tests/auto/linguist/lconvert/data/test20.ts create mode 100644 tests/auto/linguist/lconvert/data/variants.ts create mode 100644 tests/auto/linguist/lconvert/data/wrapping.po create mode 100644 tests/auto/linguist/lconvert/lconvert.pro create mode 100644 tests/auto/linguist/lconvert/tst_lconvert.cpp create mode 100644 tests/auto/linguist/linguist.pro create mode 100644 tests/auto/linguist/lrelease/lrelease.pro create mode 100644 tests/auto/linguist/lrelease/testdata/compressed.ts create mode 100644 tests/auto/linguist/lrelease/testdata/dupes.errors create mode 100644 tests/auto/linguist/lrelease/testdata/dupes.ts create mode 100644 tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts create mode 100644 tests/auto/linguist/lrelease/testdata/mixedcodecs-ts20.ts create mode 100644 tests/auto/linguist/lrelease/testdata/translate.ts create mode 100644 tests/auto/linguist/lrelease/tst_lrelease.cpp create mode 100644 tests/auto/linguist/lupdate/lupdate.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/backslashes/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/backslashes/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/backslashes/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/backslashes/src/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecforsrc/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecforsrc/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr1/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr1/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr2/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/codecfortr2/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/lacksqobject/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/lacksqobject/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_ordering/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_ordering/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_versions/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_versions/project.ui create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_whitespace/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/merge_whitespace/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp/finddialog.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/finddialog.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/finddialog.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/mergeui_obsolete/project.ui create mode 100644 tests/auto/linguist/lupdate/testdata/good/multiple_locations/finddialog.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/multiple_locations/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/namespaces/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/namespaces/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/parse_special_chars/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/parse_special_chars/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecontexts/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecontexts/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecpp/finddialog.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecpp/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsejava/main.java create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsejava/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/parsejava/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/parseui/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/parseui/project.ui create mode 100644 tests/auto/linguist/lupdate/testdata/good/prefix/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/prefix/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/preprocess/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/preprocess/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/preprocess/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/main_mac.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/main_unix.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/main_win.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/vpaths/dependpath/main_dependpath.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/main1.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard/mainfile.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard1.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing/wildcard99.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/a create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/a.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/b create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/b.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/e create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/f/g.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/files-cc.txt create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/spaces/z create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/variable_with_spaces create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/with create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/x/d create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsing2/x/variable create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/common.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/common/main.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/mac.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/mac/main_mac.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/relativity.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub/sub.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/relativity/sub2/sub2.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/main_unix.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/unix/unix.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/main_win.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingpri/win/win.pri create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubdirs/sub1/sub1.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/common.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/common/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/mac.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/mac/main_mac.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/main_unix.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/unix/unix.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/main_win.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/good/proparsingsubs/win/win.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.pro create mode 100644 tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.before create mode 100644 tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/good/textsimilarity/project.ui create mode 100644 tests/auto/linguist/lupdate/testdata/output_ts/lupdatecmd create mode 100644 tests/auto/linguist/lupdate/testdata/output_ts/project.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/tools.pro create mode 100644 tests/auto/linguist/lupdate/testdata/output_ts/toplevel/library/tools/translations/readme.txt create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/project.ui create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.c++ create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cpp create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/sub/filetypes/main.cxx create mode 100644 tests/auto/linguist/lupdate/testdata/recursivescan/sub/finddialog.cpp create mode 100644 tests/auto/linguist/lupdate/testlupdate.cpp create mode 100644 tests/auto/linguist/lupdate/testlupdate.h create mode 100644 tests/auto/linguist/lupdate/tst_lupdate.cpp diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index a215daa..fd887fd 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -10,6 +10,7 @@ SUBDIRS += _networkselftest \ compile \ compilerwarnings \ exceptionsafety \ + linguist \ macgui \ macplist \ mediaobject \ diff --git a/tests/auto/linguist/lconvert/data/codec-cp1252.ts b/tests/auto/linguist/lconvert/data/codec-cp1252.ts new file mode 100644 index 0000000..5ffa2f3 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/codec-cp1252.ts @@ -0,0 +1,28 @@ + + + +windows-1252 + + FooBar + + + random ascii only + + + + + this contains an umlaut ü &uuml; + + + + + random ascii only in utf8 + + + + + umlaut ü &uuml; in utf8 + + + + diff --git a/tests/auto/linguist/lconvert/data/codec-utf8.ts b/tests/auto/linguist/lconvert/data/codec-utf8.ts new file mode 100644 index 0000000..0ebdbfd --- /dev/null +++ b/tests/auto/linguist/lconvert/data/codec-utf8.ts @@ -0,0 +1,28 @@ + + + +UTF-8 + + FooBar + + + random ascii only + + + + + this contains an umlaut ü &uuml; + + + + + random ascii only in utf8 + + + + + umlaut ü &uuml; in utf8 + + + + diff --git a/tests/auto/linguist/lconvert/data/dual-encoding.ts b/tests/auto/linguist/lconvert/data/dual-encoding.ts new file mode 100644 index 0000000..5023a04 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/dual-encoding.ts @@ -0,0 +1,11 @@ + + + + + + + Mühsam + tedious + + + diff --git a/tests/auto/linguist/lconvert/data/endless-po-loop.ts b/tests/auto/linguist/lconvert/data/endless-po-loop.ts new file mode 100644 index 0000000..6212fbd --- /dev/null +++ b/tests/auto/linguist/lconvert/data/endless-po-loop.ts @@ -0,0 +1,16 @@ + + + + + Assistant + + This is some text which introduces the DonauDampfSchifffahrtsKapitaensMuetzeMitKomischenUltraViolettenFransenUndEinemKnopf + + + + + %n document(s) found. + + + + diff --git a/tests/auto/linguist/lconvert/data/makeplurals.sh b/tests/auto/linguist/lconvert/data/makeplurals.sh new file mode 100755 index 0000000..2e0f375 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/makeplurals.sh @@ -0,0 +1,43 @@ +#! /bin/bash + +function makeit2() +{ + for ((i = 0; i < (1 << $1); i++)); do + echo + test -n "$3" && echo "$3" + echo "msgid \"singular $2 $i\"" + echo "msgid_plural \"plural $2 $i\"" + for ((j = 0; j < $1; j++)); do + tr= + if test $((i & (1 << j))) = 0; then + tr="translated $2 $i $j" + fi + echo "msgstr[$j] \"$tr\"" + done + done +} + +function makeit() +{ + { + cat < ${OUTDIR}plural-$1.po +} + +OUTDIR=$1 +makeit 1 zh_CN +makeit 2 de_DE +makeit 3 pl_PL diff --git a/tests/auto/linguist/lconvert/data/msgid.ts b/tests/auto/linguist/lconvert/data/msgid.ts new file mode 100644 index 0000000..ab65845 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/msgid.ts @@ -0,0 +1,27 @@ + + + + + Dialog2 + + %n files + + + + + + %n cars + + + + + + Age: %1 + + + + func3 + + + + diff --git a/tests/auto/linguist/lconvert/data/plurals-cn.ts b/tests/auto/linguist/lconvert/data/plurals-cn.ts new file mode 100644 index 0000000..966ec77 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/plurals-cn.ts @@ -0,0 +1,17 @@ + + + + + Assistant + + Source + Translation + + + %n document(s) found. + + 1 Dokument gefunden. + + + + diff --git a/tests/auto/linguist/lconvert/data/plurals-de.ts b/tests/auto/linguist/lconvert/data/plurals-de.ts new file mode 100644 index 0000000..6cbadff --- /dev/null +++ b/tests/auto/linguist/lconvert/data/plurals-de.ts @@ -0,0 +1,18 @@ + + + + + Assistant + + Not plural + Kein plural + + + %n document(s) found. + + 1 Dokument gefunden. + %n Dokumente gefunden. + + + + diff --git a/tests/auto/linguist/lconvert/data/relative.ts b/tests/auto/linguist/lconvert/data/relative.ts new file mode 100644 index 0000000..b8eaaca --- /dev/null +++ b/tests/auto/linguist/lconvert/data/relative.ts @@ -0,0 +1,74 @@ + + + + + Foo + + + This is the first entry. + + + + + And a second one on the same line. + + + + + This tr is new. + + + + + + This one moved in from another file. + + + + + Just as this one. + + + + + + Another alien. + + + + + They are coming! + + + + + They are everywhere! + + + + + An earthling again. + + + + + This is from the bottom, too. + + + + + Third string from the bottom. + + + + + Fourth one! + + + + + This string did move from the bottom. + + + + diff --git a/tests/auto/linguist/lconvert/data/singular.po b/tests/auto/linguist/lconvert/data/singular.po new file mode 100644 index 0000000..a0d4019 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/singular.po @@ -0,0 +1,42 @@ +msgid "" +msgstr "" + +msgid "untranslated one" +msgstr "translated" + +#, fuzzy +#| msgid "old untranslated" +msgid "untranslated two" +msgstr "translated" + +#, fuzzy +#| msgid "old untranslated" +msgid "untranslated two b" +msgstr "" + +#, fuzzy +#| msgid "old untranslated" +#| msgid_plural "old untranslated plural" +msgid "untranslated three" +msgstr "translated" + +#, fuzzy +#| msgid "old untranslated" +#| msgid_plural "old untranslated plural" +msgid "untranslated three b" +msgstr "" + +#, fuzzy +#| msgid_plural "old untranslated only plural" +msgid "untranslated four" +msgstr "translated" + +#, fuzzy +#| msgid_plural "old untranslated only plural" +msgid "untranslated four b" +msgstr "" + +#, fuzzy +#| msgctxt "old context" +msgid "untranslated five" +msgstr "translated" diff --git a/tests/auto/linguist/lconvert/data/test-broken-utf8.po b/tests/auto/linguist/lconvert/data/test-broken-utf8.po new file mode 100644 index 0000000..20b58a0 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-broken-utf8.po @@ -0,0 +1,9 @@ +# no comment +msgid "" +msgstr "" + +msgid "this works" +msgstr "das geht: ä" + +msgid "this is broken" +msgstr "das ist kaputt: i" diff --git a/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out b/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out new file mode 100644 index 0000000..c00fd19 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-broken-utf8.po.out @@ -0,0 +1,9 @@ +# no comment +msgid "" +msgstr "" + +msgid "this works" +msgstr "das geht: ä" + +msgid "this is broken" +msgstr "das ist kaputt: i" diff --git a/tests/auto/linguist/lconvert/data/test-developer-comment.po b/tests/auto/linguist/lconvert/data/test-developer-comment.po new file mode 100644 index 0000000..787f312 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-developer-comment.po @@ -0,0 +1,23 @@ +# translation of kdmgreet.po to zh_CN +# Simp. Chinese Translation for kdmgreet. +# Copyright (C) 2001,2003 Free Software Foundation, Inc. +# Gou Zhuang , 2001. +# Xiong Jiang , 2003. +# Yan Shuangchun , 2003. +# +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2008-04-22 16:56+0800\n" +"Last-Translator: Lie_Ex \n" +"Language-Team: zh_CN \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#. I'm a clever developer. Right? Uhm ... +msgid "User %u will log in in %t" +msgstr "用户 %u 将在 %t 秒后登录" diff --git a/tests/auto/linguist/lconvert/data/test-empty-comment.po b/tests/auto/linguist/lconvert/data/test-empty-comment.po new file mode 100644 index 0000000..ce74c46 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-empty-comment.po @@ -0,0 +1,24 @@ +# translation of kdmgreet.po to zh_CN +# Simp. Chinese Translation for kdmgreet. +# Copyright (C) 2001,2003 Free Software Foundation, Inc. +# Gou Zhuang , 2001. +# Xiong Jiang , 2003. +# Yan Shuangchun , 2003. +# +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2008-04-22 16:56+0800\n" +"Last-Translator: Lie_Ex \n" +"Language-Team: zh_CN \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +# +#: themer/kdmlabel.cpp:236 +msgid "User %u will log in in %t" +msgstr "用户 %u 将在 %t 秒后登录" diff --git a/tests/auto/linguist/lconvert/data/test-escapes.po b/tests/auto/linguist/lconvert/data/test-escapes.po new file mode 100644 index 0000000..059dc58 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-escapes.po @@ -0,0 +1,11 @@ +msgid "" +msgstr "" + +msgid "this comes\non a new line" +msgstr "yup" + +msgid "come to \"quote\" me" +msgstr "sure?" + +msgid "\x1a\45\r\t\v\a\b" +msgstr "yup" diff --git a/tests/auto/linguist/lconvert/data/test-escapes.po.out b/tests/auto/linguist/lconvert/data/test-escapes.po.out new file mode 100644 index 0000000..10eefb2 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-escapes.po.out @@ -0,0 +1,13 @@ +msgid "" +msgstr "" + +msgid "" +"this comes\n" +"on a new line" +msgstr "yup" + +msgid "come to \"quote\" me" +msgstr "sure?" + +msgid "\x1a%\r\t\v\a\b" +msgstr "yup" diff --git a/tests/auto/linguist/lconvert/data/test-kde-ctxt.po b/tests/auto/linguist/lconvert/data/test-kde-ctxt.po new file mode 100644 index 0000000..b510538 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-kde-ctxt.po @@ -0,0 +1,25 @@ +# translation of kdmgreet.po to zh_CN +# Simp. Chinese Translation for kdmgreet. +# Copyright (C) 2001,2003 Free Software Foundation, Inc. +# Gou Zhuang , 2001. +# Xiong Jiang , 2003. +# Yan Shuangchun , 2003. +# +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2008-04-22 16:56+0800\n" +"Last-Translator: Lie_Ex \n" +"Language-Team: zh_CN \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +#: kgdialog.cpp:231 +#, kde-format +msgctxt "session (location)" +msgid "%1 (%2)" +msgstr "%1(%2)" diff --git a/tests/auto/linguist/lconvert/data/test-kde-fuzzy.po b/tests/auto/linguist/lconvert/data/test-kde-fuzzy.po new file mode 100644 index 0000000..b3f6e03 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-kde-fuzzy.po @@ -0,0 +1,31 @@ +# translation of kdmgreet.po to German +# Übersetzung von kdmgreet.po ins Deutsche +# Copyright (C) +# Thomas Diehl , 2002, 2003, 2004. +# Stephan Johach , 2005. +# Thomas Reitelbach , 2005, 2006, 2007. +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2007-12-06 20:50+0100\n" +"Last-Translator: Thomas Reitelbach \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KAider 0.1\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#: kgverify.cpp:459 +#, fuzzy, kde-format +#| msgid "" +#| "Logging in %1 ...\n" +#| "\n" +msgid "" +"Logging in %1...\n" +"\n" +msgstr "" +"%1 wird angemeldet ...\n" +"\n" diff --git a/tests/auto/linguist/lconvert/data/test-kde-multiline.po b/tests/auto/linguist/lconvert/data/test-kde-multiline.po new file mode 100644 index 0000000..0ca714c --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-kde-multiline.po @@ -0,0 +1,32 @@ +# translation of kdmgreet.po to German +# Übersetzung von kdmgreet.po ins Deutsche +# Copyright (C) +# Thomas Diehl , 2002, 2003, 2004. +# Stephan Johach , 2005. +# Thomas Reitelbach , 2005, 2006, 2007. +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2007-12-06 20:50+0100\n" +"Last-Translator: Thomas Reitelbach \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KAider 0.1\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" + +#: kdmshutdown.cpp:706 +#, kde-format +msgid "" +"Owner: %1\n" +"Type: %2%5\n" +"Start: %3\n" +"Timeout: %4" +msgstr "" +"Eigentümer: %1\n" +"Typ: %2%5\n" +"Start: %3\n" +"Zeitlimit: %4" diff --git a/tests/auto/linguist/lconvert/data/test-kde-plurals.po b/tests/auto/linguist/lconvert/data/test-kde-plurals.po new file mode 100644 index 0000000..6c85d74 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-kde-plurals.po @@ -0,0 +1,27 @@ +# translation of kdmgreet.po to German +# Übersetzung von kdmgreet.po ins Deutsche +# Copyright (C) +# Thomas Diehl , 2002, 2003, 2004. +# Stephan Johach , 2005. +# Thomas Reitelbach , 2005, 2006, 2007. +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2007-12-06 20:50+0100\n" +"Last-Translator: Thomas Reitelbach \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KAider 0.1\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Language: de_DE\n" + +#: kgverify.cpp:505 +#, kde-format +msgid "Your account expires tomorrow." +msgid_plural "Your account expires in %1 days." +msgstr[0] "Ihre Zugangsberechtigung läuft morgen ab." +msgstr[1] "Ihre Zugangsberechtigung läuft in %1 Tagen ab." diff --git a/tests/auto/linguist/lconvert/data/test-slurp.po b/tests/auto/linguist/lconvert/data/test-slurp.po new file mode 100644 index 0000000..67bc239 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-slurp.po @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" + +msgid "just a line" +msgstr "indeed" + +msgid "" +"another " +"line" +msgstr "certainly" + +msgid "a somewhat longer line that will certainly require re-wrapping, and will be re-wrapped if our algorithm is not completely broken.\n" +"this comes on a new line.\n" +msgstr "whatever ..." + +msgid "bi-""segmented" +msgstr "aye" diff --git a/tests/auto/linguist/lconvert/data/test-slurp.po.out b/tests/auto/linguist/lconvert/data/test-slurp.po.out new file mode 100644 index 0000000..8859a70 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-slurp.po.out @@ -0,0 +1,19 @@ +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" + +msgid "just a line" +msgstr "indeed" + +msgid "another line" +msgstr "certainly" + +msgid "" +"a somewhat longer line that will certainly require re-wrapping, and will be " +"re-wrapped if our algorithm is not completely broken.\n" +"this comes on a new line.\n" +msgstr "whatever ..." + +msgid "bi-segmented" +msgstr "aye" diff --git a/tests/auto/linguist/lconvert/data/test-translator-comment.po b/tests/auto/linguist/lconvert/data/test-translator-comment.po new file mode 100644 index 0000000..bc4df5c --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test-translator-comment.po @@ -0,0 +1,41 @@ +# translation of kdmgreet.po to zh_CN +# Simp. Chinese Translation for kdmgreet. +# Copyright (C) 2001,2003 Free Software Foundation, Inc. +# Gou Zhuang , 2001. +# Xiong Jiang , 2003. +# Yan Shuangchun , 2003. +# +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2008-04-22 16:56+0800\n" +"Last-Translator: Lie_Ex \n" +"Language-Team: zh_CN \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "no comment" +msgstr "indeed" + +# +msgid "just empty" +msgstr "indeed" + +# +# This is some comment. +# +# This is another comment. +# +msgid "User %u will log in in %t" +msgstr "用户 %u 将在 %t 秒后登录" + +# A fooish bar. +# Hey-ho, sucker. +# +# Babbling gully. +msgid "Foo" +msgstr "Bar" diff --git a/tests/auto/linguist/lconvert/data/test1-cn.po b/tests/auto/linguist/lconvert/data/test1-cn.po new file mode 100644 index 0000000..529eca3 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test1-cn.po @@ -0,0 +1,67 @@ +# translation of kdmgreet.po to zh_CN +# Simp. Chinese Translation for kdmgreet. +# Copyright (C) 2001,2003 Free Software Foundation, Inc. +# Gou Zhuang , 2001. +# Xiong Jiang , 2003. +# Yan Shuangchun , 2003. +# +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2008-04-22 16:56+0800\n" +"Last-Translator: Lie_Ex \n" +"Language-Team: zh_CN \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=1; plural=0;\n" +"X-Language: zh_CN\n" + +#: kdmconfig.cpp:147 +msgid "[fix kdmrc]" +msgstr "[修复 kdmrc]" + +#: krootimage.cpp:39 +msgid "Fancy desktop background for kdm" +msgstr "kdm 的梦幻桌面背景" + +#: kgreeter.cpp:558 +#, kde-format +msgid "" +"Your saved session type '%1' is not valid any more.\n" +"Please select a new one, otherwise 'default' will be used." +msgstr "" +"你保存的“%1”会话类型不再有效。\n" +"请选择一个新的类型,否则将使用“默认”。" + +#: kgdialog.cpp:231 +#, kde-format +msgctxt "session (location)" +msgid "%1 (%2)" +msgstr "%1(%2)" + +#: kgverify.cpp:505 +#, kde-format +msgid "Your account expires tomorrow." +msgid_plural "Your account expires in %1 days." +msgstr[0] "您的账户将于 %1 天后过期。" + +#: kdmshutdown.cpp:510 +#, kde-format +msgctxt "current option in boot loader" +msgid "%1 (current)" +msgstr "%1 (当前)" + +#: themer/kdmlabel.cpp:285 +#, no-c-format +msgctxt "date format" +msgid "%a %d %B" +msgstr "%B月%d日,%a" + +#~ msgid "_Suspend" +#~ msgstr "挂起(_S)" + +#~ msgid "Confi_gure" +#~ msgstr "配置(_G)" diff --git a/tests/auto/linguist/lconvert/data/test1-de.po b/tests/auto/linguist/lconvert/data/test1-de.po new file mode 100644 index 0000000..256b8e9 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test1-de.po @@ -0,0 +1,75 @@ +# translation of kdmgreet.po to German +# translation of kdmgreet.po to +# Übersetzung von kdmgreet.po ins Deutsche +# Copyright (C) +# Thomas Diehl , 2002, 2003, 2004. +# Stephan Johach , 2005. +# Thomas Reitelbach , 2005, 2006, 2007. +msgid "" +msgstr "" +"Project-Id-Version: kdmgreet\n" +"Report-Msgid-Bugs-To: http://bugs.kde.org\n" +"POT-Creation-Date: 2008-04-28 18:47+0200\n" +"PO-Revision-Date: 2007-12-06 20:50+0100\n" +"Last-Translator: Thomas Reitelbach \n" +"Language-Team: German \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: KAider 0.1\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Language: de_DE\n" + +#: lib/acl.c:107 lib/acl.c:121 lib/acl.c:138 lib/acl.c:165 lib/acl.c:174 +#: src/copy.c:695 src/copy.c:2017 +#, c-format +msgid "preserving permissions for %s" +msgstr "a preservar as permissões de %s" + +#: kdmconfig.cpp:147 +msgid "[fix kdmrc]" +msgstr "[fix kdmrc]" + +#: krootimage.cpp:39 +msgid "Fancy desktop background for kdm" +msgstr "Schicker Arbeitsflächenhintergrund für KDM" + +#: kgreeter.cpp:558 +#, kde-format +msgid "" +"Your saved session type '%1' is not valid any more.\n" +"Please select a new one, otherwise 'default' will be used." +msgstr "" +"Der gespeicherte Sitzungstyp „%1“ ist nicht mehr gültig.\n" +"Bitte wählen Sie einen neuen. Sonst wird die Voreinstellung verwendet." + +#: kgdialog.cpp:231 +#, kde-format +msgctxt "session (location)" +msgid "%1 (%2)" +msgstr "%1 (%2)" + +#: kgverify.cpp:505 +#, kde-format +msgid "Your account expires tomorrow." +msgid_plural "Your account expires in %1 days." +msgstr[0] "Ihre Zugangsberechtigung läuft morgen ab." +msgstr[1] "Ihre Zugangsberechtigung läuft in %1 Tagen ab." + +#: kdmshutdown.cpp:510 +#, kde-format +msgctxt "current option in boot loader" +msgid "%1 (current)" +msgstr "%1 (Aktuelle)" + +#: themer/kdmlabel.cpp:285 +#, no-c-format +msgctxt "date format" +msgid "%a %d %B" +msgstr "%a %d %B" + +#~ msgid "_Suspend" +#~ msgstr "_Ruhezustand" + +#~ msgid "Confi_gure" +#~ msgstr "Ein_richten" diff --git a/tests/auto/linguist/lconvert/data/test11.ts b/tests/auto/linguist/lconvert/data/test11.ts new file mode 100644 index 0000000..aeb46af --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test11.ts @@ -0,0 +1,32 @@ + + + + + FindDialog + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + + Should be obsolete + SHOULD BE OBSOLETE + + + diff --git a/tests/auto/linguist/lconvert/data/test20.ts b/tests/auto/linguist/lconvert/data/test20.ts new file mode 100644 index 0000000..542cdee --- /dev/null +++ b/tests/auto/linguist/lconvert/data/test20.ts @@ -0,0 +1,150 @@ + + + + + Dialog2 + + + %n files + plural form + + + + + + + %n cars + + + + + + + &Find %n cars + + + + + + + Search in %n items? + + + + + + + %1. Search in %n items? + + + + + + + Age: %1 + + + + + There are %n house(s) + Plurals and function call + + + + + + + QTranslator + Simple + + + + + + + QTranslator + Simple with comment + + + + + + + QTranslator + Plural without comment + + + + + + + QTranslator + Plural with comment + + + + + + + func3 + + + + + QApplication + + + 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. + + + + + QCoreApplication + + + Plurals, QCoreApplication + %n house(s) + + + + + + + Plurals, QCoreApplication + %n car(s) + + + + + + + Plurals, QCoreApplication + %n horse(s) + + + + + + + TestClass + + + inline function + TestClass + + + + + inline function 2 + TestClass + + + + + static inline function + TestClass + + + + diff --git a/tests/auto/linguist/lconvert/data/variants.ts b/tests/auto/linguist/lconvert/data/variants.ts new file mode 100644 index 0000000..52bb2d4 --- /dev/null +++ b/tests/auto/linguist/lconvert/data/variants.ts @@ -0,0 +1,24 @@ + + + + + Assistant + + Source + + A really very long translation + Short translation + + + + %n document(s) found. + + 1 Dokument gefunden. + + %n Dokumente gefunden. + %n Dok. gefunden. + + + + + diff --git a/tests/auto/linguist/lconvert/data/wrapping.po b/tests/auto/linguist/lconvert/data/wrapping.po new file mode 100644 index 0000000..39b7fbe --- /dev/null +++ b/tests/auto/linguist/lconvert/data/wrapping.po @@ -0,0 +1,58 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2008-05-14 14:01+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#, no-wrap +msgid "one two three four five six seven eight nine ten eleven twelve thirteen a 12 foo bar\n" +msgstr "" + +#, no-wrap +msgid "" +"one two three four five six seven eight nine ten eleven twelve thirteen a 13 foo bar\n" +"second line" +msgstr "" + +#: gettxt.c:3 +msgid "" +"one two three four five six seven eight nine ten eleven twelve thirteen a 14 " +"foo bar\n" +msgstr "" + +#: gettxt.c:4 +msgid "" +"one two three four five six seven eight nine ten eleven twelve thirteen a " +"15\n" +msgstr "" + +#: gettxt.c:5 +msgid "" +"one two three four five six seven eight nine ten eleven twelve thirteen a " +"123 foo bar\n" +msgstr "" + +#: gettxt.c:6 +msgid "one two three four five six seven eight nine ten eleven twelve thirteen" +msgstr "" + +#: gettxt.c:7 +msgid "" +"one two three four five six seven eight nine ten eleven twelve th1rt33n\n" +msgstr "" + +#: gettxt.c:8 +msgid "one two three four five six\n" +msgstr "" diff --git a/tests/auto/linguist/lconvert/lconvert.pro b/tests/auto/linguist/lconvert/lconvert.pro new file mode 100644 index 0000000..517dacd --- /dev/null +++ b/tests/auto/linguist/lconvert/lconvert.pro @@ -0,0 +1,8 @@ +CONFIG += qttest_p4 + +TARGET = tst_lconvert + +#HEADERS += testlupdate.h +SOURCES += tst_lconvert.cpp +# testlupdate.cpp + diff --git a/tests/auto/linguist/lconvert/tst_lconvert.cpp b/tests/auto/linguist/lconvert/tst_lconvert.cpp new file mode 100644 index 0000000..3df2a19 --- /dev/null +++ b/tests/auto/linguist/lconvert/tst_lconvert.cpp @@ -0,0 +1,300 @@ +#include +#include + +class tst_lconvert : public QObject +{ + Q_OBJECT + +public: + tst_lconvert() : dataDir("data/") {} + +private slots: + void initTestCase(); + void readverifies_data(); + void readverifies(); + void converts_data(); + void converts(); + void roundtrips_data(); + void roundtrips(); +#if 0 + void chains_data(); + void chains(); +#endif + +private: + void doWait(QProcess *cvt, int stage); + void doCompare(QIODevice *actual, const QString &expectedFn); + void verifyReadFail(const QString &fn); + // args can be empty or have one element less than stations + void convertChain(const QString &inFileName, const QString &outFileName, + const QStringList &stations, const QList &args); + void convertRoundtrip(const QString &fileName, const QStringList &stations, + const QList &args); + + QString dataDir; +}; + +void tst_lconvert::initTestCase() +{ + if (!QFile::exists(QLatin1String("data/plural-1.po"))) + QProcess::execute(QLatin1String("data/makeplurals.sh"), QStringList() << QLatin1String("data/")); + QVERIFY(QFile::exists(QLatin1String("data/plural-1.po"))); +} + +void tst_lconvert::doWait(QProcess *cvt, int stage) +{ + if (QTest::currentTestFailed()) { + cvt->kill(); + cvt->waitForFinished(); + } else { + QVERIFY2(cvt->waitForFinished(3000), + qPrintable(QString("Process %1 hung").arg(stage))); + QVERIFY2(cvt->exitStatus() == QProcess::NormalExit, + qPrintable(QString("Process %1 crashed").arg(stage))); + QVERIFY2(cvt->exitCode() == 0, + qPrintable(QString("Process %1 exited with status %2. Errors:\n%3") + .arg(stage).arg(cvt->exitCode()) + .arg(QString::fromUtf8(cvt->readAllStandardError())))); + } +} + +void tst_lconvert::doCompare(QIODevice *actualDev, const QString &expectedFn) +{ + QList actual = actualDev->readAll().split('\n'); + + QFile file(expectedFn); + QVERIFY(file.open(QIODevice::ReadOnly)); + QList expected = file.readAll().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 (actual.at(i) != expected.at(i)) { + while ((ei - 1) >= i && (gi - 1) >= i && 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("Output for " + expectedFn + " does not meet expectations:\n" + diff)); +} + +void tst_lconvert::verifyReadFail(const QString &fn) +{ + QProcess cvt; + cvt.start("lconvert", QStringList() << (dataDir + fn)); + QVERIFY(cvt.waitForFinished(1000)); + QVERIFY(cvt.exitStatus() == QProcess::NormalExit); + QVERIFY2(cvt.exitCode() == 2, "Accepted invalid input"); +} + +void tst_lconvert::convertChain(const QString &_inFileName, const QString &_outFileName, + const QStringList &stations, const QList &argList) +{ + QList cvts; + + QString fileName = dataDir + _inFileName; + QString outFileName = dataDir + _outFileName; + + for (int i = 0; i < stations.size() - 1; i++) { + QProcess *cvt = new QProcess(this); + if (cvts.isEmpty()) + cvt->setStandardInputFile(fileName); + else + cvts.last()->setStandardOutputProcess(cvt); + cvts.append(cvt); + } + for (int i = 0; i < stations.size() - 1; i++) { + QStringList args; + if (!argList.isEmpty()) + args += argList[i]; + args << "-if" << stations[i] << "-i" << "-" << "-of" << stations[i + 1]; + cvts.at(i)->start("lconvert", args); + } + int st = 0; + foreach (QProcess *cvt, cvts) + doWait(cvt, ++st); + + if (!QTest::currentTestFailed()) + doCompare(cvts.last(), outFileName); + + qDeleteAll(cvts); +} + +void tst_lconvert::convertRoundtrip(const QString &_fileName, const QStringList &stations, + const QList &argList) +{ + convertChain(_fileName, _fileName, stations, argList); +} + +void tst_lconvert::readverifies_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("format"); + + QTest::newRow("empty comment") << "test-empty-comment.po" << "po"; + QTest::newRow("translator comment") << "test-translator-comment.po" << "po"; + QTest::newRow("developer comment") << "test-developer-comment.po" << "po"; + QTest::newRow("kde context") << "test-kde-ctxt.po" << "po"; + QTest::newRow("kde fuzzy") << "test-kde-fuzzy.po" << "po"; + QTest::newRow("kde plurals") << "test-kde-plurals.po" << "po"; + QTest::newRow("kde multiline") << "test-kde-multiline.po" << "po"; + QTest::newRow("po linewrapping") << "wrapping.po" << "po"; + QTest::newRow("relative locations") << "relative.ts" << "ts"; + QTest::newRow("message ids") << "msgid.ts" << "ts"; + QTest::newRow("length variants") << "variants.ts" << "ts"; +} + +void tst_lconvert::readverifies() +{ + QFETCH(QString, fileName); + QFETCH(QString, format); + + convertRoundtrip(fileName, QStringList() << format << format, QList()); +} + +void tst_lconvert::converts_data() +{ + QTest::addColumn("inFileName"); + QTest::addColumn("outFileName"); + QTest::addColumn("format"); + + QTest::newRow("broken utf8") << "test-broken-utf8.po" << "test-broken-utf8.po.out" << "po"; + QTest::newRow("line joins") << "test-slurp.po" << "test-slurp.po.out" << "po"; + QTest::newRow("escapes") << "test-escapes.po" << "test-escapes.po.out" << "po"; +} + +void tst_lconvert::converts() +{ + QFETCH(QString, inFileName); + QFETCH(QString, outFileName); + QFETCH(QString, format); + + QString outFileNameFq = dataDir + outFileName; + + QProcess cvt; + cvt.start("lconvert", QStringList() << "-i" << (dataDir + inFileName) << "-of" << format); + doWait(&cvt, 0); + if (QTest::currentTestFailed()) + return; + + doCompare(&cvt, outFileNameFq); +} + +Q_DECLARE_METATYPE(QList); + +#if 0 +void tst_lconvert::chains_data() +{ + QTest::addColumn("inFileName"); + QTest::addColumn("outFileName"); + QTest::addColumn("stations"); + QTest::addColumn >("args"); + +} + +void tst_lconvert::chains() +{ + QFETCH(QString, inFileName); + QFETCH(QString, outFileName); + QFETCH(QStringList, stations); + QFETCH(QList, args); + + convertChain(inFileName, outFileName, stations, args); +} +#endif + +void tst_lconvert::roundtrips_data() +{ + QTest::addColumn("fileName"); + QTest::addColumn("stations"); + QTest::addColumn >("args"); + + QStringList poTsPo; poTsPo << "po" << "ts" << "po"; + QStringList poXlfPo; poXlfPo << "po" << "xlf" << "po"; + QStringList tsTs11Ts; tsTs11Ts << "ts" << "ts11" << "ts"; + QStringList tsPoTs; tsPoTs << "ts" << "po" << "ts"; + QStringList ts11PoTs11; ts11PoTs11 << "ts11" << "po" << "ts11"; + QStringList tsXlfTs; tsXlfTs << "ts" << "xlf" << "ts"; + QStringList tsQmTs; tsQmTs << "ts" << "qm" << "ts"; + + QList noArgs; + QList filterPoArgs; filterPoArgs << QStringList() << (QStringList() << "-drop-tag" << "po:*"); + QList outDeArgs; outDeArgs << QStringList() << (QStringList() << "-target-language" << "de"); + QList outCnArgs; outCnArgs << QStringList() << (QStringList() << "-target-language" << "cn"); + + QTest::newRow("po-ts-po (translator comment)") << "test-translator-comment.po" << poTsPo << noArgs; + QTest::newRow("po-xliff-po (translator comment)") << "test-translator-comment.po" << poXlfPo << noArgs; + QTest::newRow("po-ts-po (developer comment)") << "test-developer-comment.po" << poTsPo << noArgs; + QTest::newRow("po-xliff-po (developer comment)") << "test-developer-comment.po" << poXlfPo << noArgs; + + QTest::newRow("ts11-po-ts11") << "test11.ts" << ts11PoTs11 << filterPoArgs; + QTest::newRow("ts20-po-ts20") << "test20.ts" << tsPoTs << filterPoArgs; + QTest::newRow("po-ts-po (de)") << "test1-de.po" << poTsPo << noArgs; + QTest::newRow("po-ts-po (cn)") << "test1-cn.po" << poTsPo << noArgs; + QTest::newRow("po-xliff-po (de)") << "test1-de.po" << poXlfPo << noArgs; + QTest::newRow("po-xliff-po (cn)") << "test1-cn.po" << poXlfPo << noArgs; + + QTest::newRow("po-ts-po (singular)") << "singular.po" << poTsPo << noArgs; + QTest::newRow("po-ts-po (plural-1)") << "plural-1.po" << poTsPo << noArgs; + QTest::newRow("po-ts-po (plural-2)") << "plural-2.po" << poTsPo << noArgs; + QTest::newRow("po-ts-po (plural-3)") << "plural-3.po" << poTsPo << noArgs; + QTest::newRow("po-xliff-po (singular)") << "singular.po" << poXlfPo << noArgs; + QTest::newRow("po-xliff-po (plural-1)") << "plural-1.po" << poXlfPo << noArgs; + QTest::newRow("po-xliff-po (plural-2)") << "plural-2.po" << poXlfPo << noArgs; + QTest::newRow("po-xliff-po (plural-3)") << "plural-3.po" << poXlfPo << noArgs; + + QTest::newRow("ts20-ts11-ts20 (utf8)") << "codec-utf8.ts" << tsTs11Ts << noArgs; + QTest::newRow("ts20-ts11-ts20 (cp1252)") << "codec-cp1252.ts" << tsTs11Ts << noArgs; + QTest::newRow("ts20-ts11-ts20 (dual-encoding)") << "dual-encoding.ts" << tsTs11Ts << noArgs; + + QTest::newRow("ts-qm-ts (dual-encoding)") << "dual-encoding.ts" << tsQmTs << noArgs; + QTest::newRow("ts-qm-ts (plurals-de)") << "plurals-de.ts" << tsQmTs << outDeArgs; + QTest::newRow("ts-qm-ts (plurals-cn)") << "plurals-cn.ts" << tsQmTs << outCnArgs; + QTest::newRow("ts-qm-ts (variants)") << "variants.ts" << tsQmTs << outDeArgs; + QTest::newRow("ts-po-ts (msgid)") << "msgid.ts" << tsPoTs << noArgs; + QTest::newRow("ts-xliff-ts (msgid)") << "msgid.ts" << tsXlfTs << noArgs; + + QTest::newRow("ts-po-ts (endless loop)") << "endless-po-loop.ts" << tsPoTs << noArgs; +} + +void tst_lconvert::roundtrips() +{ + QFETCH(QString, fileName); + QFETCH(QStringList, stations); + QFETCH(QList, args); + + convertRoundtrip(fileName, stations, args); +} + +QTEST_APPLESS_MAIN(tst_lconvert) + +#include "tst_lconvert.moc" diff --git a/tests/auto/linguist/linguist.pro b/tests/auto/linguist/linguist.pro new file mode 100644 index 0000000..90e2d36 --- /dev/null +++ b/tests/auto/linguist/linguist.pro @@ -0,0 +1,2 @@ +TEMPLATE = subdirs +SUBDIRS = lrelease lconvert lupdate diff --git a/tests/auto/linguist/lrelease/lrelease.pro b/tests/auto/linguist/lrelease/lrelease.pro new file mode 100644 index 0000000..8006042 --- /dev/null +++ b/tests/auto/linguist/lrelease/lrelease.pro @@ -0,0 +1,5 @@ +CONFIG += qttest_p4 +CONFIG -= gui +TARGET = tst_lrelease + +SOURCES += tst_lrelease.cpp diff --git a/tests/auto/linguist/lrelease/testdata/compressed.ts b/tests/auto/linguist/lrelease/testdata/compressed.ts new file mode 100644 index 0000000..9579269 --- /dev/null +++ b/tests/auto/linguist/lrelease/testdata/compressed.ts @@ -0,0 +1,46 @@ + + + + + Context1 + + Foo + in first context + + + + Context2 + + Bar + in second context + + + + Action1 + + + Component Name + translation in first context + + + Fooish bar + the bar is fooish + + + + Action2 + + + Component Name + translation in second context + + + + Action3 + + + Component Name + translation in third context + + + diff --git a/tests/auto/linguist/lrelease/testdata/dupes.errors b/tests/auto/linguist/lrelease/testdata/dupes.errors new file mode 100644 index 0000000..74fcbbb --- /dev/null +++ b/tests/auto/linguist/lrelease/testdata/dupes.errors @@ -0,0 +1,4 @@ +Warning: dropping duplicate messages in 'testdata/dupes\.qm': + +\* Context: FindDialog +\* Source: Text not found diff --git a/tests/auto/linguist/lrelease/testdata/dupes.ts b/tests/auto/linguist/lrelease/testdata/dupes.ts new file mode 100644 index 0000000..ec368c3 --- /dev/null +++ b/tests/auto/linguist/lrelease/testdata/dupes.ts @@ -0,0 +1,25 @@ + + + + + FindDialog + + Search reached start of the document + + + + + Search reached start of the document + + + + + Text not found + + + + Text not found + + + + diff --git a/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts b/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts new file mode 100644 index 0000000..991f354 --- /dev/null +++ b/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts11.ts @@ -0,0 +1,18 @@ + + + +windows-1252 + + FooBar + + + this contains an umlaut ü &uuml; + random stuff with umlaut + + + + umlaut ü &uuml; in utf8 + more random stuff with umlaut + + + diff --git a/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts20.ts b/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts20.ts new file mode 100644 index 0000000..8bb56d4 --- /dev/null +++ b/tests/auto/linguist/lrelease/testdata/mixedcodecs-ts20.ts @@ -0,0 +1,18 @@ + + + +windows-1252 + + FooBar + + + this contains an umlaut ü &uuml; + random stuff with umlaut + + + + umlaut ü &uuml; in utf8 + more random stuff with umlaut + + + diff --git a/tests/auto/linguist/lrelease/testdata/translate.ts b/tests/auto/linguist/lrelease/testdata/translate.ts new file mode 100644 index 0000000..ad3015d --- /dev/null +++ b/tests/auto/linguist/lrelease/testdata/translate.ts @@ -0,0 +1,136 @@ + + + + + + + + Test + AAAA + Empty context + + + + CubeForm + + + Test + BBBB + + + + QObject + + + +newline at the start + +NEWLINE AT THE START + + + + newline at the end + + NEWLINE AT THE END + + + + + newline and space at the end + + NEWLINE AND SPACE AT THE END + + + + + space and newline at the end + + SPACE AND NEWLINE AT THE END + + + + + tab at the start and newline at the end + + TAB AT THE START AND NEWLINE AT THE END + + + + + +newline and tab at the start + +NEWLINE AND TAB AT THE START + + + + space and tab at the start + SPACE AND TAB AT THE START + + + + space first + + + + + string that does not exist + + + + + Plurals + + + There are %n houses + + There is %n house + There are %n houses + + + + + tst_lrelease + + + There are %n cars + More Plurals + + There is %n car + There are %n cars + + + + Completely random string + + Super-lange Uebersetzung mit Schikanen + Mittlere Uebersetung + Kurze Uebers. + + + + + no_en + + + Kjør Kåre, kjære + Drive Kåre, dear + + + + en_no + + + Drive Kåre, dear + Kjør Kåre, kjære + + + + en_ch + + + Chinese symbol: + Chinese symbol:簟 + + + diff --git a/tests/auto/linguist/lrelease/tst_lrelease.cpp b/tests/auto/linguist/lrelease/tst_lrelease.cpp new file mode 100644 index 0000000..6f65dbc --- /dev/null +++ b/tests/auto/linguist/lrelease/tst_lrelease.cpp @@ -0,0 +1,163 @@ +#include +#include +#include +#include + +#include + +class tst_lrelease : public QObject +{ + Q_OBJECT +private: + +private slots: + void translate(); + void mixedcodecs(); + void compressed(); + void dupes(); + +private: + void doCompare(const QStringList &actual, const QString &expectedFn); +}; + +void tst_lrelease::doCompare(const QStringList &actual, const QString &expectedFn) +{ + 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 (!QRegExp(expected.at(i)).exactMatch(actual.at(i))) { + while ((ei - 1) >= i && (gi - 1) >= i && + (QRegExp(expected.at(ei - 1)).exactMatch(actual.at(gi - 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("Output for " + expectedFn + " does not meet expectations:\n" + diff)); +} + +void tst_lrelease::translate() +{ + QVERIFY(!QProcess::execute("lrelease testdata/translate.ts")); + + QTranslator translator; + QVERIFY(translator.load("testdata/translate.qm")); + qApp->installTranslator(&translator); + + QCOMPARE(QObject::tr("\nnewline at the start"), QString("\nNEWLINE AT THE START")); + QCOMPARE(QObject::tr("newline at the end\n"), QString("NEWLINE AT THE END\n")); + QCOMPARE(QObject::tr("newline and space at the end\n "), QString("NEWLINE AND SPACE AT THE END\n ")); + QCOMPARE(QObject::tr("space and newline at the end \n"), QString("SPACE AND NEWLINE AT THE END \n")); + QCOMPARE(QObject::tr("\ttab at the start and newline at the end\n"), QString("\tTAB AT THE START AND NEWLINE AT THE END\n")); + QCOMPARE(QObject::tr("\n\tnewline and tab at the start"), QString("\n\tNEWLINE AND TAB AT THE START")); + QCOMPARE(QObject::tr(" \tspace and tab at the start"), QString(" \tSPACE AND TAB AT THE START")); + QCOMPARE(QObject::tr(" string that does not exist"), QString(" string that does not exist")); + + QCOMPARE(QCoreApplication::translate("CubeForm", "Test"), QString::fromAscii("BBBB")); + QCOMPARE(QCoreApplication::translate("", "Test", "Empty context"), QString("AAAA")); + + // Test plurals + QString txed = QCoreApplication::translate("Plurals", "There are %n houses", 0, QCoreApplication::UnicodeUTF8, 0); + QCOMPARE(QString::fromAscii("[%1]").arg(txed), QString("[There are 0 houses]")); + QCOMPARE(QCoreApplication::translate("Plurals", "There are %n houses", 0, QCoreApplication::UnicodeUTF8, 1), QString("There is 1 house")); + QCOMPARE(QCoreApplication::translate("Plurals", "There are %n houses", 0, QCoreApplication::UnicodeUTF8, 2), QString("There are 2 houses")); + QCOMPARE(QCoreApplication::translate("Plurals", "There are %n houses", 0, QCoreApplication::UnicodeUTF8, 3), QString("There are 3 houses")); + + + // More plurals + QCOMPARE(tr("There are %n cars", "More Plurals", 0) , QString("There are 0 cars")); + QCOMPARE(tr("There are %n cars", "More Plurals", 1) , QString("There is 1 car")); + QCOMPARE(tr("There are %n cars", "More Plurals", 2) , QString("There are 2 cars")); + QCOMPARE(tr("There are %n cars", "More Plurals", 3) , QString("There are 3 cars")); + + + QCOMPARE(QCoreApplication::translate("no_en", "Kj\370r K\345re, kj\346re"), QString::fromAscii("Drive K\345re, dear")); + QCOMPARE(QCoreApplication::translate("en_no", "Drive K\345re, dear"), QString::fromAscii("Kj\370r K\345re, kj\346re")); + QCOMPARE(QCoreApplication::translate("en_ch", "Chinese symbol:"), QString::fromAscii("Chinese symbol:%1").arg(QChar(0x7c1f))); + +// printf("halo\r\nhallo"); + // QCOMPARE(tr("This\r\nwill fail"), QString("THIS\nWILL FAIL")); // \r\n = 0d 0a + + QCOMPARE(tr("Completely random string"), + QString::fromLatin1("Super-lange Uebersetzung mit Schikanen\x9c" + "Mittlere Uebersetung\x9c" + "Kurze Uebers.")); + + qApp->removeTranslator(&translator); +} + +void tst_lrelease::mixedcodecs() +{ + QVERIFY(!QProcess::execute("lrelease testdata/mixedcodecs-ts11.ts")); + QVERIFY(!QProcess::execute("lrelease testdata/mixedcodecs-ts20.ts")); + QVERIFY(!QProcess::execute("cmp testdata/mixedcodecs-ts11.qm testdata/mixedcodecs-ts20.qm")); + QTranslator translator; + QVERIFY(translator.load("testdata/mixedcodecs-ts11.qm")); + qApp->installTranslator(&translator); + + QCOMPARE(QCoreApplication::translate("FooBar", "this contains an umlaut \xfc ü"), + QString::fromAscii("random stuff with umlaut")); + QCOMPARE(QCoreApplication::translate("FooBar", "umlaut \xc3\xbc ü in utf8"), + QString::fromAscii("more random stuff with umlaut")); +} + +void tst_lrelease::compressed() +{ + QVERIFY(!QProcess::execute("lrelease -compress testdata/compressed.ts")); + + QTranslator translator; + QVERIFY(translator.load("testdata/compressed.qm")); + qApp->installTranslator(&translator); + + QCOMPARE(QCoreApplication::translate("Context1", "Foo"), QString::fromAscii("in first context")); + QCOMPARE(QCoreApplication::translate("Context2", "Bar"), QString::fromAscii("in second context")); + + QCOMPARE(QCoreApplication::translate("Action1", "Component Name"), QString::fromAscii("translation in first context")); + QCOMPARE(QCoreApplication::translate("Action2", "Component Name"), QString::fromAscii("translation in second context")); + QCOMPARE(QCoreApplication::translate("Action3", "Component Name"), QString::fromAscii("translation in third context")); + +} + +void tst_lrelease::dupes() +{ + QProcess proc; + proc.start("lrelease testdata/dupes.ts"); + QVERIFY(proc.waitForFinished()); + QVERIFY(proc.exitStatus() == QProcess::NormalExit); + doCompare(QString(proc.readAllStandardError()).trimmed().remove('\r').split('\n'), "testdata/dupes.errors"); +} + +QTEST_MAIN(tst_lrelease) +#include "tst_lrelease.moc" 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 @@ + + + + + QApplication + + + 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. + + + + 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 +#include +#include +#include + +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 @@ + + + +UTF-8 + + QObject + + + abc + ascii + + + + + æøå + utf-8 + + + + 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 +#include +#include +#include + +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 @@ + + + +windows-1251 + + QObject + + + Á + + + + 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 + +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 @@ + + + +windows-1252 + + FooBar + + + random ascii only + + + + + this contains an umlaut ü &uuml; + + + + + random ascii only in utf8 + + + + + umlaut ü &uuml; in utf8 + + + + 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 + +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 @@ + + + +UTF-8 + + FooBar + + + random ascii only + + + + + this contains an umlaut ü &uuml; + + + + + random ascii only in utf8 + + + + + umlaut ü &uuml; in utf8 + + + + 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 + + +// +// 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 @@ + + + + + B + + + Bla + ::B + + + + + C + + + Bla + ::C + + + + + nsB::B + + + Bla + nsB::B + + + + + nsB::C + + + Bla + nsB::C + + + + 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 @@ + + + + Bar + + + Another alien. + + + + + They are coming! + + + + + They are everywhere! + + + + + This one moved in from another file. + + + + + Foo + + + This is the first entry. + + + + + A second message. + + + + + Now again one which is just where it was. + + + + + Just as this one. + + + + + An earthling again. + + + + + This is from the bottom, too. + + + + + Third string from the bottom. + + + + + Fourth one! + + + + + This string did move from the bottom. + + + + 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 @@ + + + + + Foo + + + This is the first entry. + + + + + A second message. + + + + + And a second one on the same line. + + + + + This tr is new. + + + + + This one moved in from another file. + + + + + Now again one which is just where it was. + + + + + Just as this one. + + + + + Another alien. + + + + + They are coming! + + + + + They are everywhere! + + + + + An earthling again. + + + + + This is from the bottom, too. + + + + + Third string from the bottom. + + + + + Fourth one! + + + + + This string did move from the bottom. + + + + 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 @@ + + + + FindDialog + + Qt Assistant - Finn text + + + + Finn tekst + + + + 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 @@ + + + + + FindDialog + + Qt Assistant - Finn text + + + + Finn tekst + + + + 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 @@ + + + ********************************************************************* +** +** 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. +** +********************************************************************* + + FindDialog + + + + 0 + 0 + 400 + 172 + + + + Qt Assistant - Finn text + + + Finn tekst + + + + comboFind + checkWords + checkCase + radioForward + radioBackward + findButton + closeButton + + + + 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 +#include + +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 @@ + + + + QObject + + + +newline at the start + +NEWLINE AT THE START + + + + newline at the end + + NEWLINE AT THE END + + + + + newline and space at the end + + NEWLINE AND SPACE AT THE END + + + + + space and newline at the end + + SPACE AND NEWLINE AT THE END + + + + + Tab at the start and newline at the end + + TAB AT THE START AND NEWLINE AT THE END + + + + + +newline and tab at the start + +NEWLINE AND TAB AT THE START + + + + space and tab at the start + SPACE AND TAB AT THE START + + + + space_first + SPACE_FIRST + + + + space_last + SPACE_LAST + + + + carriage return and line feed last + + CARRIAGE RETURN AND LINE FEED LAST + + + + 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 @@ + + + + + QObject + + + +newline at the start + +NEWLINE AT THE START + + + + newline at the end + + NEWLINE AT THE END + + + + + newline and space at the end + + NEWLINE AND SPACE AT THE END + + + + + space and newline at the end + + SPACE AND NEWLINE AT THE END + + + + + Tab at the start and newline at the end + + TAB AT THE START AND NEWLINE AT THE END + + + + + + newline and tab at the start + + NEWLINE AND TAB AT THE START + + + + space and tab at the start + SPACE AND TAB AT THE START + + + + space_first + SPACE_FIRST + + + + space_last + SPACE_LAST + + + + carriage return and line feed last + + CARRIAGE RETURN AND LINE FEED LAST + + + + 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 @@ + + + + FindDialog + + + magic context comment + random translator comment + + + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + + %n item(s) + merge from singular to plural form + + + + + + + %n item(s) + merge from a finished singular form to an unfinished plural form + + + + + + 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 @@ + + + + + FindDialog + + + magic context comment + random translator comment + + + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + + %n item(s) + merge from singular to plural form + + + + + + + %n item(s) + merge from a finished singular form to an unfinished plural form + + + + + + 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 +#include +#include +#include +#include +#include + +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(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 @@ + + + + FindDialog + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + + Should be obsolete + SHOULD BE OBSOLETE + + + 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 @@ + + + + + FindDialog + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + 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 +#include +#include +#include +#include +#include + +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(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(parent())->statusBar()->showMessage(message, 2000); +} + +MainWindow *FindDialog::mainWindow() const +{ + return static_cast(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 @@ + + + + FindDialog + + + Enter the text you are looking for. + Skriv inn teksten du soker etter + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + 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 @@ + + + + + FindDialog + + Enter the text you are looking for. + Skriv inn teksten du soker etter + + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + 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 @@ + + + + FindDialog + + + Qt Assistant - Find text + + Qt Assistant - Finn tekst + + + + 300px + 300px + + + + 400px + + + + 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 @@ + + + + + FindDialog + + + Qt Assistant - Find Text + Qt Assistant - Find text + Qt Assistant - Finn tekst + + + + 300px + 300px + + + + 401 pixels + + + + 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 @@ + + + ********************************************************************* +** +** 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. +** +********************************************************************* + + FindDialog + + + + 0 + 0 + 400 + 172 + + + + Qt Assistant - Find Text + + + 300px + + + 401 pixels + + + + comboFind + checkWords + checkCase + radioForward + radioBackward + findButton + closeButton + + + + 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 @@ + + + + FindDialog + + + Test similarity + Test likhet (test1) + + + + Similarity should have kicked in here! + Test likhet (test2) + + + 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 @@ + + + + + FindDialog + + Test similarity + Test likhet (test1) + + + + This should not be considered to be more or less equal to the corresponding one in the ts file. + + + + + Here, similarity should kick in! + Similarity should have kicked in here! + Test likhet (test2) + + + 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 @@ + + + + + + FindDialog + + + + This should not be considered to be more or less equal to the corresponding one in the ts file. + + + Here, similarity should kick in! + + + 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 @@ + + + + + context + + + + + just a message + This is one comment +---------- +This is a comment, too. + + + + 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 + +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 @@ + + + + + Class + + + nested class context + + + + + just class context + + + + + outestmost class + + + + + Outer::Class + + + outer class + + + + + Outer::Middle1::Different + + + different namespaced class def + + + + + Outer::Middle1::Inner1::Class + + + innermost one + + + + + innermost two + + + + + innermost three + + + + + innermost four + + + + + Outer::Middle1::Something + + + namespaced class def + + + + + namespaced class def 2 + + + + + Outer::Middle2::Inner2::Class + + + innermost three b + + + + 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 @@ + + + + + Dialog2 + + + catégorie + + + + + Für Èlise + + + + 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 +#include + +// +// 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 @@ + + + + + A1::AB + + + inlineFuncAfterFriendDeclaration + A1::AB + + + + + A1::B + + + foo + A1::B + + + + + A1::B2 + + + test TRANSLATOR comment (2) + A1::B2 + + + + + test TRANSLATOR comment (4) + A1::B2 + + + + + test TRANSLATOR comment (5) + A1::B2 + + + + + A1::B3::C2 + + + test TRANSLATOR comment (6) + A1::B3::C2 + + + + + A1::V + + + bar + A1::V + + + + + A1::W + + + baz + A1::W + + + + + A::C + + + + Bla + A::C + + + + + Bla 2 + A::C + + + + + B1 + + + test TRANSLATOR comment (1) + B1 + + + + + B2 + + + + This is a comment to the translator. + + + + + C1 + + + test TRANSLATOR comment (3) + C1 + + + + + D + + + test + D + + + + + Gui::MainWindow + + + More bla + Gui::MainWindow + + + + + QObject + + + task 161186 + QObject + + + + + X::D + + + foo + D + + + + + Bla + X::D + + + + + X::F + + + inline function + X::F + + + + + X::Y::C + + + Bla + X::Y::C + + + + + X::Y::E + + + + Bla + X::Y::E + + + + + ico::foo::A + + + myfoo + ico::foo::A + + + + 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 +#include +#include +#include +#include +#include + +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(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(parent())->statusBar()->showMessage(message, 2000); +} + +MainWindow *FindDialog::mainWindow() const +{ + return static_cast(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 @@ + + + + + Dialog2 + + + %n files + plural form + + + + + + + %n cars + + + + + + + &Find %n cars + + + + + + + Search in %n items? + + + + + + + %1. Search in %n items? + + + + + + + Age: %1 + + + + + There are %n house(s) + Plurals and function call + + + + + + + func3 + + + + + FindDialog + + + Enter the text you are looking for. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + + null comment + + + + + Kåntekst + + + encoding, using QApplication + + + + + Plurals, QCoreApplication + + + %n house(s) + Plurals and identifier + + + + + + + %n car(s) + Plurals and literal number + + + + + + + %n horse(s) + Plurals and function call + + + + + + + QApplication + + + 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. + + + + + QCoreApplication + + + with comment + comment + + + + + empty comment + + + + + null comment + + + + + encoding, using QCoreApplication + + + + + encoding, using QApplication + + + + + QTranslator + + + + Simple + + + + + Simple with comment + with comment + + + + + Plural without comment + + + + + + + Plural with comment + comment 1 + + + + + + + Plural with comment + comment 2 + + + + + + + TestClass + + + inline function + TestClass + + + + + inline function 2 + TestClass + + + + + static inline function + TestClass + + + + + Testing + + + extra-commented string + this is an extra comment for the translator + + + + + not extra-commented string + + + + + another extra-commented string + another extra-comment + + + + + scope + + + works in translate, too + blabb + blah! + + + + + + + string + extra comment for NOOP which spans multiple lines + + + + + string + comment + extra comment for NOOP3 + + + + + string continuation on next line + + + + 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 @@ + + + + + Plurals, QCoreApplication + + + %n house(s) + Plurals and identifier + with extra comment! + + + + + + + QTranslator + + + + Simple + + + + + Simple with comment + with comment + + + + + Plural without comment + + + + + + + Plural with comment + comment 1 + + + + + + + Plural with comment + comment 2 + + + + + + + com.trolltech.examples.I18N + + + pack class method + + + + + 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. + + + + + %n files + plural form + + + + + + + %n cars + + + + + + + Age: %1 + + + + + There are %n house(s) + Plurals and function call + + + + + + + com.trolltech.examples.I18N$MainWindow + + + pack class class + + + + + pack class class extra + extra comment for t-tor + + + + + pack class class method + + + + 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 @@ + + + + + FindDialog + + + Qt Assistant - Finn text + + + + + Finn tekst - Der Bjørn möchte auch mal. + + + + 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 @@ + + + ********************************************************************* +** +** 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. +** +********************************************************************* + + FindDialog + + + + 0 + 0 + 400 + 172 + + + + Qt Assistant - Finn text + + + Finn tekst - Der Bjørn möchte auch mal. + + + + comboFind + checkWords + checkCase + radioForward + radioBackward + findButton + closeButton + + + + 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 @@ + + + + + Foo + + + XXX + YYY + + + + + CTOR + + + + + BAR + + + + 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 @@ + + + + + QApplication + + + Hello world + Platform-independent file + + + + + Kind + Windows only, see Type + + + + + Type + Not used on windows, see Kind + + + + + One string, three lines + + + + + 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/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 @@ + + + + + QApplication + + + Hello world + Platform-independent file + + + + + Hello macworld + mac-only file + + + + + Hello unixworld + unix-only file + + + + + Hello windowsworld + Windows-only file + + + + + Hello world + wildcard/main1.cpp + + + + + Hello world + wildcard/main2.cpp + + + + + Hello world + wildcard1.cpp + + + + + Hello world + wildcard99.cpp + + + + + QCoreApplication + + + Hello from a DEPENDPATH + See if the DEPENDPATH thing works + + + + 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 @@ + + + + + QLineEdit + + + a + + + + + a.cpp + + + + + b + + + + + b.cpp + + + + + e + + + + + f/g.cpp + + + + + spaces/z + + + + + variable with spaces + + + + + with + + + + + x/d + + + + + x/variable + + + + 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 @@ + + + + + QApplication + + + Hello world + Platform-independent file + + + + + Hello macworld + mac-only file + + + + + relativity.pri + Platform-independent file + + + + + Hello unixworld + unix-only file + + + + + Hello windowsworld + Windows-only file + + + + 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 @@ + + + + + QApplication + + + Hello world + Platform-independent file + + + + 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 @@ + + + + + QApplication + + + Hello windowsworld + Windows-only file + + + + + Hello macworld + mac-only file + + + + + Hello unixworld + unix-only file + + + + + Hello world + Platform-independent file + + + + 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 @@ + + + + FindDialog + + + Test similarity + Test likhet (test1) + + + + Similarity should have kicked in here! + Test likhet (test2) + + + 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 @@ + + + + + FindDialog + + Test similarity + Test likhet (test1) + + + + This should not be considered to be more or less equal to the corresponding one in the ts file. + + + + + Here, similarity should kick in! + Similarity should have kicked in here! + Test likhet (test2) + + + 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 @@ + + + + + + FindDialog + + + + This should not be considered to be more or less equal to the corresponding one in the ts file. + + + Here, similarity should kick in! + + + 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 @@ + + + + + QApplication + + + Hello world + + + + 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 @@ + + + + + FindDialog + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + 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 @@ + + + + + FindDialog + + + Qt Assistant - Finn text + + + + + Finn tekst + + + + + Enter the text you want to find. + + + + + Search reached end of the document + + + + + Search reached start of the document + + + + + Text not found + + + + + QObject + + + +newline at the start + + + + + newline at the end + + + + + + newline and space at the end + + + + + + space and newline at the end + + + + + + Tab at the start and newline at the end + + + + + + + newline and tab at the start + + + + + space and tab at the start + + + + + space_first + + + + + space_last + + + + + text/c++ + + + test + + + + + text/cpp + + + test + + + + + text/cxx + + + test + + + + 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 +#include + +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 @@ + + + ********************************************************************* +** +** 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. +** +********************************************************************* + + FindDialog + + + + 0 + 0 + 400 + 172 + + + + Qt Assistant - Finn text + + + Finn tekst + + + + comboFind + checkWords + checkCase + radioForward + radioBackward + findButton + closeButton + + + + 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 + +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 + +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 + +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 +#include +#include +#include +#include +#include + +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(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(parent())->statusBar()->showMessage(message, 2000); +} + +MainWindow *FindDialog::mainWindow() const +{ + return static_cast(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..c80dd54 --- /dev/null +++ b/tests/auto/linguist/lupdate/testlupdate.cpp @@ -0,0 +1,116 @@ +#include "testlupdate.h" +#include +#include +#include +#include +#include + +#ifdef Q_OS_WIN32 +# include +#endif + +#include + + +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..3fd7dcb --- /dev/null +++ b/tests/auto/linguist/lupdate/testlupdate.h @@ -0,0 +1,46 @@ +#ifndef TESTLUPDATE_H +#define TESTLUPDATE_H + +#include +#include +#include + +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..1beae73 --- /dev/null +++ b/tests/auto/linguist/lupdate/tst_lupdate.cpp @@ -0,0 +1,277 @@ +#include "testlupdate.h" +#if CHECK_SIMTEXTH +#include "../shared/simtexth.h" +#endif + +#include +#include +#include +#include + +#include + +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("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("currentPath"); + QTest::addColumn("commandline"); + QTest::addColumn("generatedtsfile"); + QTest::addColumn("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("one"); + addColumn("two"); + addColumn("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" diff --git a/tests/auto/tests.xml b/tests/auto/tests.xml index d2f378d..a5386b2 100644 --- a/tests/auto/tests.xml +++ b/tests/auto/tests.xml @@ -9,6 +9,9 @@ + + + @@ -412,6 +415,9 @@ + + + -- cgit v0.12