summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/linguist/lupdate/ui.cpp12
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.pro3
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.ts.result17
-rw-r--r--tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.ui59
4 files changed, 90 insertions, 1 deletions
diff --git a/src/linguist/lupdate/ui.cpp b/src/linguist/lupdate/ui.cpp
index c60bc411d..417f32cc6 100644
--- a/src/linguist/lupdate/ui.cpp
+++ b/src/linguist/lupdate/ui.cpp
@@ -52,7 +52,7 @@ class UiReader : public QXmlDefaultHandler
public:
UiReader(Translator &translator, ConversionData &cd)
: m_translator(translator), m_cd(cd), m_lineNumber(-1), m_isTrString(false),
- m_insideStringList(false)
+ m_insideStringList(false), m_idBasedTranslations(false)
{}
bool startElement(const QString &namespaceURI, const QString &localName,
@@ -74,12 +74,14 @@ private:
QString m_source;
QString m_comment;
QString m_extracomment;
+ QString m_id;
QXmlLocator *m_locator;
QString m_accum;
int m_lineNumber;
bool m_isTrString;
bool m_insideStringList;
+ bool m_idBasedTranslations;
};
bool UiReader::startElement(const QString &namespaceURI,
@@ -96,6 +98,10 @@ bool UiReader::startElement(const QString &namespaceURI,
flush();
m_insideStringList = true;
readTranslationAttributes(atts);
+ } else if (qName == QLatin1String("ui")) { // UI "header"
+ const int translationTypeIndex = atts.index(QStringLiteral("idbasedtr"));
+ m_idBasedTranslations = translationTypeIndex >= 0
+ && atts.value(translationTypeIndex) == QLatin1String("true");
}
m_accum.clear();
return true;
@@ -147,12 +153,14 @@ void UiReader::flush()
m_comment, QString(), m_cd.m_sourceFileName,
m_lineNumber, QStringList());
msg.setExtraComment(m_extracomment);
+ msg.setId(m_id);
m_translator.extend(msg, m_cd);
}
m_source.clear();
if (!m_insideStringList) {
m_comment.clear();
m_extracomment.clear();
+ m_id.clear();
}
}
@@ -163,6 +171,8 @@ void UiReader::readTranslationAttributes(const QXmlAttributes &atts)
m_isTrString = true;
m_comment = atts.value(QStringLiteral("comment"));
m_extracomment = atts.value(QStringLiteral("extracomment"));
+ if (m_idBasedTranslations)
+ m_id = atts.value(QStringLiteral("id"));
if (!m_cd.m_noUiLines)
m_lineNumber = m_locator->lineNumber();
} else {
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.pro b/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.pro
new file mode 100644
index 000000000..fa56972dd
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.pro
@@ -0,0 +1,3 @@
+FORMS += project.ui
+
+TRANSLATIONS = project.ts
diff --git a/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.ts.result
new file mode 100644
index 000000000..989aabcbb
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.ts.result
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE TS>
+<TS version="2.1">
+<context>
+ <name>FindDialog</name>
+ <message id="windowTitleId">
+ <location filename="project.ui" line="42"/>
+ <source>Qt Assistant - Finn text</source>
+ <translation type="unfinished"></translation>
+ </message>
+ <message id="heightId">
+ <location filename="project.ui" line="45"/>
+ <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/parseidbasedui/project.ui b/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.ui
new file mode 100644
index 000000000..684033ddb
--- /dev/null
+++ b/tests/auto/linguist/lupdate/testdata/good/parseidbasedui/project.ui
@@ -0,0 +1,59 @@
+<ui version="4.0" idbasedtr="true">
+ <author></author>
+<comment>*********************************************************************
+**
+** Copyright (C) 2017 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:GPL-EXCEPT$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3 as published by the Free Software
+** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+*********************************************************************</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 id="windowTitleId">Qt Assistant - Finn text</string>
+ </property>
+ <property name="height" >
+ <string id="heightId">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>