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