From e3a099032895e8722fd0c0250f35fd75972dd772 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Mon, 5 Sep 2011 14:30:52 +0300 Subject: Symbian: Detect app caption and pkg name translations by id attribute. To better support various localization tools, added an alternate way to detect application caption and package name translations in .ts files. Now in addition to specific source text the id attribute of the message element can be used to identify interesting translations. The ids qmake is looking for are: qtn_short_caption_ qtn_long_caption_ qtn_package_name_ qtn_smart_installer_package_name_ Task-number: QT-5247 Reviewed-by: Sami Merila --- qmake/generators/symbian/symbiancommon.cpp | 61 ++++++++++++++---------------- 1 file changed, 28 insertions(+), 33 deletions(-) diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index c9ffa11..c7d7560 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -953,10 +953,15 @@ bool SymbianCommonGenerator::parseTsContent(const QString &tsFilename, SymbianLo static QString messageElement = QLatin1String("message"); static QString sourceElement = QLatin1String("source"); static QString translationElement = QLatin1String("translation"); - static QString shortCaptionId = QLatin1String("Application short caption"); - static QString longCaptionId = QLatin1String("Application long caption"); - static QString pkgDisplayNameId = QLatin1String("Package name"); - static QString installerPkgDisplayNameId = QLatin1String("Smart installer package name"); + static QString idAttribute = QLatin1String("id"); + static QString shortCaptionId = QLatin1String("qtn_short_caption_"); + static QString longCaptionId = QLatin1String("qtn_long_caption_"); + static QString pkgDisplayNameId = QLatin1String("qtn_package_name_"); + static QString installerPkgDisplayNameId = QLatin1String("qtn_smart_installer_package_name_"); + static QString shortCaptionSource = QLatin1String("Application short caption"); + static QString longCaptionSource = QLatin1String("Application long caption"); + static QString pkgDisplayNameSource = QLatin1String("Package name"); + static QString installerPkgDisplayNameSource = QLatin1String("Smart installer package name"); static QString languageAttribute = QLatin1String("language"); static QChar underscoreChar = QLatin1Char('_'); @@ -991,6 +996,7 @@ bool SymbianCommonGenerator::parseTsContent(const QString &tsFilename, SymbianLo if (xml.name() == messageElement) { QString source; QString translation; + QString id = xml.attributes().value(idAttribute).toString(); while (xml.readNextStartElement()) { if (xml.name() == sourceElement) { source = xml.readElementText(); @@ -1005,35 +1011,24 @@ bool SymbianCommonGenerator::parseTsContent(const QString &tsFilename, SymbianLo xml.skipCurrentElement(); } } - - if (source == shortCaptionId) { - if (loc->shortCaption.isEmpty()) { - loc->shortCaption = translation; - } else { - fprintf(stderr, "Warning: Duplicate application short caption defined in (%s).\n", - qPrintable(tsFilename)); - } - } else if (source == longCaptionId) { - if (loc->longCaption.isEmpty()) { - loc->longCaption = translation; - } else { - fprintf(stderr, "Warning: Duplicate application long caption defined in (%s).\n", - qPrintable(tsFilename)); - } - } else if (source == pkgDisplayNameId) { - if (loc->pkgDisplayName.isEmpty()) { - loc->pkgDisplayName = translation; - } else { - fprintf(stderr, "Warning: Duplicate package display name defined in (%s).\n", - qPrintable(tsFilename)); - } - } else if (source == installerPkgDisplayNameId) { - if (loc->installerPkgDisplayName.isEmpty()) { - loc->installerPkgDisplayName = translation; - } else { - fprintf(stderr, "Warning: Duplicate smart installer package display name defined in (%s).\n", - qPrintable(tsFilename)); - } + // Interesting translations can be identified either by id attribute + // of the message or by the source text. + // Allow translations with correct id to override translations + // detected by source text, as the source text can accidentally + // be the same in another string if there are non-interesting + // translations added to same context. + if (id.startsWith(shortCaptionId) + || (loc->shortCaption.isEmpty() && source == shortCaptionSource)) { + loc->shortCaption = translation; + } else if (id.startsWith(longCaptionId) + || (loc->longCaption.isEmpty() && source == longCaptionSource)) { + loc->longCaption = translation; + } else if (id.startsWith(pkgDisplayNameId) + || (loc->pkgDisplayName.isEmpty() && source == pkgDisplayNameSource)) { + loc->pkgDisplayName = translation; + } else if (id.startsWith(installerPkgDisplayNameId) + || (loc->installerPkgDisplayName.isEmpty() && source == installerPkgDisplayNameSource)) { + loc->installerPkgDisplayName = translation; } } else { xml.skipCurrentElement(); -- cgit v0.12 From 890b99843f4e7bcbb010a64f87f191634b1b01ba Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 6 Sep 2011 10:02:54 +0300 Subject: Remove few unused variables. The languageAttribute and underscoreChar variables were not used in SymbianCommonGenerator::parseTsContent function, so removed them. Reviewed-by: TrustMe --- qmake/generators/symbian/symbiancommon.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/qmake/generators/symbian/symbiancommon.cpp b/qmake/generators/symbian/symbiancommon.cpp index c7d7560..2c4373a 100644 --- a/qmake/generators/symbian/symbiancommon.cpp +++ b/qmake/generators/symbian/symbiancommon.cpp @@ -962,8 +962,6 @@ bool SymbianCommonGenerator::parseTsContent(const QString &tsFilename, SymbianLo static QString longCaptionSource = QLatin1String("Application long caption"); static QString pkgDisplayNameSource = QLatin1String("Package name"); static QString installerPkgDisplayNameSource = QLatin1String("Smart installer package name"); - static QString languageAttribute = QLatin1String("language"); - static QChar underscoreChar = QLatin1Char('_'); enum CurrentContext { ContextUnknown, -- cgit v0.12 From 58d0e747348eb89723abd515d864da5316cba760 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Tue, 6 Sep 2011 16:17:24 +0300 Subject: Fix qt.conf for Symbian to use $${EPOCROOT} $(EPOCROOT) in qt.conf resolves epocroot from environment variable, which is wrong when doing full platform build and qmake is executed in context of sbsv2 tools build. The correct way to resolve epocroot in qt.conf is to use $${EPOCROOT}. Reviewed-by: TrustMe --- config.profiles/symbian/qt.conf | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config.profiles/symbian/qt.conf b/config.profiles/symbian/qt.conf index 29dfa88..072fd7b 100644 --- a/config.profiles/symbian/qt.conf +++ b/config.profiles/symbian/qt.conf @@ -1,6 +1,6 @@ [Paths] -Data = $(EPOCROOT)epoc32/tools/qt -Headers = $(EPOCROOT)epoc32/include/mw -Binaries = $(EPOCROOT)epoc32/tools -Prefix = $(EPOCROOT)sf/mw/qt +Data = $${EPOCROOT}epoc32/tools/qt +Headers = $${EPOCROOT}epoc32/include/mw +Binaries = $${EPOCROOT}epoc32/tools +Prefix = $${EPOCROOT}sf/mw/qt -- cgit v0.12