diff --git a/autotests/klocalizedstringtest.cpp b/autotests/klocalizedstringtest.cpp index 82dd05d..ee80209 100644 --- a/autotests/klocalizedstringtest.cpp +++ b/autotests/klocalizedstringtest.cpp @@ -1,550 +1,550 @@ // krazy:excludeall=i18ncheckarg /* This file is part of the KDE libraries Copyright (C) 2006 Chusslove Illich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ // Tests explicitly use their own test catalogs. #undef TRANSLATION_DOMAIN #include "klocalizedstringtest.h" #include "klocalizedtranslator.h" #include #include -#include +#include #include #include -#include -#include +#include +#include void KLocalizedStringTest::initTestCase() { KLocalizedString::setApplicationDomain("ki18n-test"); m_hasFrench = true; if (m_hasFrench) { setlocale(LC_ALL, "fr_FR.utf8"); if (setlocale(LC_ALL, nullptr) != QByteArray("fr_FR.utf8")) { qDebug() << "Failed to set locale to fr_FR.utf8."; m_hasFrench = false; } } if (m_hasFrench) { if (!m_tempDir.isValid()) { qDebug() << "Failed to create temporary directory for test data."; m_hasFrench = false; } } QDir dataDir(m_tempDir.path()); if (m_hasFrench) { m_hasFrench = compileCatalogs({QFINDTESTDATA("po/fr/ki18n-test.po"), QFINDTESTDATA("po/fr/ki18n-test-qt.po")}, dataDir); } if (m_hasFrench) { qputenv("XDG_DATA_DIRS", qgetenv("XDG_DATA_DIRS") + ":" + QFile::encodeName(dataDir.path())); // bind... dataDir.path() QStringList languages; languages.append("fr"); KLocalizedString::setLanguages(languages); } #if 0 // until locale system is ready if (m_hasFrench) { KLocale::global()->setLanguage(QStringList() << "fr" << "en_US"); } KLocale::global()->setThousandsSeparator(QLatin1String(",")); KLocale::global()->setDecimalSymbol(QLatin1String(".")); #endif } bool KLocalizedStringTest::compileCatalogs(const QStringList &testPoPaths, const QDir &dataDir) { if (!dataDir.mkpath("locale/fr/LC_MESSAGES")) { qDebug() << "Failed to create locale subdirectory " "inside temporary directory."; return false; } QString msgfmt = QStandardPaths::findExecutable(QLatin1String("msgfmt")); if (msgfmt.isEmpty()) { qDebug() << "msgfmt(1) not found in path."; return false; } foreach (const QString &testPoPath, testPoPaths) { int pos_1 = testPoPath.lastIndexOf(QLatin1Char('/')); int pos_2 = testPoPath.lastIndexOf(QLatin1Char('.')); QString domain = testPoPath.mid(pos_1 + 1, pos_2 - pos_1 - 1); QString testMoPath; testMoPath = QString::fromLatin1("%1/locale/fr/LC_MESSAGES/%2.mo") .arg(dataDir.path(), domain); QProcess process; QStringList arguments; arguments << testPoPath << QLatin1String("-o") << testMoPath; process.start(msgfmt, arguments); process.waitForFinished(10000); if (process.exitCode() != 0) { qDebug() << QString::fromLatin1("msgfmt(1) could not compile %1.") .arg(testPoPath); return false; } } return true; } void KLocalizedStringTest::correctSubs() { // Warm up. QCOMPARE(i18n("Daisies, daisies"), QString("Daisies, daisies")); // Placeholder in the middle. QCOMPARE(i18n("Fault in %1 unit", QString("AE35")), QString("Fault in AE35 unit")); // Placeholder at the start. QCOMPARE(i18n("%1, Tycho Magnetic Anomaly 1", QString("TMA-1")), QString("TMA-1, Tycho Magnetic Anomaly 1")); // Placeholder at the end. QCOMPARE(i18n("...odd things happening at %1", QString("Clavius")), QString("...odd things happening at Clavius")); QCOMPARE(i18n("Group %1", 1), QString("Group 1")); // Two placeholders. QCOMPARE(i18n("%1 and %2", QString("Bowman"), QString("Poole")), QString("Bowman and Poole")); // Two placeholders in inverted order. QCOMPARE(i18n("%2 and %1", QString("Poole"), QString("Bowman")), QString("Bowman and Poole")); // % which is not of placeholder. QCOMPARE(i18n("It's going to go %1% failure in 72 hours.", 100), QString("It's going to go 100% failure in 72 hours.")); // Usual plural. QCOMPARE(i18np("%1 pod", "%1 pods", 1), QString("1 pod")); QCOMPARE(i18np("%1 pod", "%1 pods", 10), QString("10 pods")); // No plural-number in singular. QCOMPARE(i18np("A pod", "%1 pods", 1), QString("A pod")); QCOMPARE(i18np("A pod", "%1 pods", 10), QString("10 pods")); // No plural-number in singular or plural. QCOMPARE(i18np("A pod", "Few pods", 1), QString("A pod")); QCOMPARE(i18np("A pod", "Few pods", 10), QString("Few pods")); // First of two arguments as plural-number. QCOMPARE(i18np("A pod left on %2", "%1 pods left on %2", 1, QString("Discovery")), QString("A pod left on Discovery")); QCOMPARE(i18np("A pod left on %2", "%1 pods left on %2", 2, QString("Discovery")), QString("2 pods left on Discovery")); // Second of two arguments as plural-number. QCOMPARE(i18np("%1 has a pod left", "%1 has %2 pods left", QString("Discovery"), 1), QString("Discovery has a pod left")); QCOMPARE(i18np("%1 has a pod left", "%1 has %2 pods left", QString("Discovery"), 2), QString("Discovery has 2 pods left")); // No plural-number in singular or plural, but another argument present. QCOMPARE(i18np("A pod left on %2", "Some pods left on %2", 1, QString("Discovery")), QString("A pod left on Discovery")); QCOMPARE(i18np("A pod left on %2", "Some pods left on %2", 2, QString("Discovery")), QString("Some pods left on Discovery")); // Visual formatting. // FIXME: Needs much more tests. QCOMPARE(xi18n("E = mc^2"), QString("E = mc^2")); QCOMPARE(xi18n("E < mc^2"), QString("E < mc^2")); QCOMPARE(xi18n("E ? mc^2"), QString("E ? *mc^2*")); QCOMPARE(xi18n("E < mc^2"), QString("E < *mc^2*")); QCOMPARE(xi18nc("@label", "E < mc^2"), QString("E < *mc^2*")); QCOMPARE(xi18nc("@info", "E < mc^2"), QString("E < mc^2")); QCOMPARE(xi18n("E = mc^2"), QString("E = mc^2")); QCOMPARE(xi18n("E = mc^2"), QString("E = mc^2")); // Number formatting. QCOMPARE(ki18n("%1").subs(42).toString(), QString("42")); QCOMPARE(ki18n("%1").subs(42, 5).toString(), QString(" 42")); QCOMPARE(ki18n("%1").subs(42, -5, 10, QChar('_')).toString(), QString("42___")); QCOMPARE(ki18n("%1").subs(4.2, 5, 'f', 2).toString(), QString(" 4.20")); } void KLocalizedStringTest::wrongSubs() { #ifndef NDEBUG // Too many arguments. QVERIFY(i18n("Europa", 1) != QString("Europa")); // Too few arguments. QVERIFY(i18n("%1, %2 and %3", QString("Hunter"), QString("Kimball")) != QString("Hunter, Kimball and %3")); // Gaps in placheholder numbering. QVERIFY(ki18n("Beyond the %2").subs("infinity").toString() != QString("Beyond the infinity")); // Plural argument not supplied. QVERIFY(ki18np("1 pod", "%1 pods").toString() != QString("1 pod")); QVERIFY(ki18np("1 pod", "%1 pods").toString() != QString("%1 pods")); #endif } void KLocalizedStringTest::semanticTags() { KLocalizedString::setLanguages({"en"}); // QCOMPARE(xi18nc("@action:inmenu", "Open with %1", "Okteta"), QString("Open with Okteta")); QCOMPARE(xi18nc("@info", "Open with %1", "Okteta"), QString("Open with Okteta")); // QCOMPARE(xi18nc("@info:whatsthis", "You can try the following snippet:" "\\begin{equation}\n" " C_{x_i} = \\frac{C_z^2}{e \\pi \\lambda}\n" "\\end{equation}" ""), QString("You can try the following snippet:\n\n
"
                     "\\begin{equation}\n"
                     "  C_{x_i} = \\frac{C_z^2}{e \\pi \\lambda}\n"
                     "\\end{equation}"
                     "
