diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) -include(GenerateExportHeader) +include(ECMGenerateExportHeader) include(CMakePackageConfigHelpers) include(ECMSetupVersion) include(ECMGenerateHeaders) @@ -35,6 +35,8 @@ find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core) +set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") + option(BUILD_WITH_QML "Build with support for scripted translations (recommended)" ON) if (BUILD_WITH_QML) find_package(Qt5Qml ${REQUIRED_QT_VERSION} CONFIG REQUIRED) diff --git a/autotests/klocalizedstringtest.h b/autotests/klocalizedstringtest.h --- a/autotests/klocalizedstringtest.h +++ b/autotests/klocalizedstringtest.h @@ -19,6 +19,7 @@ #ifndef KLOCALIZEDSTRINGTEST_H #define KLOCALIZEDSTRINGTEST_H +#include #include #include @@ -33,7 +34,9 @@ void miscMethods(); void translateToFrenchLowlevel(); void translateToFrench(); +#if KI18N_ENABLE_DEPRECATED_SINCE(5, 0) void translateQt(); +#endif void addCustomDomainPath(); void testThreads(); diff --git a/autotests/klocalizedstringtest.cpp b/autotests/klocalizedstringtest.cpp --- a/autotests/klocalizedstringtest.cpp +++ b/autotests/klocalizedstringtest.cpp @@ -487,6 +487,7 @@ QCOMPARE(i18n("Job"), QString::fromUtf8("Tâche")); } +#if KI18N_ENABLE_DEPRECATED_SINCE(5, 0) void KLocalizedStringTest::translateQt() { KLocalizedString::insertQtDomain("ki18n-test-qt"); @@ -509,6 +510,7 @@ #endif KLocalizedString::removeQtDomain("ki18n-test-qt"); } +#endif void KLocalizedStringTest::testLocalizedTranslator() { @@ -582,8 +584,10 @@ sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::correctSubs)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::correctSubs)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::correctSubs)); +#if KI18N_ENABLE_DEPRECATED_SINCE(5, 0) sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::translateQt)); sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::translateQt)); +#endif sync.addFuture(QtConcurrent::run(this, &KLocalizedStringTest::translateToFrench)); sync.waitForFinished(); QThreadPool::globalInstance()->setMaxThreadCount(1); // delete those threads diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -21,8 +21,15 @@ ) add_library(KF5I18n ${libki18n_SRCS}) -generate_export_header(KF5I18n BASE_NAME KI18n) add_library(KF5::I18n ALIAS KF5I18n) +ecm_generate_export_header(KF5I18n + BASE_NAME KI18n + # GROUP_BASE_NAME KF <- enable once all of KF modules use ecm_generate_export_header + VERSION ${KF5_VERSION} + DEPRECATED_BASE_VERSION 0 + DEPRECATION_VERSIONS 5.0 + EXCLUDE_DEPRECATED_BEFORE_AND_AT ${EXCLUDE_DEPRECATED_BEFORE_AND_AT} +) target_include_directories(KF5I18n INTERFACE "$") target_include_directories(KF5I18n PRIVATE ${LibIntl_INCLUDE_DIRS}) diff --git a/src/klocalizedstring.h b/src/klocalizedstring.h --- a/src/klocalizedstring.h +++ b/src/klocalizedstring.h @@ -53,23 +53,25 @@ #define I18NC_NOOP(context, text) context, text #endif +#if KI18N_ENABLE_DEPRECATED_SINCE(5, 0) #ifndef I18N_NOOP2 /** * Wrap string with context for extraction, discarding context. * - * \deprecated Use \c I18NC_NOOP. + * \deprecated Since 5.0, 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. + * \deprecated Since 5.0, use \c I18NC_NOOP. */ #define I18N_NOOP2_NOSTRIP(context, text) context, text #endif +#endif // KI18N_ENABLE_DEPRECATED_SINCE(5, 0) /** * @class KLocalizedString klocalizedstring.h @@ -606,6 +608,7 @@ */ Q_REQUIRED_RESULT static QString removeAcceleratorMarker(const QString &label); +#if KI18N_ENABLE_DEPRECATED_SINCE(5, 0) /** * Translate a message with Qt semantics. * @@ -621,21 +624,27 @@ * 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); + KI18N_DEPRECATED_VERSION(5, 0, "See API docs") + Q_REQUIRED_RESULT static QString translateQt(const char *context, const char *text, + const char *comment, int n); +#endif +#if KI18N_ENABLE_DEPRECATED_SINCE(5, 0) /** * Add another domain to search for Qt translations. * * \param domain the translation domain to add * * \see translateQt * \see removeQtDomain * - * \deprecated + * \deprecated Since 5.0 */ - KI18N_DEPRECATED static void insertQtDomain(const char *domain); + KI18N_DEPRECATED_VERSION(5, 0, "See API docs") + static void insertQtDomain(const char *domain); +#endif +#if KI18N_ENABLE_DEPRECATED_SINCE(5, 0) /** * Remove a domain from Qt translation lookup. * @@ -650,9 +659,11 @@ * \see translateQt * \see insertQtDomain * - * \deprecated + * \deprecated Since 5.0 */ - KI18N_DEPRECATED static void removeQtDomain(const char *domain); + KI18N_DEPRECATED_VERSION(5, 0, "See API docs") + static void removeQtDomain(const char *domain); +#endif private: KLocalizedString(const char *domain, diff --git a/src/klocalizedstring.cpp b/src/klocalizedstring.cpp --- a/src/klocalizedstring.cpp +++ b/src/klocalizedstring.cpp @@ -1454,6 +1454,7 @@ return ::removeAcceleratorMarker(label); } +#if KI18N_BUILD_DEPRECATED_SINCE(5, 0) QString KLocalizedString::translateQt(const char *context, const char *sourceText, const char *comment, @@ -1525,7 +1526,9 @@ // No proper translation found, return empty according to Qt semantics. return QString(); } +#endif +#if KI18N_BUILD_DEPRECATED_SINCE(5, 0) void KLocalizedString::insertQtDomain(const char *domain) { KLocalizedStringPrivateStatics *s = staticsKLSP(); @@ -1542,7 +1545,9 @@ ++s->qtDomainInsertCount[pos]; } } +#endif +#if KI18N_BUILD_DEPRECATED_SINCE(5, 0) void KLocalizedString::removeQtDomain(const char *domain) { KLocalizedStringPrivateStatics *s = staticsKLSP(); @@ -1555,6 +1560,8 @@ s->qtDomainInsertCount.removeAt(pos); } } +#endif + void KLocalizedString::addDomainLocaleDir(const QByteArray &domain, const QString &path) { KCatalog::addDomainLocaleDir(domain, path);