From f927eb52f0bcb8d326dbb35250878fcf1d798cf6 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Fri, 8 Mar 2013 18:48:56 +0100 Subject: [PATCH] fix translation contexts the bootstrapped library now fakes the translation api sufficiently well to enable unifying the usage. Change-Id: I6a5d7cb1bb67830f1ea0a732566ebee354d62e7e Reviewed-by: hjk --- src/linguist/lupdate/main.cpp | 2 +- src/linguist/shared/po.cpp | 4 ++-- src/linguist/shared/qm.cpp | 2 +- src/linguist/shared/qph.cpp | 2 +- src/linguist/shared/translator.cpp | 10 ---------- src/linguist/shared/translator.h | 14 +++----------- src/linguist/shared/ts.cpp | 2 +- src/linguist/shared/xliff.cpp | 2 +- 8 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/linguist/lupdate/main.cpp b/src/linguist/lupdate/main.cpp index 56078a5..2d15901 100644 --- a/src/linguist/lupdate/main.cpp +++ b/src/linguist/lupdate/main.cpp @@ -624,7 +624,7 @@ int main(int argc, char **argv) options |= NoSort; continue; } else if (arg == QLatin1String("-version")) { - printOut(QObject::tr("lupdate version %1\n").arg(QLatin1String(QT_VERSION_STR))); + printOut(LU::tr("lupdate version %1\n").arg(QLatin1String(QT_VERSION_STR))); return 0; } else if (arg == QLatin1String("-ts")) { metTsFlag = true; diff --git a/src/linguist/shared/po.cpp b/src/linguist/shared/po.cpp index 2f51e1c..3cf3a72 100644 --- a/src/linguist/shared/po.cpp +++ b/src/linguist/shared/po.cpp @@ -878,14 +878,14 @@ int initPO() { Translator::FileFormat format; format.extension = QLatin1String("po"); - format.description = QObject::tr("GNU Gettext localization files"); + format.description = FMT::tr("GNU Gettext localization files"); format.loader = &loadPO; format.saver = &savePO; format.fileType = Translator::FileFormat::TranslationSource; format.priority = 1; Translator::registerFileFormat(format); format.extension = QLatin1String("pot"); - format.description = QObject::tr("GNU Gettext localization template files"); + format.description = FMT::tr("GNU Gettext localization template files"); format.loader = &loadPO; format.saver = &savePOT; format.fileType = Translator::FileFormat::TranslationSource; diff --git a/src/linguist/shared/qm.cpp b/src/linguist/shared/qm.cpp index 418c12e..4b6cfdb 100644 --- a/src/linguist/shared/qm.cpp +++ b/src/linguist/shared/qm.cpp @@ -733,7 +733,7 @@ int initQM() Translator::FileFormat format; format.extension = QLatin1String("qm"); - format.description = QObject::tr("Compiled Qt translations"); + format.description = FMT::tr("Compiled Qt translations"); format.fileType = Translator::FileFormat::TranslationBinary; format.priority = 0; format.loader = &loadQM; diff --git a/src/linguist/shared/qph.cpp b/src/linguist/shared/qph.cpp index 6f25417..ac80f19 100644 --- a/src/linguist/shared/qph.cpp +++ b/src/linguist/shared/qph.cpp @@ -191,7 +191,7 @@ int initQPH() Translator::FileFormat format; format.extension = QLatin1String("qph"); - format.description = QObject::tr("Qt Linguist 'Phrase Book'"); + format.description = FMT::tr("Qt Linguist 'Phrase Book'"); format.fileType = Translator::FileFormat::TranslationSource; format.priority = 0; format.loader = &loadQPH; diff --git a/src/linguist/shared/translator.cpp b/src/linguist/shared/translator.cpp index a722ad7..e3295e8 100644 --- a/src/linguist/shared/translator.cpp +++ b/src/linguist/shared/translator.cpp @@ -66,16 +66,6 @@ QT_BEGIN_NAMESPACE -#ifdef QT_BOOTSTRAPPED -QString QObject::tr(const char *sourceText, const char *, int n) -{ - QString ret = QString::fromLatin1(sourceText); - if (n >= 0) - ret.replace(QLatin1String("%n"), QString::number(n)); - return ret; -} -#endif - Translator::Translator() : m_locationsType(AbsoluteLocations), m_indexOk(true) diff --git a/src/linguist/shared/translator.h b/src/linguist/shared/translator.h index 17dc3d5..e0820b0 100644 --- a/src/linguist/shared/translator.h +++ b/src/linguist/shared/translator.h @@ -44,6 +44,7 @@ #include "translatormessage.h" +#include #include #include #include @@ -54,18 +55,9 @@ QT_BEGIN_NAMESPACE -#ifdef QT_BOOTSTRAPPED -class QObject { -public: - static QString tr(const char *sourceText, const char * = 0, int n = -1); -}; -class QCoreApplication : public QObject { -public: - static QString translate(const char *, const char *sourceText, const char * = 0, - int n = -1) - { return tr(sourceText, 0, n); } +class FMT { + Q_DECLARE_TR_FUNCTIONS(Linguist) }; -#endif class QIODevice; diff --git a/src/linguist/shared/ts.cpp b/src/linguist/shared/ts.cpp index 38e76f9..2c8840d 100644 --- a/src/linguist/shared/ts.cpp +++ b/src/linguist/shared/ts.cpp @@ -691,7 +691,7 @@ int initTS() format.extension = QLatin1String("ts"); format.fileType = Translator::FileFormat::TranslationSource; format.priority = 0; - format.description = QObject::tr("Qt translation sources"); + format.description = FMT::tr("Qt translation sources"); format.loader = &loadTS; format.saver = &saveTS; Translator::registerFileFormat(format); diff --git a/src/linguist/shared/xliff.cpp b/src/linguist/shared/xliff.cpp index b66fa89..a29c7ba 100644 --- a/src/linguist/shared/xliff.cpp +++ b/src/linguist/shared/xliff.cpp @@ -837,7 +837,7 @@ int initXLIFF() { Translator::FileFormat format; format.extension = QLatin1String("xlf"); - format.description = QObject::tr("XLIFF localization files"); + format.description = FMT::tr("XLIFF localization files"); format.fileType = Translator::FileFormat::TranslationSource; format.priority = 1; format.loader = &loadXLIFF; -- 2.7.4