")); // QCOMPARE(xi18nc("@info", "This will call %1 internally.", "true"), QString("This will call true internally.")); QCOMPARE(xi18nc("@info", "Consult man entry for %1", "true", 1), QString("Consult man entry for true(1)")); // QCOMPARE(xi18nc("@info", "Send bug reports to %1.", "konqi@kde.org"), QString("Send bug reports to <konqi@kde.org>.")); QCOMPARE(xi18nc("@info", "Send praises to %2.", "konqi@kde.org", "Konqi"), QString("Send praises to Konqi.")); // QCOMPARE(xi18nc("@info:progress", "Checking feedback circuits..."), QString("Checking *feedback* circuits...")); QCOMPARE(xi18nc("@info:progress", "Checking feedback circuits..."), QString("Checking **feedback** circuits...")); // QCOMPARE(xi18nc("@info", "Assure that your PATH is properly set."), QString("Assure that your $PATH is properly set.")); // QCOMPARE(xi18nc("@info", "Cannot read %1.", "data.dat"), QString("Cannot read data.dat.")); // TODO: is nested really wanted? #ifndef Q_OS_WIN QString homeFooRc("$HOME/.foorc does not exist."); #else //TODO $HOME -> %HOME% ? QString homeFooRc("$HOME\\.foorc does not exist."); #endif QCOMPARE(xi18nc("@info", "HOME/.foorc does not exist."), homeFooRc); // QCOMPARE(xi18nc("@info:tooltip", "Execute svn merge on selected revisions."), QString("Execute svn merge on selected revisions.")); // QCOMPARE(xi18nc("@info:whatsthis", "If you make a mistake, click Reset to start again."), QString("If you make a mistake, click Reset to start again.")); QCOMPARE(xi18nc("@info:whatsthis", "The line colors can be changed under Settings->Visuals."), QString("The line colors can be changed under Settings->Visuals.")); // QCOMPARE(xi18nc("@info:tooltip", "Go to %1 website.", "http://kde.org/"), QString("Go to http://kde.org/ website.")); QCOMPARE(xi18nc("@info:tooltip", "Go to %2.", "http://kde.org/", "the KDE website"), QString("Go to the KDE website.")); // QCOMPARE(xi18nc("@info", "The fortune cookie says: %1", "Nothing"), QString("The fortune cookie says: Nothing")); // #ifndef Q_OS_WIN QString deleteEtcPasswd("Do you really want to delete:
/etc/passwd"); #else QString deleteEtcPasswd("Do you really want to delete:
\\etc\\passwd"); #endif QCOMPARE(xi18nc("@info", "Do you really want to delete:%1", "/etc/passwd"), deleteEtcPasswd); //check within filename doesn't break (Windows path separators) #ifndef Q_OS_WIN QString filenameWithNewline("/filename/with
/newline
"); #else QString filenameWithNewline("\\filename\\with
\\newline
"); #endif QCOMPARE(xi18nc("@info", "/filename/with/newline"), filenameWithNewline); // QEXPECT_FAIL("", "what happened to ? TODO.", Continue); QCOMPARE(xi18nc("@info:progress", "Connecting to %1...", 22), QString("Connecting to 22")); QCOMPARE(xi18nc("@info", "Replace name with your name."), QString("Replace <name> with your name.")); QCOMPARE(xi18nc("@item:inlistbox", "All images"), QString("")); // QCOMPARE(xi18nc("@info", "Apply color scheme %1?", "XXX"), QString("Apply color scheme “XXX”?")); QCOMPARE(xi18nc("@info:whatsthis", "Cycle through layouts using Alt+Space."), QString("Cycle through layouts using Alt+Space.")); // QCOMPARE(xi18nc("@info", "Probably the best known of all duck species is the Mallard. " "It breeds throughout the temperate areas around the world. " "Most domestic ducks are derived from Mallard."), QString("Probably the best known of all duck species is the Mallard. " "It breeds throughout the temperate areas around the world. " "Note: Most domestic ducks are derived from Mallard.")); QCOMPARE(xi18nc("@info", "Most domestic ducks are derived from Mallard."), QString("Trivia: Most domestic ducks are derived from Mallard.")); // QCOMPARE(xi18nc("@info", "Really delete this key?" "This cannot be undone."), QString("Really delete this key?" "Warning: This cannot be undone.")); QCOMPARE(xi18nc("@info", "This cannot be undone."), QString("Danger: This cannot be undone.")); } void KLocalizedStringTest::removeAcceleratorMarker() { // No accelerator marker. QCOMPARE(KLocalizedString::removeAcceleratorMarker(QString()), QString()); QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo bar"), QString("Foo bar")); // Run of the mill. QCOMPARE(KLocalizedString::removeAcceleratorMarker("&Foo bar"), QString("Foo bar")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo &bar"), QString("Foo bar")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo b&ar"), QString("Foo bar")); // - presence of escaped ampersands QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo && Bar"), QString("Foo & Bar")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo && &Bar"), QString("Foo & Bar")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("&Foo && Bar"), QString("Foo & Bar")); // CJK-style markers. QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo bar (&F)"), QString("Foo bar")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("(&F) Foo bar"), QString("Foo bar")); // - interpunction after/before parenthesis still qualifies CJK marker QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo bar (&F):"), QString("Foo bar:")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo bar (&F)..."), QString("Foo bar...")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("...(&F) foo bar"), QString("...foo bar")); // - alphanumerics around parenthesis disqualify CJK marker QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo (&F) bar"), QString("Foo (F) bar")); // - something removed raw ampersands, leaving dangling reduced CJK markers. // Remove reduced markers only if CJK characters are found in the string. QCOMPARE(KLocalizedString::removeAcceleratorMarker(QString::fromUtf8("Foo bar (F)")), QString::fromUtf8("Foo bar (F)")); QCOMPARE(KLocalizedString::removeAcceleratorMarker(QString::fromUtf8("印刷(P)...")), QString::fromUtf8("印刷...")); // Shady cases, where ampersand is obviously not a marker // and should have been escaped, but it was not. QCOMPARE(KLocalizedString::removeAcceleratorMarker("&"), QString("&")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo bar &"), QString("Foo bar &")); QCOMPARE(KLocalizedString::removeAcceleratorMarker("Foo & Bar"), QString("Foo & Bar")); } void KLocalizedStringTest::miscMethods() { KLocalizedString k; QVERIFY(k.isEmpty()); if (m_hasFrench) { QSet availableLanguages; availableLanguages.insert("fr"); availableLanguages.insert("en_US"); QCOMPARE(KLocalizedString::availableApplicationTranslations(), availableLanguages); } } // Same as translateToFrench, but using libintl directly (bindtextdomain+dgettext). // Useful for debugging. This changes global state, though, so it's skipped by default. void KLocalizedStringTest::translateToFrenchLowlevel() { if (!m_hasFrench) { QSKIP("French test files not usable."); } QSKIP("Skipped by default to avoid changing global state."); // fr_FR locale was set by initTestCase already. if (QFile::exists("/usr/share/locale/fr/LC_MESSAGES/ki18n-test.mo")) { bindtextdomain("ki18n-test", "/usr/share/locale"); QCOMPARE(QString::fromUtf8(dgettext("ki18n-test", "Loadable modules")), QString::fromUtf8("Modules chargeables")); } } void KLocalizedStringTest::translateToFrench() { if (!m_hasFrench) { QSKIP("French test files not usable."); } QCOMPARE(i18n("Loadable modules"), QString::fromUtf8("Modules chargeables")); QCOMPARE(i18n("Job"), QString::fromUtf8("Tâche")); } void KLocalizedStringTest::translateQt() { KLocalizedString::insertQtDomain("ki18n-test-qt"); QString result = KLocalizedString::translateQt("QPrintPreviewDialog", "Landscape", nullptr, 0); // When we use the default language, translateQt returns an empty string. QString expected = m_hasFrench ? QString("Paysage") : QString(); QCOMPARE(result, expected); #if 0 // KLocalizedString no longer does anything with QTranslator, this needed? result = QCoreApplication::translate("QPrintPreviewDialog", "Landscape"); QString expected2 = m_hasFrench ? QString("Paysage") : QString("Landscape"); QCOMPARE(result, expected2); #endif #if 0 // translateRaw no longer public, this needed? // So let's use translateRaw instead for the threaded test QString lang; KLocale::global()->translateRaw("Landscape", &lang, &result); QCOMPARE(lang, m_hasFrench ? QString("fr") : QString("en_US")); QCOMPARE(result, m_hasFrench ? QString("Paysage") : QString("Landscape")); #endif KLocalizedString::removeQtDomain("ki18n-test-qt"); } void KLocalizedStringTest::testLocalizedTranslator() { if (!m_hasFrench) { QSKIP("French test files not usable."); } QScopedPointer translator(new KLocalizedTranslator()); QCoreApplication *app = QCoreApplication::instance(); app->installTranslator(translator.data()); // no translation domain and no context QCOMPARE(app->translate("foo", "Job"), QStringLiteral("Job")); // adding the translation domain still lacks the context translator->setTranslationDomain(QStringLiteral("ki18n-test")); QCOMPARE(app->translate("foo", "Job"), QStringLiteral("Job")); translator->addContextToMonitor(QStringLiteral("foo")); // now it should translate QCOMPARE(app->translate("foo", "Job"), QStringLiteral("Tâche")); // other context shouldn't translate QCOMPARE(app->translate("bar", "Job"), QStringLiteral("Job")); // with a mismatching disambiguation it shouldn't translate QCOMPARE(app->translate("foo", "Job", "bar"), QStringLiteral("Job")); } void KLocalizedStringTest::addCustomDomainPath() { if (!m_hasFrench) { QSKIP("French test files not usable."); } QTemporaryDir dir; compileCatalogs({QFINDTESTDATA("po/fr/ki18n-test2.po")}, dir.path()); KLocalizedString::addDomainLocaleDir("ki18n-test2", dir.path() + "/locale"); QSet expectedAvailableTranslations({"en_US", "fr"}); QCOMPARE(KLocalizedString::availableDomainTranslations("ki18n-test2"), expectedAvailableTranslations); QCOMPARE(i18nd("ki18n-test2", "Cheese"), QString::fromUtf8("Fromage")); } #include #include #include void KLocalizedStringTest::testThreads() { QThreadPool::globalInstance()->setMaxThreadCount(10); QFutureSynchronizer sync; sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::correctSubs)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::correctSubs)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::correctSubs)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::translateQt)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::translateQt)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::translateToFrench)); sync.waitForFinished(); QThreadPool::globalInstance()->setMaxThreadCount(1); // delete those threads } QTEST_MAIN(KLocalizedStringTest) diff --git a/autotests/klocalizedstringtest.h b/autotests/klocalizedstringtest.h index 7256c6d..df7eecb 100644 --- a/autotests/klocalizedstringtest.h +++ b/autotests/klocalizedstringtest.h @@ -1,50 +1,50 @@ /* This file is part of the KDE libraries Copyright (c) 2005 Thomas Braxton This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KLOCALIZEDSTRINGTEST_H #define KLOCALIZEDSTRINGTEST_H -#include -#include +#include +#include class KLocalizedStringTest : public QObject { Q_OBJECT private Q_SLOTS: void initTestCase(); void correctSubs(); void wrongSubs(); void removeAcceleratorMarker(); void miscMethods(); void translateToFrenchLowlevel(); void translateToFrench(); void translateQt(); void addCustomDomainPath(); void testThreads(); void testLocalizedTranslator(); void semanticTags(); private: bool m_hasFrench; QTemporaryDir m_tempDir; bool compileCatalogs(const QStringList &catalogs, const QDir &dataDir); }; #endif // KLOCALIZEDSTRINGTEST_H diff --git a/autotests/ktranscriptcleantest.cpp b/autotests/ktranscriptcleantest.cpp index a748afe..b6950f5 100644 --- a/autotests/ktranscriptcleantest.cpp +++ b/autotests/ktranscriptcleantest.cpp @@ -1,99 +1,99 @@ /* Copyright 2014 Kevin Krammer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include -#include +#include #include #include QTEST_MAIN(KTranscriptCleanTest) KTranscriptCleanTest::KTranscriptCleanTest() : m_transcript(nullptr) { } void KTranscriptCleanTest::init() { m_transcript = autotestCreateKTranscriptImp(); } void KTranscriptCleanTest::cleanup() { autotestDestroyKTranscriptImp(); m_transcript = nullptr; } void KTranscriptCleanTest::test_data() { QTest::addColumn("argv"); QTest::addColumn("fallsBack"); QTest::addColumn("expected"); // Example test case, replace with first clean-slate test QTest::newRow("test_basic") << (QVariantList() << "test_basic" << "foo") << false << "foo bar"; } void KTranscriptCleanTest::test() { QFETCH(QVariantList, argv); QFETCH(bool, fallsBack); QFETCH(QString, expected); QString language = "fr"; QString country = "fr"; QString msgctxt = "a-context"; QHash dynamicContext; dynamicContext.insert("origin", "neverwhere"); QString msgid = "source-text"; QStringList subs; subs << "10" << "qwyx"; QList values; values << 10 << "qwyx"; QString ordinaryTranslation = "translated-text"; QString testJs = QFINDTESTDATA("test.js"); QList modules; modules << (QStringList() << testJs << language); QString error; bool fallback; QString result = m_transcript->eval( argv, language, country, msgctxt, dynamicContext, msgid, subs, values, ordinaryTranslation, modules, error, fallback); if (!error.isEmpty()) { QFAIL(qPrintable(error)); } if (!fallsBack) { QVERIFY(!fallback); QCOMPARE(result, expected); } else { QVERIFY(fallback); } } diff --git a/autotests/ktranscripttest.cpp b/autotests/ktranscripttest.cpp index ccfc3af..45a5bbc 100644 --- a/autotests/ktranscripttest.cpp +++ b/autotests/ktranscripttest.cpp @@ -1,234 +1,234 @@ /* Copyright 2013 Aurélien Gâteau Copyright (C) 2014 Chusslove Illich Copyright (C) 2014 Kevin Krammer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) version 3, or any later version accepted by the membership of KDE e.V. (or its successor approved by the membership of KDE e.V.), which shall act as a proxy defined in Section 6 of version 3 of the license. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library. If not, see . */ #include "ktranscripttest.h" #include "testhelpers.h" -#include +#include #include #include QTEST_MAIN(KTranscriptTest) extern "C" { typedef KTranscript *(*InitFunc)(); } KTranscriptTest::KTranscriptTest() : m_transcript(nullptr) { } void KTranscriptTest::initTestCase() { QVERIFY2(deployTestConfig(), "Could not deploy test ktranscript.ini"); QString pluginPath = QStringLiteral(KTRANSCRIPT_PATH); QVERIFY2(QFile::exists(pluginPath), "Could not find ktranscript plugin"); m_library.setFileName(pluginPath); QVERIFY(m_library.load()); InitFunc initf = (InitFunc) m_library.resolve("load_transcript"); QVERIFY(initf); m_transcript = initf(); QVERIFY(m_transcript); } void KTranscriptTest::cleanupTestCase() { QVERIFY2(removeTestConfig(), "Could not remove test ktranscript.ini"); } void KTranscriptTest::test_data() { QTest::addColumn("argv"); QTest::addColumn("fallsBack"); QTest::addColumn("expected"); QTest::newRow("test_basic") << (QVariantList() << "test_basic" << "foo") << false << "foo bar"; QTest::newRow("test_unicode") << (QVariantList() << "test_unicode" << "čгσィ九") << false << "čгσィ九 фу"; QTest::newRow("test_hascall") << (QVariantList() << "test_hascall" << "test_basic") << false << "yes"; QTest::newRow("test_acall") << (QVariantList() << "test_acall" << "test_basic" << "qwyx") << false << "qwyx bar"; QTest::newRow("test_load") << (QVariantList() << "test_load") << false << "foo blurb"; QTest::newRow("test_fallback") << (QVariantList() << "test_fallback") << true << ""; QTest::newRow("test_msgid") << (QVariantList() << "test_msgid") << false << "source-text"; QTest::newRow("test_msgtrf") << (QVariantList() << "test_msgtrf") << false << "translated-text"; QTest::newRow("test_msgctxt") << (QVariantList() << "test_msgctxt") << false << "a-context"; QTest::newRow("test_msgkey") << (QVariantList() << "test_msgkey") << false << "a-context|source-text"; QTest::newRow("test_nsubs") << (QVariantList() << "test_nsubs") << false << "2"; QTest::newRow("test_subs") << (QVariantList() << "test_subs" << 1) << false << "qwyx"; QTest::newRow("test_vals") << (QVariantList() << "test_vals" << 0 << 5) << false << "50"; QTest::newRow("test_dynctxt") << (QVariantList() << "test_dynctxt" << "origin") << false << "neverwhere"; QTest::newRow("test_dbgputs") << (QVariantList() << "test_dbgputs") << false << "debugged"; QTest::newRow("test_warnputs") << (QVariantList() << "test_warnputs") << false << "warned"; QTest::newRow("test_setcallForall") << (QVariantList() << "test_setcallForall") << false << "done"; QTest::newRow("test_toUpperFirst") << (QVariantList() << "test_toUpperFirst" << "...123 foo") << false << "...123 Foo"; QTest::newRow("test_toUpperFirst_unicode") << (QVariantList() << "test_toUpperFirst" << "...123 фу") << false << "...123 Фу"; QTest::newRow("test_toLowerFirst") << (QVariantList() << "test_toLowerFirst" << "...123 FOO") << false << "...123 fOO"; QTest::newRow("test_loadProps") << (QVariantList() << "test_loadProps" << "cities") << false << "loaded"; QTest::newRow("test_getProp") << (QVariantList() << "test_getProp" << "cities" << "Athens" << "gen") << false << "Atine"; QTest::newRow("test_setProp") << (QVariantList() << "test_setProp" << "Oslo" << "dat" << "Oslou") << false << "Oslou"; QTest::newRow("test_normKey") << (QVariantList() << "test_normKey" << "Some &Thing") << false << "something"; QTest::newRow("test_getConfString") << (QVariantList() << "test_getConfString" << "StringKey") << false << "StringValue"; QTest::newRow("test_getConfStringWithDefault") << (QVariantList() << "test_getConfStringWithDefault" << "NoSuchKey" << "DefaultValue") << false << "DefaultValue"; QTest::newRow("test_getConfBool") << (QVariantList() << "test_getConfBool" << "BoolKey") << false << "true"; QTest::newRow("test_getConfBoolWithDefault") << (QVariantList() << "test_getConfBoolWithDefault" << "NoSuchKey" << true) << false << "true"; QTest::newRow("test_getConfNumber") << (QVariantList() << "test_getConfNumber" << "NumberKey") << false << "12345"; QTest::newRow("test_getConfNumberWithDefault") << (QVariantList() << "test_getConfNumberWithDefault" << "NoSuchKey" << 54321) << false << "54321"; } void KTranscriptTest::test() { QFETCH(QVariantList, argv); QFETCH(bool, fallsBack); QFETCH(QString, expected); QString language = "fr"; QString country = "fr"; QString msgctxt = "a-context"; QHash dynamicContext; dynamicContext.insert("origin", "neverwhere"); QString msgid = "source-text"; QStringList subs; subs << "10" << "qwyx"; QList values; values << 10 << "qwyx"; QString ordinaryTranslation = "translated-text"; QString testJs = QFINDTESTDATA("test.js"); QList modules; modules << (QStringList() << testJs << language); QString error; bool fallback; QString result = m_transcript->eval( argv, language, country, msgctxt, dynamicContext, msgid, subs, values, ordinaryTranslation, modules, error, fallback); if (!error.isEmpty()) { QFAIL(qPrintable(error)); } if (!fallsBack) { QVERIFY(!fallback); QCOMPARE(result, expected); } else { QVERIFY(fallback); } } diff --git a/autotests/testhelpers.cpp b/autotests/testhelpers.cpp index 11a0208..966ac45 100644 --- a/autotests/testhelpers.cpp +++ b/autotests/testhelpers.cpp @@ -1,75 +1,75 @@ /* This file is part of the KI18N Framework Copyright (C) 2014 Kevin Krammer This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "testhelpers.h" #include #include #include #include #include -#include +#include static const QString targetFileName = QStringLiteral("ktranscript.ini"); bool deployTestConfig() { QStandardPaths::setTestModeEnabled(true); QDir configDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); const QFileInfo targetFile = QFileInfo(configDir, targetFileName); if (!configDir.exists()) { if (!QDir::current().mkpath(configDir.absolutePath())) { qWarning() << "Failed to create config dir" << configDir.absolutePath(); return false; } } else if (targetFile.exists()) { if (!configDir.remove(targetFileName)) { qWarning() << "Failed to remove existing test config file" << targetFile.absoluteFilePath(); return false; } } QFile sourceFile(QFINDTESTDATA("ktranscript-test.ini")); if (!sourceFile.exists()) { qWarning() << "Could not locate test data file" << sourceFile.fileName(); return false; } if (!sourceFile.copy(targetFile.absoluteFilePath())) { qWarning() << "Failed to copy test config file" << sourceFile.fileName() << "to target location" << targetFile.absoluteFilePath(); return false; } return true; } bool removeTestConfig() { Q_ASSERT(QStandardPaths::isTestModeEnabled()); QDir configDir = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation); if (!configDir.exists()) { return true; } return configDir.remove(targetFileName); } diff --git a/src/kcatalog_p.h b/src/kcatalog_p.h index f061a19..b05eccc 100644 --- a/src/kcatalog_p.h +++ b/src/kcatalog_p.h @@ -1,134 +1,134 @@ /* This file is part of the KDE libraries Copyright (c) 2001 Hans Petter Bieker Copyright (c) 2012, 2013 Chusslove Illich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KCATALOG_H #define KCATALOG_H -#include -#include -#include +#include +#include +#include class KCatalogPrivate; /** * This class abstracts a Gettext message catalog. * It takes care of needed Gettext bindings. * * @see KLocalizedString * @internal */ class KCatalog { public: /** * Constructor. * * @param name translation domain * @param language translation language */ KCatalog(const QByteArray &domain, const QString &language); /** * Destructor. */ ~KCatalog(); /** * Get translation of the given message text. * * Do not pass empty message text. * * @param msgid message text * * @return translated message if found, QString() otherwise */ QString translate(const QByteArray &msgid) const; /** * Get translation of the given message text with given context. * * Do not pass empty message text. * * @param msgctxt message context * @param msgid message text * * @return translated message if found, QString() otherwise */ QString translate(const QByteArray &msgctxt, const QByteArray &msgid) const; /** * Get translation of given message with plural forms. * * Do not pass empty message text. * * @param msgid singular message text * @param msgid_plural plural message text * @param n number for which the plural form is needed * * @return translated message if found, QString() otherwise */ QString translate(const QByteArray &msgid, const QByteArray &msgid_plural, qulonglong n) const; /** * Get translation of given message with plural forms with given context. * * Do not pass empty message text. * * @param msgctxt message context * @param msgid singular message text * @param msgid_plural plural message text * @param n number for which the plural form is needed * * @return translated message if found, QString() otherwise */ QString translate(const QByteArray &msgctxt, const QByteArray &msgid, const QByteArray &msgid_plural, qulonglong n) const; /** * Find the locale directory for the given domain in the given language. * * @param domain translation domain * @param language language of the catalog * * @return the locale directory if found, QByteArray() otherwise. */ static QString catalogLocaleDir(const QByteArray &domain, const QString &language); /** * Find the all languages for which the translation catalog * of given domain exists. * * @param domain translation domain * * @return set of language codes */ static QSet availableCatalogLanguages(const QByteArray &domain); static void addDomainLocaleDir(const QByteArray &domain, const QString &path); private: Q_DISABLE_COPY(KCatalog) KCatalogPrivate *const d; }; #endif diff --git a/src/klocalizedstring.h b/src/klocalizedstring.h index d3d56ad..5186a1c 100644 --- a/src/klocalizedstring.h +++ b/src/klocalizedstring.h @@ -1,2024 +1,2024 @@ /* This file is part of the KDE libraries Copyright (C) 2006, 2013 Chusslove Illich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KLOCALIZEDSTRING_H #define KLOCALIZEDSTRING_H #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include class KLocalizedStringPrivate; /** * \file klocalizedstring.h */ #ifndef I18N_NOOP /** * Wrap string for extraction. * * See \ref i18n_noop for use cases. */ #define I18N_NOOP(text) text #endif #ifndef I18NC_NOOP /** * Wrap string with context for extraction. * * See \ref i18n_noop for use cases. */ #define I18NC_NOOP(context, text) context, text #endif #ifndef I18N_NOOP2 /** * Wrap string with context for extraction, discarding context. * * \deprecated Use \c I18NC_NOOP. */ #define I18N_NOOP2(context, text) text #endif #ifndef I18N_NOOP2_NOSTRIP /** * Wrap string with context for extraction. * * \deprecated Old name for \c I18NC_NOOP. */ #define I18N_NOOP2_NOSTRIP(context, text) context, text #endif /** * @class KLocalizedString klocalizedstring.h * * \short Class for producing and handling localized messages * * \c KLocalizedString handles translation and * argument substitution and formatting of user-visible text. * * \c KLocalizedString instances are usually not constructed directly, * but through one of the wrapper \c \*i18n\* calls. * * For detailed information on how to use KI18n functions please refer * to \ref prg_guide. */ class KI18N_EXPORT KLocalizedString { friend class KLocalizedStringPrivate; friend KLocalizedString KI18N_EXPORT ki18n(const char *text); friend KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text); friend KLocalizedString KI18N_EXPORT ki18np(const char *singular, const char *plural); friend KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural); friend KLocalizedString KI18N_EXPORT ki18nd(const char *domain, const char *text); friend KLocalizedString KI18N_EXPORT ki18ndc(const char *domain, const char *context, const char *text); friend KLocalizedString KI18N_EXPORT ki18ndp(const char *domain, const char *singular, const char *plural); friend KLocalizedString KI18N_EXPORT ki18ndcp(const char *domain, const char *context, const char *singular, const char *plural); friend KLocalizedString KI18N_EXPORT kxi18n(const char *text); friend KLocalizedString KI18N_EXPORT kxi18nc(const char *context, const char *text); friend KLocalizedString KI18N_EXPORT kxi18np(const char *singular, const char *plural); friend KLocalizedString KI18N_EXPORT kxi18ncp(const char *context, const char *singular, const char *plural); friend KLocalizedString KI18N_EXPORT kxi18nd(const char *domain, const char *text); friend KLocalizedString KI18N_EXPORT kxi18ndc(const char *domain, const char *context, const char *text); friend KLocalizedString KI18N_EXPORT kxi18ndp(const char *domain, const char *singular, const char *plural); friend KLocalizedString KI18N_EXPORT kxi18ndcp(const char *domain, const char *context, const char *singular, const char *plural); public: /** * Construct an empty message. * * Direct construction is used when another \c KLocalizedString instance, * obtained by one of \c ki18n\* calls, should later be assigned * to directly constructed instance. * Before the assignment happens, directly constructed instance * is not valid for finalization by \c toString methods. * * \see isEmpty */ explicit KLocalizedString(); /** * Copy constructor. */ KLocalizedString(const KLocalizedString &rhs); /** * Assignment operator. */ KLocalizedString &operator=(const KLocalizedString &rhs); /** * Destructor. */ ~KLocalizedString(); /** * Check whether the message is empty. * * The message is considered empty if the object was constructed * via the default constructor. * * Empty messages are not valid for finalization. * The behavior of calling \c toString on them is undefined. * In debug mode, an error mark may appear in the returned string. * * \return \c true if the message is empty, \c false otherwise */ bool isEmpty() const; /** * Finalize the translation. * * Creates translated \c QString, with placeholders substituted * by arguments given by \c KLocalizedString::subs methods. * Translated text is searched for and arguments are formatted * based on the global locale. * * If there was any mismatch between placeholders and arguments, * in debug mode the returned string may contain error marks. * * \return finalized translation */ Q_REQUIRED_RESULT QString toString() const; /** * Like \c toString, but look for translation only in given languages. * * Given languages override languages defined by the global locale, * and any languages set earlier using \c withLanguages. * If \p languages is empty, original message is returned. * * \param languages list of language codes (by decreasing priority) * \return finalized translation */ Q_REQUIRED_RESULT QString toString(const QStringList &languages) const; #if 0 // until locale system is ready /** * Like \c toString, but look for translation based on given locale. * * Given locale overrides any set earlier using \c withLocale. * If \p locale is \c NULL, original message is returned. * * \param locale the locale for which translations are made * \return finalized translation */ QString toString(const KLocale *locale) const; #endif /** * Like \c toString, but look for translation in the given domain. * * Given domain overrides any set earlier using \c withDomain. * * \param domain the translation domain * \return finalized translation */ Q_REQUIRED_RESULT QString toString(const char *domain) const; /** * Like \c toString, but resolve KUIT markup into given visual format. * * Given visual format overrides that implied by the context UI marker * or set earlier using \c withFormat. * If the message is not markup-aware, * this is same as \c toString without arguments. * * \param format the target visual format * \return finalized translation */ Q_REQUIRED_RESULT QString toString(Kuit::VisualFormat format) const; /** * Indicate to look for translation only in given languages. * * \param languages list of language codes (by decreasing priority) * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString withLanguages(const QStringList &languages) const; #if 0 // until locale system is ready /** * Indicate to look for translation based on given locale. * * \param locale the locale for which translations are made * \return updated \c KLocalizedString */ KLocalizedString withLocale(const KLocale *locale) const; #endif /** * Indicate to look for translation in the given domain. * * \param domain the translation domain * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString withDomain(const char *domain) const; /** * Indicate to resolve KUIT markup into given visual format. * * If the message is not markup-aware, this has no effect. * * \param format the target visual format * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString withFormat(Kuit::VisualFormat format) const; /** * Substitute an int argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param base the radix used to represent the number as a string. * Valid values range from 2 to 36 * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(int a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute an unsigned int argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param base the radix used to represent the number as a string. * Valid values range from 2 to 36 * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(uint a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute a long argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param base the radix used to represent the number as a string. * Valid values range from 2 to 36 * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(long a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute an unsigned long argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param base the radix used to represent the number as a string. * Valid values range from 2 to 36 * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(ulong a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute a long long argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param base the radix used to represent the number as a string. * Valid values range from 2 to 36 * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(qlonglong a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute an unsigned long long argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param base the radix used to represent the number as a string. * Valid values range from 2 to 36 * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(qulonglong a, int fieldWidth = 0, int base = 10, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute a double argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param format type of floating point formating, like in QString::arg * \param precision number of digits after the decimal separator * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(double a, int fieldWidth = 0, char format = 'g', int precision = -1, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute a \c QChar argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(QChar a, int fieldWidth = 0, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute a \c QString argument into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(const QString &a, int fieldWidth = 0, QChar fillChar = QLatin1Char(' ')) const; /** * Substitute another \c KLocalizedString into the message. * * \param a the argument * \param fieldWidth width of the formatted field, padded by spaces. * Positive value aligns right, negative aligns left * \param fillChar the character used to fill up the empty places when * field width is greater than argument width * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString subs(const KLocalizedString &a, int fieldWidth = 0, QChar fillChar = QLatin1Char(' ')) const; /** * Add dynamic context to the message. * * See \ref dyn_ctxt for use cases. * * \param key context key * \param value context value * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString inContext(const QString &key, const QString &value) const; /** * Relax matching between placeholders and arguments. * * Normally the placeholders should start from %1 and have no gaps, * and on finalization there must be exactly as many arguments * supplied through \c subs methods as there are unique plaecholders. * If this is not satisfied, in debug mode warnings are printed * and the finalized string may contain error marks. * * This method relaxes the placeholder-argument matching, * such that there must only be an argument available for * every present unique placeholder (taking placeholder numbers * to be 1-based indices into the argument list). * This can come useful in some situations. * * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString relaxSubs() const; /** * Do not resolve KUIT markup. * * If the message is markup-aware * (constructed by one of \c \*xi18n\* calls), * this function can be used to make it non-markup-aware. * This may be useful for debugging markup. * * \return updated \c KLocalizedString */ Q_REQUIRED_RESULT KLocalizedString ignoreMarkup() const; /** * Set the given domain as application's main domain. * * This function must be called in applications, in order to have * any translations at all. It should never be called in libraries. * This allows to check whether the application is translated * into a given language, so that if it is not, translations from * underlying libraries will not appear even if they are translated. * This prevents mixing of translated and untranslated text * in the user interface. * * This function should be called right after creating the instance * of QCoreApplication or one of its subclasses. At that time the locale * setup has been made, including what is hooked into the * QCoreApplication startup, like KXMLGUI's language switching support. * So the initialisation done by this function sees all the data it should. * * \param domain the translation domain of the application */ static void setApplicationDomain(const char *domain); /** * Get the application's main translation domain. * * Returns the domain set by \c setApplicationDomain. */ static QByteArray applicationDomain(); #if 0 // until locale system is ready /** * Set the locale for which translations will be made. * * Locale determines from which languages (and in which order) * to draw translations, formatting of number arguments, etc. * * \param locale the locale * \see setLanguages */ static void setLocale(const KLocale &locale); #endif /** * Get the languages for which translations will be made. * * Returned languages are ordered with decreasing priority. * * \return languages ordered list of language codes * \see setLanguages * \see clearLanguages * * \since 5.20.0 */ static QStringList languages(); /** * Set the languages for which translations will be made. * * This overrides the languages provided by the locale. * Languages should be ordered with decreasing priority. * * \param languages ordered list of language codes * \see setLocale * \see clearLanguages * \see languages */ static void setLanguages(const QStringList &languages); /** * Clear override languages. * * This clears the override languages, going back to those * provided by the locale. * * \see setLanguages * \see languages */ static void clearLanguages(); /** * Check whether the translation catalog file in the given language * for the set application translation domain exists. * * \param language the language code to check * \return \c true if the translation catalog for \p language exits, * \c false otherwise * \see setApplicationDomain */ static bool isApplicationTranslatedInto(const QString &language); /** * @since 5.0 * * Get the languages for which there exists the translation catalog file * for the set application translation domain. * * The application domain is set by \c setApplicationDomain. * If the application domain was not set, empty set is returned. * If the application domain was set, the language set will always * contain at least the source code language (en_US). * * \return set of language codes for existing translation catalogs * \see setApplicationDomain */ static QSet availableApplicationTranslations(); /** * @since 5.0 * * Get the languages for which a translation catalog file * for the passed translation domain exists. * * If the translation domain was not specified in the * domain parameter an empty set is returned. * * If the application domain was set, the language set will always * contain at least the source code language (en_US). * * \param domain query for translations of a specific domain, if an empty * QByteArray is passed, an empty set will be returned * * \return set of language codes for existing translation catalogs * \see setApplicationDomain * \see availableApplicationTranslations */ static QSet availableDomainTranslations(const QByteArray &domain); /* * Load locales for a domain from a specific location * This is useful for resources which have their translation files * outside of the usual $XDG_DATA_DIRS/locales location * * \param the domain to load resources from * \path the full file path to the locale directory */ static void addDomainLocaleDir(const QByteArray &domain, const QString &path); /** * Find a path to the localized file for the given original path. * * This is intended mainly for non-text resources (images, sounds, etc). * Text resources should be handled in more specific ways. * * Possible localized paths are checked in turn by priority of set * languages, in form of \/l10n/\/\, * where \ and \ are those of * the original path, and \ is the language code. * * \param filePath path to the original file * * \return path to the localized file if found, original path otherwise */ Q_REQUIRED_RESULT static QString localizedFilePath(const QString &filePath); /** * Remove accelerator marker from a UI text label. * * Accelerator marker is not always a plain ampersand (&), * so it is not enough to just remove it by \c QString::remove. * The label may contain escaped markers ("&&") which must be resolved * and skipped, as well as CJK-style markers ("Foo (&F)") where * the whole parenthesis construct should be removed. * Therefore always use this function to remove accelerator marker * from UI labels. * * \param label UI label which may contain an accelerator marker * \return label without the accelerator marker */ Q_REQUIRED_RESULT static QString removeAcceleratorMarker(const QString &label); /** * Translate a message with Qt semantics. * * This functions provides a capability to derive a Qt translator from * \c QTranslator and draw translations from PO catalogs of given domain. * All domains added with \c insertQtDomain are checked for translation, * in undefined order. * No Ki18n-specific processing is performed (formatting, scripting, etc). * * \see QTranslator * * \deprecated Use Qt's native i18n system, Qt Linguist, * with roundtrip TS->PO->TS through * Qt's \c lupdate and \c lconvert commands. */ Q_REQUIRED_RESULT KI18N_DEPRECATED static QString translateQt(const char *context, const char *text, const char *comment, int n); /** * Add another domain to search for Qt translations. * * \param domain the translation domain to add * * \see translateQt * \see removeQtDomain * * \deprecated */ KI18N_DEPRECATED static void insertQtDomain(const char *domain); /** * Remove a domain from Qt translation lookup. * * To really remove the domain, this function must be invoked * at least as many times as \c insertQtDomain was invoked to add * this domain. This makes it safe to always use paired * insertion/removal calls, without pulling out a domain * underneath an unrelated piece of code that uses it as well. * * \param domain the translation domain to remove * * \see translateQt * \see insertQtDomain * * \deprecated */ KI18N_DEPRECATED static void removeQtDomain(const char *domain); private: KLocalizedString(const char *domain, const char *context, const char *text, const char *plural, bool markupAware); KLocalizedStringPrivate *const d; }; // Do not document every multi-argument i18n* call separately, // but provide special quasi-calls that only Doxygen sees. // Placed in front of ki18n* calls, because i18n* are more basic. #ifdef DOXYGEN_SHOULD_SKIP_THIS /** * Translate a string and substitute any arguments. * * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18n(const char *text, const TYPE &arg...); /** * Translate a string with context and substitute any arguments. * * \param context context of the string * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18nc(const char *context, const char *text, const TYPE &arg...); /** * Translate a string with plural and substitute any arguments. * * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18np(const char *singular, const char *plural, const TYPE &arg...); /** * Translate a string with context and plural and substitute any arguments. * * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18ncp(const char *context, const char *singular, const char *plural, const TYPE &arg...); /** * Translate a string from domain and substitute any arguments. * * \param domain domain in which to look for translations * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18nd(const char *domain, const char *text, const TYPE &arg...); /** * Translate a string from domain with context and substitute any arguments. * * \param domain domain in which to look for translations * \param context context of the string * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...); /** * Translate a string from domain with plural and substitute any arguments. * * \param domain domain in which to look for translations * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18ndp(const char *domain, const char *singular, const char *plural, const TYPE &arg...); /** * Translate a string from domain with context and plural * and substitute any arguments. * * \param domain domain in which to look for translations * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const TYPE &arg...); /** * Translate a markup-aware string and substitute any arguments. * * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18n(const char *text, const TYPE &arg...); /** * Translate a markup-aware string with context and substitute any arguments. * * \param context context of the string * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18nc(const char *context, const char *text, const TYPE &arg...); /** * Translate a markup-aware string with plural and substitute any arguments. * * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18np(const char *singular, const char *plural, const TYPE &arg...); /** * Translate a markup-aware string with context and plural * and substitute any arguments. * * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18ncp(const char *context, const char *singular, const char *plural, const TYPE &arg...); /** * Translate a markup-aware string from domain and substitute any arguments. * * \param domain domain in which to look for translations * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18nd(const char *domain, const char *text, const TYPE &arg...); /** * Translate a markup-aware string from domain with context * and substitute any arguments. * * \param domain domain in which to look for translations * \param context context of the string * \param text string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...); /** * Translate a markup-aware string from domain with plural * and substitute any arguments. * * \param domain domain in which to look for translations * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18ndp(const char *domain, const char *singular, const char *plural, const TYPE &arg...); /** * Translate a markup-aware string from domain with context and plural * and substitute any arguments. * * \param domain domain in which to look for translations * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \param arg arguments to insert (0 to 9), * admissible types according to \c KLocalizedString::subs methods * \return translated string */ QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const TYPE &arg...); #endif // DOXYGEN_SHOULD_SKIP_THIS /** * Create non-finalized translated string. * * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18n(const char *text); /** * Create non-finalized translated string with context. * * \param context context of the string * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18nc(const char *context, const char *text); /** * Create non-finalized translated string with plural. * * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18np(const char *singular, const char *plural); /** * Create non-finalized translated string with context and plural. * * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18ncp(const char *context, const char *singular, const char *plural); /** * Create non-finalized translated string from domain. * * \param domain domain in which to look for translations * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18nd(const char *domain, const char *text); /** * Create non-finalized translated string from domain with context. * * \param domain domain in which to look for translations * \param context context of the string * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18ndc(const char *domain, const char *context, const char *text); /** * Create non-finalized translated string from domain with plural. * * \param domain domain in which to look for translations * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18ndp(const char *domain, const char *singular, const char *plural); /** * Create non-finalized translated string from domain with context and plural. * * \param domain domain in which to look for translations * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT ki18ndcp(const char *domain, const char *context, const char *singular, const char *plural); /** * Create non-finalized markup-aware translated string. * * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18n(const char *text); /** * Create non-finalized markup-aware translated string with context. * * \param context context of the string * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18nc(const char *context, const char *text); /** * Create non-finalized markup-aware translated string with plural. * * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18np(const char *singular, const char *plural); /** * Create non-finalized markup-aware translated string. * with context and plural. * * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18ncp(const char *context, const char *singular, const char *plural); /** * Create non-finalized markup-aware translated string from domain. * * \param domain domain in which to look for translations * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18nd(const char *domain, const char *text); /** * Create non-finalized markup-aware translated string from domain with context. * * \param domain domain in which to look for translations * \param context context of the string * \param text string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18ndc(const char *domain, const char *context, const char *text); /** * Create non-finalized markup-aware translated string from domain with plural. * * \param domain domain in which to look for translations * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18ndp(const char *domain, const char *singular, const char *plural); /** * Create non-finalized markup-aware translated string from domain * with context and plural. * * \param domain domain in which to look for translations * \param context context of the string * \param singular singular form of the string to translate * \param plural plural form of the string to translate * \return non-finalized translated string */ KLocalizedString KI18N_EXPORT kxi18ndcp(const char *domain, const char *context, const char *singular, const char *plural); /** * Redirect Qt's uic-generated translation calls to Ki18n. * * Use -tr tr2i18n option to \c uic to have it redirect calls. * * \param text string to translate * \param comment Qt equivalent of disambiguation context * \return translated string */ inline QString tr2i18n(const char *text, const char *comment = nullptr) { if (comment && comment[0] && text && text[0]) { return ki18nc(comment, text).toString(); } else if (text && text[0]) { return ki18n(text).toString(); } else { return QString(); } } /** * Like \c tr2i18n, but look for translation in a specific domain. * * Use -tr tr2i18nd option to \c uic to have it redirect calls. * * \param domain domain in which to look for translations * \param text string to translate * \param comment Qt equivalent of disambiguation context * \return translated string */ inline QString tr2i18nd(const char *domain, const char *text, const char *comment = nullptr) { if (comment && comment[0] && text && text[0]) { return ki18ndc(domain, comment, text).toString(); } else if (text && text[0]) { return ki18nd(domain, text).toString(); } else { return QString(); } } /** * Like \c tr2i18n, but when UI strings are KUIT markup-aware. * * Use -tr tr2xi18n option to \c uic to have it redirect calls. * * \param text markup-aware string to translate * \param comment Qt equivalent of disambiguation context * \return translated string */ inline QString tr2xi18n(const char *text, const char *comment = nullptr) { if (comment && comment[0] && text && text[0]) { return kxi18nc(comment, text).toString(); } else if (text && text[0]) { return kxi18n(text).toString(); } else { return QString(); } } /** * Like \c tr2xi18n, but look for translation in a specific domain. * * Use -tr tr2xi18nd option to \c uic to have it redirect calls. * * \param domain domain in which to look for translations * \param text markup-aware string to translate * \param comment Qt equivalent of disambiguation context * \return translated string */ inline QString tr2xi18nd(const char *domain, const char *text, const char *comment = nullptr) { if (comment && comment[0] && text && text[0]) { return kxi18ndc(domain, comment, text).toString(); } else if (text && text[0]) { return kxi18nd(domain, text).toString(); } else { return QString(); } } #ifndef DOXYGEN_SHOULD_SKIP_THIS #ifndef NDEBUG #define I18N_ERR_MSG String_literal_as_second_argument_to_i18n___Perhaps_you_need_i18nc_or_i18np template class I18nTypeCheck { public: static void I18N_ERR_MSG() {} }; template class I18nTypeCheck {}; #define STATIC_ASSERT_NOT_LITERAL_STRING(T) I18nTypeCheck::I18N_ERR_MSG(); #else #define STATIC_ASSERT_NOT_LITERAL_STRING(T) #endif // >>>>> Basic calls // Autogenerated; contact maintainer for batch changes. inline QString i18n(const char *text) { return ki18n(text).toString(); } template inline QString i18n(const char *text, const A1 &a1) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<<<< End of basic calls // >>>>> Context calls // Autogenerated; contact maintainer for batch changes. inline QString i18nc(const char *context, const char *text) { return ki18nc(context, text).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1) { return ki18nc(context, text).subs(a1).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2) { return ki18nc(context, text).subs(a1).subs(a2).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { return ki18nc(context, text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return ki18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return ki18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return ki18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return ki18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return ki18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return ki18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of context calls // >>>>> Plural calls // Autogenerated; contact maintainer for batch changes. template inline QString i18np(const char *singular, const char *plural, const A1 &a1) { return ki18np(singular, plural).subs(a1).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return ki18np(singular, plural).subs(a1).subs(a2).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return ki18np(singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return ki18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return ki18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return ki18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return ki18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return ki18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return ki18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of plural calls // >>>>> Context-plural calls // Autogenerated; contact maintainer for batch changes. template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1) { return ki18ncp(context, singular, plural).subs(a1).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return ki18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of context-plural calls // >>>>> Basic calls with domain // Autogenerated; contact maintainer for batch changes. inline QString i18nd(const char *domain, const char *text) { return ki18nd(domain, text).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return ki18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<<<< End of basic calls with domain // >>>>> Context calls with domain // Autogenerated; contact maintainer for batch changes. inline QString i18ndc(const char *domain, const char *context, const char *text) { return ki18ndc(domain, context, text).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1) { return ki18ndc(domain, context, text).subs(a1).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2) { return ki18ndc(domain, context, text).subs(a1).subs(a2).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { return ki18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return ki18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return ki18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return ki18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return ki18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return ki18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return ki18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of context calls with domain // >>>>> Plural calls with domain // Autogenerated; contact maintainer for batch changes. template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1) { return ki18ndp(domain, singular, plural).subs(a1).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return ki18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of plural calls with domain // >>>>> Context-plural calls with domain // Autogenerated; contact maintainer for batch changes. template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1) { return ki18ndcp(domain, context, singular, plural).subs(a1).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString i18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return ki18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of context-plural calls with domain // >>>>> Markup-aware basic calls // Autogenerated; contact maintainer for batch changes. inline QString xi18n(const char *text) { return kxi18n(text).toString(); } template inline QString xi18n(const char *text, const A1 &a1) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18n(const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18n(text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<<<< End of markup-aware basic calls // >>>>> Markup-aware context calls // Autogenerated; contact maintainer for batch changes. inline QString xi18nc(const char *context, const char *text) { return kxi18nc(context, text).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1) { return kxi18nc(context, text).subs(a1).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2) { return kxi18nc(context, text).subs(a1).subs(a2).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { return kxi18nc(context, text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return kxi18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return kxi18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return kxi18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return kxi18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return kxi18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18nc(const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return kxi18nc(context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of markup-aware context calls // >>>>> Markup-aware plural calls // Autogenerated; contact maintainer for batch changes. template inline QString xi18np(const char *singular, const char *plural, const A1 &a1) { return kxi18np(singular, plural).subs(a1).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return kxi18np(singular, plural).subs(a1).subs(a2).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return kxi18np(singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return kxi18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return kxi18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return kxi18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return kxi18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return kxi18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18np(const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return kxi18np(singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of markup-aware plural calls // >>>>> Markup-aware context-plural calls // Autogenerated; contact maintainer for batch changes. template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1) { return kxi18ncp(context, singular, plural).subs(a1).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18ncp(const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return kxi18ncp(context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of markup-aware context-plural calls // >>>>> Markup-aware basic calls with domain // Autogenerated; contact maintainer for batch changes. inline QString xi18nd(const char *domain, const char *text) { return kxi18nd(domain, text).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18nd(const char *domain, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { STATIC_ASSERT_NOT_LITERAL_STRING(A1) return kxi18nd(domain, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<<<< End of markup-aware basic calls with domain // >>>>> Markup-aware context calls with domain // Autogenerated; contact maintainer for batch changes. inline QString xi18ndc(const char *domain, const char *context, const char *text) { return kxi18ndc(domain, context, text).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1) { return kxi18ndc(domain, context, text).subs(a1).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18ndc(const char *domain, const char *context, const char *text, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return kxi18ndc(domain, context, text).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of markup-aware context calls with domain // >>>>> Markup-aware plural calls with domain // Autogenerated; contact maintainer for batch changes. template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1) { return kxi18ndp(domain, singular, plural).subs(a1).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18ndp(const char *domain, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return kxi18ndp(domain, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of markup-aware plural calls with domain // >>>>> Markup-aware context-plural calls with domain // Autogenerated; contact maintainer for batch changes. template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1) { return kxi18ndcp(domain, context, singular, plural).subs(a1).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).toString(); } template inline QString xi18ndcp(const char *domain, const char *context, const char *singular, const char *plural, const A1 &a1, const A2 &a2, const A3 &a3, const A4 &a4, const A5 &a5, const A6 &a6, const A7 &a7, const A8 &a8, const A9 &a9) { return kxi18ndcp(domain, context, singular, plural).subs(a1).subs(a2).subs(a3).subs(a4).subs(a5).subs(a6).subs(a7).subs(a8).subs(a9).toString(); } // <<<<< End of markup-aware context-plural calls with domain #endif // DOXYGEN_SHOULD_SKIP_THIS #endif // KLOCALIZEDSTRING_H #ifndef DOXYGEN_SHOULD_SKIP_THIS // Outside of include guards, to be able to map and unmap domains // by successive inclusions of this header // preceded with different definitions of TRANSLATION_DOMAIN. #ifdef TRANSLATION_DOMAIN #define i18n(...) i18nd(TRANSLATION_DOMAIN, __VA_ARGS__) #define i18nc(...) i18ndc(TRANSLATION_DOMAIN, __VA_ARGS__) #define i18np(...) i18ndp(TRANSLATION_DOMAIN, __VA_ARGS__) #define i18ncp(...) i18ndcp(TRANSLATION_DOMAIN, __VA_ARGS__) #define ki18n(...) ki18nd(TRANSLATION_DOMAIN, __VA_ARGS__) #define ki18nc(...) ki18ndc(TRANSLATION_DOMAIN, __VA_ARGS__) #define ki18np(...) ki18ndp(TRANSLATION_DOMAIN, __VA_ARGS__) #define ki18ncp(...) ki18ndcp(TRANSLATION_DOMAIN, __VA_ARGS__) #define tr2i18n(...) tr2i18nd(TRANSLATION_DOMAIN, __VA_ARGS__) #define xi18n(...) xi18nd(TRANSLATION_DOMAIN, __VA_ARGS__) #define xi18nc(...) xi18ndc(TRANSLATION_DOMAIN, __VA_ARGS__) #define xi18np(...) xi18ndp(TRANSLATION_DOMAIN, __VA_ARGS__) #define xi18ncp(...) xi18ndcp(TRANSLATION_DOMAIN, __VA_ARGS__) #define kxi18n(...) kxi18nd(TRANSLATION_DOMAIN, __VA_ARGS__) #define kxi18nc(...) kxi18ndc(TRANSLATION_DOMAIN, __VA_ARGS__) #define kxi18np(...) kxi18ndp(TRANSLATION_DOMAIN, __VA_ARGS__) #define kxi18ncp(...) kxi18ndcp(TRANSLATION_DOMAIN, __VA_ARGS__) #define tr2xi18n(...) tr2xi18nd(TRANSLATION_DOMAIN, __VA_ARGS__) #else #undef i18n #undef i18nc #undef i18np #undef i18ncp #undef ki18n #undef ki18nc #undef ki18np #undef ki18ncp #undef tr2i18n #undef xi18n #undef xi18nc #undef xi18np #undef xi18ncp #undef kxi18n #undef kxi18nc #undef kxi18np #undef kxi18ncp #undef tr2xi18n #endif #endif // DOXYGEN_SHOULD_SKIP_THIS diff --git a/src/klocalizedtranslator.h b/src/klocalizedtranslator.h index 4027262..aba1679 100644 --- a/src/klocalizedtranslator.h +++ b/src/klocalizedtranslator.h @@ -1,110 +1,110 @@ /* * Copyright 2014 Martin Gräßlin * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) version 3, or any * later version accepted by the membership of KDE e.V. (or its * successor approved by the membership of KDE e.V.), which shall * act as a proxy defined in Section 6 of version 3 of the license. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library. If not, see . */ #ifndef KLOCALIZEDTRANSLATOR_H #define KLOCALIZEDTRANSLATOR_H #include -#include +#include class KLocalizedTranslatorPrivate; /** * @class KLocalizedTranslator klocalizedtranslator.h * * @brief A QTranslator using KLocalizedString for translations. * * This class allows to translate strings in Qt's translation system with KLocalizedString. * An example is the translation of a dynamically loaded user interface through QUILoader. * * To use this Translator install it in the QCoreApplication and provide the translation domain * to be used. The Translator can operate for multiple contexts, those needs to be specified. * * Example for translating a UI loaded through QUILoader: * @code * // create translator and install in QCoreApplication * KLocalizedTranslator *translator = new KLocalizedTranslator(this); * QCoreApplication::instance()->installTranslator(translator); * translator->setTranslationDomain(QStringLiteral("MyAppsDomain")); * * // create the QUILoader * QUiLoader *loader = new QUiLoader(this); * loader->setLanguageChangeEnabled(true); * * // load the UI * QFile uiFile(QStringLiteral("/path/to/userInterface.ui")); * uiFile.open(QFile::ReadOnly); * QWidget *loadedWidget = loader->load(&uiFile, this); * uiFile.close(); * * // the object name of the loaded UI is the context in this case * translator->addContextToMonitor(loadedWidget->objectName()); * * // send a LanguageChange event, this will re-translate using our translator * QEvent le(QEvent::LanguageChange); * QCoreApplication::sendEvent(loadedWidget, &le); * @endcode * * @since 5.0 **/ class KI18N_EXPORT KLocalizedTranslator : public QTranslator { Q_OBJECT public: explicit KLocalizedTranslator(QObject *parent = nullptr); virtual ~KLocalizedTranslator(); QString translate(const char *context, const char *sourceText, const char *disambiguation = nullptr, int n = -1) const Q_DECL_OVERRIDE; /** * Sets the @p translationDomain to be used. * * The translation domain is required. Without the translation domain any invocation of * translate() will be delegated to the base class. * * @param translationDomain The translation domain to be used. **/ void setTranslationDomain(const QString &translationDomain); /** * Adds a @p context for which this Translator should be active. * * The Translator only translates texts with a context matching one of the monitored contexts. * If the context is not monitored, the translate() method delegates to the base class. * * @param context The context for which the Translator should be active * * @see removeContextToMonitor **/ void addContextToMonitor(const QString &context); /** * Stop translating for the given @p context. * * @param context The context for which the Translator should no longer be active * * @see addContextToMonitor **/ void removeContextToMonitor(const QString &context); private: const QScopedPointer d; }; #endif //KLOCALIZEDTRANSLATOR_H diff --git a/src/kuitmarkup.h b/src/kuitmarkup.h index 9dd98f1..e17073b 100644 --- a/src/kuitmarkup.h +++ b/src/kuitmarkup.h @@ -1,201 +1,201 @@ /* This file is part of the KDE libraries Copyright (C) 2013 Chusslove Illich This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef KUITMARKUP_H #define KUITMARKUP_H #include -#include -#include -#include +#include +#include +#include class KuitSetup; /** * Global constants and functions related to KUIT markup. */ namespace Kuit { /** * Visual formats into which KUIT markup can be resolved. */ enum VisualFormat { /** * Visual format not defined. * This value can be explicitly set * (e.g. through \c KLocalizedString::withFormat) * to indicate that the format should be decided * by another mechanism (e.g. context UI marker). */ UndefinedFormat = 0, /** * Plain text. */ PlainText = 10, /** * Qt rich text (HTML subset). */ RichText = 20, /** * Terminal escape sequences. */ TermText = 30 }; /** * Classification of KUIT tags. */ enum TagClass { /** * Tags wrapping text inserted into running text. */ PhraseTag = 0, /** * Tags spliting text into paragraph-level blocks. */ StructTag = 1 }; /** * Functions accepted by tag formatting functions. * * \param languages the target languages (by decreasing priority) * \param tagName the wrapping tag name * \param attributes the attribute name-value pairs in the tag * \param text the wrapped text * \param tagPath the ordered list of ancestor tag names, parent first * \param format the target visual format * \return formatted text */ typedef QString(*TagFormatter)(const QStringList &languages, const QString &tagName, const QHash &attributes, const QString &text, const QStringList &tagPath, Kuit::VisualFormat format); /** * Get hold of the KUIT setup object for a given domain. * * \param domain the translation domain * \return pointer to KUIT setup object */ KuitSetup &setupForDomain(const char *domain); KuitSetup &setupForDomain(const QByteArray& domain); } class KLocalizedString; class KuitSetupPrivate; class KuitFormatterPrivate; /** * @class KuitSetup kuitmarkup.h * * Class for modifying KUIT markup in a given domain. * * Not directly constructed, but obtained through \c Kuit::setupForDomain. */ class KI18N_EXPORT KuitSetup { friend KuitSetup &Kuit::setupForDomain(const QByteArray& domain); friend class KuitFormatterPrivate; public: /** * Destructor. */ ~KuitSetup(); /** * Set the formatting string for a tag with attributes combination. * * If a new tag name is given, this effectively defines a new tag. * The same holds for attribute names. * * The pattern string \p pattern should contain placeholders * for inserting the text and the attribute values. * %1 will be replaced with the wrapped text, and %2 and upwards * with attribute values in the order given by \p attrNames. * Non markup-aware translation call with context (\c ki18nc) * should be used to create the pattern string. * * In addition to the pattern, a formatting function * of the type \c TagFormatter can be given. * This function receives the full markup parsing context, * so that it can do whatever is necessary with the wrapped text. * The result of this function is then substituted into the pattern. * You can also give an empty pattern (as KLocalizedString()) * together with the formatting function, in which case the function * is assumed to do everything and no substitution is performed. * * \param tagName the name of the tag * \param attribNames the names of the attributes (empty names are ignored) * \param format the target visual format * \param pattern the pattern string * \param leadingNewlines the number of new lines (\\n) to be maintained * between any preceding text and the text wrapped * with this tag (for formats where it matters) */ void setTagPattern(const QString &tagName, const QStringList &attribNames, Kuit::VisualFormat format, const KLocalizedString &pattern, Kuit::TagFormatter formatter = nullptr, int leadingNewlines = 0); /** * Set the KUIT class of the tag. * * \param tagName the name of the tag * \param aClass the KUIT tag class */ void setTagClass(const QString &tagName, Kuit::TagClass aClass); /** * Set the default visual format for a given UI marker. * * Giving "@" for \p marker means to set the format * only for standalone \@\ marker, * while "@:" (with trailing colon) means to set * the same format for all \@\:\ combinations. * * Defined UI marker major/minor combinations are listed in the section * \ref uimark_ctxt. If an UI marker combination outside of the defined * is given as \p marker, it will be ignored. * * Setting \c Kuit::UndefinedFormat as \p format * means to fall back to default format for the given UI marker. * * \param marker the UI marker * \param format the visual format */ void setFormatForMarker(const QString &marker, Kuit::VisualFormat format); private: KuitSetup(const QByteArray &domain); Q_DISABLE_COPY(KuitSetup) KuitSetupPrivate *const d; }; #endif // KUITMARKUP_H