commit kf6-ki18n for openSUSE:Factory
Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package kf6-ki18n for openSUSE:Factory checked in at 2024-08-10 19:06:35 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/kf6-ki18n (Old) and /work/SRC/openSUSE:Factory/.kf6-ki18n.new.7232 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "kf6-ki18n" Sat Aug 10 19:06:35 2024 rev:6 rq:1192878 version:6.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/kf6-ki18n/kf6-ki18n.changes 2024-07-14 08:53:03.666065069 +0200 +++ /work/SRC/openSUSE:Factory/.kf6-ki18n.new.7232/kf6-ki18n.changes 2024-08-10 19:10:25.792333514 +0200 @@ -1,0 +2,19 @@ +Mon Aug 5 10:47:42 UTC 2024 - Christophe Marin <christophe@krop.fr> + +- Update to 6.5.0 + * New feature release + * For more details please see: + * https://kde.org/announcements/frameworks/6/6.5.0 +- Changes since 6.4.0: + * Update dependency version to 6.5.0 + * Use more specific names for the functions + * Add comment for translators in example code + * Code cleanup + * Minor Doxygen change + * Build with older clang versions too + * Test also retranslateFormatString + * Make retranslateFormatString() call function from correct namespace and adjust code documentation + * Add helper method for setting a plural-aware spin box prefix/suffix + * Update version to 6.5.0 + +------------------------------------------------------------------- Old: ---- ki18n-6.4.0.tar.xz ki18n-6.4.0.tar.xz.sig New: ---- ki18n-6.5.0.tar.xz ki18n-6.5.0.tar.xz.sig ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ kf6-ki18n.spec ++++++ --- /var/tmp/diff_new_pack.XQG7oh/_old 2024-08-10 19:10:27.152389986 +0200 +++ /var/tmp/diff_new_pack.XQG7oh/_new 2024-08-10 19:10:27.152389986 +0200 @@ -19,13 +19,13 @@ %define qt6_version 6.6.0 %define rname ki18n -# Full KF6 version (e.g. 6.4.0) +# Full KF6 version (e.g. 6.5.0) %{!?_kf6_version: %global _kf6_version %{version}} # Last major and minor KF6 version (e.g. 6.0) %{!?_kf6_bugfix_version: %define _kf6_bugfix_version %(echo %{_kf6_version} | awk -F. '{print $1"."$2}')} %bcond_without released Name: kf6-ki18n -Version: 6.4.0 +Version: 6.5.0 Release: 0 Summary: KDE Gettext-based UI text internationalization License: LGPL-2.1-or-later ++++++ ki18n-6.4.0.tar.xz -> ki18n-6.5.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ki18n-6.4.0/CMakeLists.txt new/ki18n-6.5.0/CMakeLists.txt --- old/ki18n-6.4.0/CMakeLists.txt 2024-07-05 22:07:04.000000000 +0200 +++ new/ki18n-6.5.0/CMakeLists.txt 2024-08-02 13:13:28.000000000 +0200 @@ -1,11 +1,11 @@ cmake_minimum_required(VERSION 3.16) -set(KF_VERSION "6.4.0") # handled by release scripts +set(KF_VERSION "6.5.0") # handled by release scripts project(KI18n VERSION ${KF_VERSION}) # ECM setup include(FeatureSummary) -find_package(ECM 6.4.0 NO_MODULE) +find_package(ECM 6.5.0 NO_MODULE) set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules") feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES) @@ -36,7 +36,7 @@ # Dependencies set(REQUIRED_QT_VERSION 6.5.0) -find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core) +find_package(Qt6 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Core OPTIONAL_COMPONENTS Widgets) set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].") @@ -89,6 +89,7 @@ add_subdirectory(src) if(BUILD_TESTING) add_subdirectory(autotests) + add_subdirectory(tests) endif() # create a Config.cmake and a ConfigVersion.cmake file and install them diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ki18n-6.4.0/src/i18n/CMakeLists.txt new/ki18n-6.5.0/src/i18n/CMakeLists.txt --- old/ki18n-6.4.0/src/i18n/CMakeLists.txt 2024-07-05 22:07:04.000000000 +0200 +++ new/ki18n-6.5.0/src/i18n/CMakeLists.txt 2024-08-02 13:13:28.000000000 +0200 @@ -17,6 +17,7 @@ common_helpers.cpp klocalizedcontext.cpp main.cpp + klocalization.cpp ) ecm_qt_declare_logging_category(KF6I18n @@ -69,6 +70,7 @@ KLocalizedContext KLocalizedString KLocalizedTranslator + KLocalization KuitSetup REQUIRED_HEADERS KI18n_HEADERS ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ki18n-6.4.0/src/i18n/klocalization.cpp new/ki18n-6.5.0/src/i18n/klocalization.cpp --- old/ki18n-6.4.0/src/i18n/klocalization.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/ki18n-6.5.0/src/i18n/klocalization.cpp 2024-08-02 13:13:28.000000000 +0200 @@ -0,0 +1,9 @@ +/* + SPDX-FileCopyrightText: 2024 Lukas Sommer <sommerluk@gmail.com> + SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org> + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#include "klocalization.h" + +// this file only exists so we check klocalization.h compiles diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ki18n-6.4.0/src/i18n/klocalization.h new/ki18n-6.5.0/src/i18n/klocalization.h --- old/ki18n-6.4.0/src/i18n/klocalization.h 1970-01-01 01:00:00.000000000 +0100 +++ new/ki18n-6.5.0/src/i18n/klocalization.h 2024-08-02 13:13:28.000000000 +0200 @@ -0,0 +1,142 @@ +/* + SPDX-FileCopyrightText: 2024 Lukas Sommer <sommerluk@gmail.com> + SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org> + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#ifndef KLOCALIZATION_H +#define KLOCALIZATION_H + +#include "klocalizedstring.h" + +#include <QObject> + +#include <type_traits> + +class QDoubleSpinBox; +class QSpinBox; + +/** + * @namespace KLocalization + * @brief Namespace containing helpers for localization. + * @since 6.5 + */ +namespace KLocalization +{ + +///@cond hidden +namespace Private +{ + +constexpr inline const char SpinBoxFormatStringProperty[] = "__KLocalizationFormatStringPrivate"; + +} +///@endcond + +/** + * @brief Retranslates a previously set up format string to the current + * language and updates the spin box. + * + * The format string is initially set up by setupSpinBoxFormatString(). + * This function updates the prefix and suffix of a spin box to reflect the + * current language settings. It is useful for responding to language changes, + * such as those triggered by QEvent::LanguageChange. + * + * @tparam T The type of the spin box, which must be either QSpinBox or + * QDoubleSpinBox. + * @param spinBox Pointer to the spin box. + * + * @post The prefix and suffix of the spin box are updated to reflect the + * current language. + * + * @sa @ref setupSpinBoxFormatString + * + * @since 6.5 + */ + +template<typename T> +inline void retranslateSpinBoxFormatString(T *spinBox) +{ + constexpr bool isSpinBox = std::is_base_of_v<QSpinBox, T> || std::is_base_of_v<QDoubleSpinBox, T>; + static_assert(isSpinBox, "First argument must be a QSpinBox or QDoubleSpinBox."); + + const auto lString = spinBox->property(Private::SpinBoxFormatStringProperty).template value<KLocalizedString>(); + const auto translation = lString.subs(spinBox->value()).toString(); + const auto parts = translation.split(QLatin1StringView("%v")); + if (parts.count() == 2) { + spinBox->setPrefix(parts.at(0)); + spinBox->setSuffix(parts.at(1)); + } else { + spinBox->setPrefix(QString()); + spinBox->setSuffix(QString()); + } +} + +/** + * @brief Sets up a format string for internationalizing spin boxes. + * + * This function allows the customization of prefix and suffix for spin boxes + * (QSpinBox and QDoubleSpinBox), considering internationalization needs. + * + * Spin boxes display a number and possibly a prefix and/or suffix. However, + * in some languages, the position of the prefix and suffix may be reversed + * compared to English. Example: In English, you write 50%, but in Turkish, + * you write %50. Qt does not offer an out-of-the-box solution for this. This + * helper now provides complete internationalization for prefixes and suffixes + * of spin boxes. + * + * For QSpinBox it also provides correct plural handling by installing a + * handler for the valueChanged() signal to update prefix and suffix whenever + * the spin box value changes in the future. + * + * Example usage: + * @code + * QDoubleSpinBox doubleBox; + * KLocalization::setupSpinBoxFormatString( + * &doubleBox, + * ki18nc("@item %v is a number and the second % is the percent sign", "%v%")); + * // Turkish translation: "%%v" + * + * QSpinBox intBox; + * KLocalization::setupSpinBoxFormatString( + * &intBox, + * ki18ncp("@item %v is a number", "Baking %v cake", "Baking %v cakes")); + * @endcode + * + * @tparam T The type of the spin box, which must be either QSpinBox or QDoubleSpinBox. + * @param spinBox Pointer to the spin box. + * @param formatString A localized string in the format "PREFIX%vSUFFIX". + * For QDoubleSpinBox, it does not handle plural forms. For QSpinBox, it is + * recommended to handle plural forms. + * + * @note It is safe to call this function multiple times on the same spin box. + * + * @sa @ref retranslateSpinBoxFormatString + * + * @since 6.5 + */ + +template<typename T> +inline void setupSpinBoxFormatString(T *spinBox, const KLocalizedString &formatString) +{ + constexpr bool isSpinBox = std::is_base_of_v<QSpinBox, T>; + constexpr bool isDoubleSpinBox = std::is_base_of_v<QDoubleSpinBox, T>; + static_assert(isSpinBox || isDoubleSpinBox, "First argument must be a QSpinBox or QDoubleSpinBox."); + + if constexpr (isSpinBox) { + const bool hasSetup = !spinBox->property(Private::SpinBoxFormatStringProperty).isNull(); + if (!hasSetup) { + QObject::connect(spinBox, &T::valueChanged, spinBox, [spinBox]() { + retranslateSpinBoxFormatString(spinBox); + }); + } + } + // Using relaxSubs() to avoid error marks if the library user did pass + // a singular-only KLocalizedString. + spinBox->setProperty(Private::SpinBoxFormatStringProperty, QVariant::fromValue(formatString.relaxSubs())); + retranslateSpinBoxFormatString(spinBox); +} + +} + +#endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ki18n-6.4.0/tests/CMakeLists.txt new/ki18n-6.5.0/tests/CMakeLists.txt --- old/ki18n-6.4.0/tests/CMakeLists.txt 1970-01-01 01:00:00.000000000 +0100 +++ new/ki18n-6.5.0/tests/CMakeLists.txt 2024-08-02 13:13:28.000000000 +0200 @@ -0,0 +1,7 @@ +# SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org> +# SPDX-License-Identifier: BSD-3-clause + +if (TARGET Qt6::Widgets) + add_executable(spinbox spinbox.cpp) + target_link_libraries(spinbox PRIVATE Qt6::Widgets KF6::I18n) +endif() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ki18n-6.4.0/tests/spinbox.cpp new/ki18n-6.5.0/tests/spinbox.cpp --- old/ki18n-6.4.0/tests/spinbox.cpp 1970-01-01 01:00:00.000000000 +0100 +++ new/ki18n-6.5.0/tests/spinbox.cpp 2024-08-02 13:13:28.000000000 +0200 @@ -0,0 +1,28 @@ +/* + SPDX-FileCopyrightText: 2024 Volker Krause <vkrause@kde.org> + SPDX-License-Identifier: LGPL-2.0-or-later +*/ + +#include <KLocalization> + +#include <QApplication> +#include <QDoubleSpinBox> +#include <QSpinBox> + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QSpinBox spinBox; + KLocalization::setupSpinBoxFormatString(&spinBox, ki18np("Baking %v pizza", "Baking %v pizzas")); + KLocalization::setupSpinBoxFormatString(&spinBox, ki18np("Baking %v cake", "Baking %v cakes")); + KLocalization::retranslateSpinBoxFormatString(&spinBox); + spinBox.show(); + + QSpinBox doubleSpinBox; + KLocalization::setupSpinBoxFormatString(&doubleSpinBox, ki18n("%v%")); + KLocalization::retranslateSpinBoxFormatString(&doubleSpinBox); + doubleSpinBox.show(); + + return app.exec(); +}
participants (1)
-
Source-Sync