summaryrefslogtreecommitdiff
path: root/tests/auto/linguist/lupdate/testdata/good/parsejs4
diff options
context:
space:
mode:
authorRoberto Raggi <roberto.raggi@nokia.com>2011-12-07 10:24:01 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-13 08:47:04 +0100
commit1d1fbec4a2fcfde4e3e5c20c4ff6b679385773fd (patch)
tree5d372f03f4d7ab37512e595dc48695da2ff314c7 /tests/auto/linguist/lupdate/testdata/good/parsejs4
parent18ee2e8b52832dedfdc1ef6de14977c9e543e024 (diff)
downloadqttools-1d1fbec4a2fcfde4e3e5c20c4ff6b679385773fd.tar.gz
Improve lupdate
Merge the QML and the Javascript front-ends. Also, change the way we process directives in QML/JS comments. The old code was processing all the directives before visiting the AST nodes. Unfortunately, this doesn't play nice with TRANSLATOR-like directives. Added support for translating extended Javascript files. That is, QML/JS extends Javascript with pragma directives (e.g. .pragma). We emulate the `real' QML engine and we simply remove the pragmas from the original source code. Change-Id: Ie2536b10199a587b97f41c5e0560acabae981807 Sanity-Review: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'tests/auto/linguist/lupdate/testdata/good/parsejs4')
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs4/expectedoutput.txt29
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs4/main.js98
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs4/project.pro3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parsejs4/project.ts.result30
4 files changed, 160 insertions, 0 deletions
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs4/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/parsejs4/expectedoutput.txt
new file mode 100644
index 000000000..4743949e6
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs4/expectedoutput.txt
@@ -0,0 +1,29 @@
+.*/lupdate/testdata/good/parsejs4/main.js:45: qsTranslate\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs4/main.js:46: qsTranslate\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs4/main.js:47: qsTranslate\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs4/main.js:48: qsTranslate\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs4/main.js:49: qsTranslate\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs4/main.js:51: QT_TRANSLATE_NOOP\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs4/main.js:52: QT_TRANSLATE_NOOP\(\) requires at least two arguments.
+.*/lupdate/testdata/good/parsejs4/main.js:53: QT_TRANSLATE_NOOP\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs4/main.js:54: QT_TRANSLATE_NOOP\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs4/main.js:55: QT_TRANSLATE_NOOP\(\): both arguments must be literal strings.
+.*/lupdate/testdata/good/parsejs4/main.js:57: qsTr\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs4/main.js:58: qsTr\(\): text to translate must be a literal string.
+.*/lupdate/testdata/good/parsejs4/main.js:60: QT_TR_NOOP\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs4/main.js:61: QT_TR_NOOP\(\): text to translate must be a literal string.
+.*/lupdate/testdata/good/parsejs4/main.js:63: qsTrId\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs4/main.js:64: qsTrId\(\): identifier must be a literal string.
+.*/lupdate/testdata/good/parsejs4/main.js:66: QT_TRID_NOOP\(\) requires at least one argument.
+.*/lupdate/testdata/good/parsejs4/main.js:67: QT_TRID_NOOP\(\): identifier must be a literal string.
+.*/lupdate/testdata/good/parsejs4/main.js:69: Unexpected character in meta string
+.*/lupdate/testdata/good/parsejs4/main.js:70: Unexpected character in meta string
+.*/lupdate/testdata/good/parsejs4/main.js:71: Unterminated meta string
+.*/lupdate/testdata/good/parsejs4/main.js:72: Unterminated meta string
+.*/lupdate/testdata/good/parsejs4/main.js:75: //% cannot be used with qsTranslate\(\). Ignoring
+.*/lupdate/testdata/good/parsejs4/main.js:77: //% cannot be used with QT_TRANSLATE_NOOP\(\). Ignoring
+.*/lupdate/testdata/good/parsejs4/main.js:79: //% cannot be used with qsTr\(\). Ignoring
+.*/lupdate/testdata/good/parsejs4/main.js:81: //% cannot be used with QT_TR_NOOP\(\). Ignoring
+.*/lupdate/testdata/good/parsejs4/main.js:84: Discarding unconsumed meta data
+.*/lupdate/testdata/good/parsejs4/main.js:86: Discarding unconsumed meta data
+.*/lupdate/testdata/good/parsejs4/main.js:88: Discarding unconsumed meta data
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs4/main.js b/tests/auto/linguist/lupdate/testdata/good/parsejs4/main.js
new file mode 100644
index 000000000..4059dfc4c
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs4/main.js
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+.pragma library
+.import QtQuick 2.0 as Quick2
+
+qsTranslate();
+qsTranslate(10);
+qsTranslate(10, 20);
+qsTranslate("10", 20);
+qsTranslate(10, "20");
+
+QT_TRANSLATE_NOOP();
+QT_TRANSLATE_NOOP(10);
+QT_TRANSLATE_NOOP(10, 20);
+QT_TRANSLATE_NOOP("10", 20);
+QT_TRANSLATE_NOOP(10, "20");
+
+qsTr();
+qsTr(10);
+
+QT_TR_NOOP();
+QT_TR_NOOP(10);
+
+qsTrId();
+qsTrId(10);
+
+QT_TRID_NOOP();
+QT_TRID_NOOP(10);
+
+//% This is wrong
+//% "This is not wrong" This is wrong
+//% "I forgot to close the meta string
+//% "Being evil \
+
+//% "Should cause a warning"
+qsTranslate("FooContext", "Hello");
+//% "Should cause a warning"
+QT_TRANSLATE_NOOP("FooContext", "World");
+//% "Should cause a warning"
+qsTr("Hello");
+//% "Should cause a warning"
+QT_TR_NOOP("World");
+
+//: This comment will be discarded.
+Math.sin(1);
+//= id_foobar
+Math.cos(2);
+//~ underflow False
+Math.tan(3);
+
+/*
+Not tested for now, because these should perhaps not cause
+translation entries to be generated at all; see QTBUG-11843.
+
+//= qtn_foo
+qsTrId("qtn_foo");
+//= qtn_bar
+QT_TRID_NOOP("qtn_bar");
+*/
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs4/project.pro b/tests/auto/linguist/lupdate/testdata/good/parsejs4/project.pro
new file mode 100644
index 000000000..d549039c4
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs4/project.pro
@@ -0,0 +1,3 @@
+SOURCES += main.js
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parsejs4/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsejs4/project.ts.result
new file mode 100644
index 000000000..83c6d3f12
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parsejs4/project.ts.result
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.0">
+<context>
+ <name>FooContext</name>
+ <message>
+ <location filename="main.js" line="75"/>
+ <source>Hello</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="77"/>
+ <source>World</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+<context>
+ <name>main</name>
+ <message>
+ <location filename="main.js" line="79"/>
+ <source>Hello</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message>
+ <location filename="main.js" line="81"/>
+ <source>World</source>
+ <translation type="unfinished"></translation>
+ </message>
+</context>
+</TS>