diff options
author | Michael Hanselmann <public@hansmi.ch> | 2016-01-14 13:59:28 +0100 |
---|---|---|
committer | Michael Hanselmann <public@hansmi.ch> | 2016-01-15 13:42:47 +0000 |
commit | 69984af8d5465feb9532823f112f322d5404cc15 (patch) | |
tree | a73c931cf40fb1c8c1c4f30d58bddeceef91167d /tests | |
parent | 1c4ee969c20e4285754f81de13f54f1d0cc2b82c (diff) | |
download | qttools-69984af8d5465feb9532823f112f322d5404cc15.tar.gz |
lupdate: Handle translation comments in ternary expressions
When the condition in a ternary operator expression was anything more
than a single identifier translation comments were not recognized for
translations within the values. Re-enabling translator comment detection
after the question mark fixes that.
Task-number: QTBUG-48776
Change-Id: I83bb9efaab42c52fc05a39094060eb0a1fb76d94
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp | 41 | ||||
-rw-r--r-- | tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result | 49 |
2 files changed, 90 insertions, 0 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp index 6be775994..f4ac1e214 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/main.cpp @@ -447,3 +447,44 @@ class Abc::NamespacedFinalClass final : public QObject tr("namespaced class with final"); } }; + + + +// QTBUG-48776: lupdate fails to recognize translator comment in ternary +// operator construct +void ternary() +{ + const auto aaa = + obj.condition ? + //: comment, aaa, true + QObject::tr("ternary, true, aaa") : + QObject::tr("ternary, failure, aaa"); + + const auto bbb = + obj.condition ? + //: comment, bbb, true + QObject::tr("ternary, bbb, true") : + //: comment, bbb, false + QObject::tr("ternary, bbb, false"); +} + +class TernaryClass : public QObject +{ + Q_OBJECT + + void f() + { + const auto ccc = + obj.condition ? + //: comment, ccc, true + tr("ternary, ccc, true") : + tr("ternary, ccc, false"); + + const auto ddd = + obj.condition ? + //: comment, ddd, true + tr("ternary, ddd, true") : + //: comment, ddd, false + tr("ternary, ddd, false"); + } +}; diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index be393f9d7..b847f8f89 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -280,6 +280,29 @@ backslashed \ stuff.</source> <translation type="unfinished"></translation> </message> <message> + <location filename="main.cpp" line="460"/> + <source>ternary, true, aaa</source> + <extracomment>comment, aaa, true</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="461"/> + <source>ternary, failure, aaa</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="466"/> + <source>ternary, bbb, true</source> + <extracomment>comment, bbb, true</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="468"/> + <source>ternary, bbb, false</source> + <extracomment>comment, bbb, false</extracomment> + <translation type="unfinished"></translation> + </message> + <message> <location filename="included.cpp" line="34"/> <source>message from #included .cpp file</source> <translation type="unfinished"></translation> @@ -332,6 +355,32 @@ backslashed \ stuff.</source> </message> </context> <context> + <name>TernaryClass</name> + <message> + <location filename="main.cpp" line="480"/> + <source>ternary, ccc, true</source> + <extracomment>comment, ccc, true</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="481"/> + <source>ternary, ccc, false</source> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="486"/> + <source>ternary, ddd, true</source> + <extracomment>comment, ddd, true</extracomment> + <translation type="unfinished"></translation> + </message> + <message> + <location filename="main.cpp" line="488"/> + <source>ternary, ddd, false</source> + <extracomment>comment, ddd, false</extracomment> + <translation type="unfinished"></translation> + </message> +</context> +<context> <name>TestClass</name> <message> <location filename="main.cpp" line="149"/> |