summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2010-11-22 14:40:25 (GMT)
committerKent Hansen <kent.hansen@nokia.com>2010-11-22 15:46:11 (GMT)
commit9e06896a9a49685dc97eb2aafdf55eef33a75507 (patch)
treef05201cea09f1885769362c25578f7da78541ee0 /tests
parentdc957655b6f5641a7b207ec304ce29e246e17000 (diff)
downloadQt-9e06896a9a49685dc97eb2aafdf55eef33a75507.zip
Qt-9e06896a9a49685dc97eb2aafdf55eef33a75507.tar.gz
Qt-9e06896a9a49685dc97eb2aafdf55eef33a75507.tar.bz2
Make lupdate recognize TRANSLATOR comments in QtScript files
- Made the output translator a member of the parser, since the processComment() callback needs it now. - Made the context for tr()/TR_NOOP() a member of the parser, since it should persist for subsequent tr calls. - The comment processing logic should match that of cpp.cpp, as usual. Task-number: QTBUG-15502 Reviewed-by: Oswald Buddenhagen
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejscontexts/main.js29
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.pro3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.ts.result81
3 files changed, 113 insertions, 0 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/main.js b/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/main.js
new file mode 100644
index 0000000..aa510c1
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/main.js
@@ -0,0 +1,29 @@
+// No context specified, default should be used.
+qsTr("One");
+QT_TR_NOOP("Two");
+
+// TRANSLATOR Foo
+qsTr("Three");
+QT_TR_NOOP("Four");
+
+// TRANSLATOR Bar
+qsTr("Five");
+
+/*
+ TRANSLATOR Baz
+ This is a comment to the translator.
+*/
+QT_TR_NOOP("Six");
+
+// TRANSLATOR Foo.Bar
+qsTr("Seven");
+
+/* TRANSLATOR Bar::Baz */
+QT_TR_NOOP("Eight");
+
+// qsTranslate() context is not affected.
+qsTranslate("Foo", "Nine");
+
+// Empty context.
+// TRANSLATOR
+qsTr("Ten");
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.pro
new file mode 100644
index 0000000..d549039
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.pro
@@ -0,0 +1,3 @@
+SOURCES += main.js
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.ts.result
new file mode 100644
index 0000000..18407b2
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejscontexts/project.ts.result
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name></name>
+ <message>
+ <location filename="main.js" line="29"/>
+ <source>Ten</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Bar</name>
+ <message>
+ <location filename="main.js" line="10"/>
+ <source>Five</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Bar::Baz</name>
+ <message>
+ <location filename="main.js" line="22"/>
+ <source>Eight</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Baz</name>
+ <message>
+ <location filename="main.js" line="12"/>
+ <source></source>
+ <comment>This is a comment to the translator.</comment>
+ <translation></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="16"/>
+ <source>Six</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Foo</name>
+ <message>
+ <location filename="main.js" line="6"/>
+ <source>Three</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="7"/>
+ <source>Four</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="25"/>
+ <source>Nine</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>Foo.Bar</name>
+ <message>
+ <location filename="main.js" line="19"/>
+ <source>Seven</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>main</name>
+ <message>
+ <location filename="main.js" line="2"/>
+ <source>One</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="3"/>
+ <source>Two</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>