QProgressBar: Make the default value translatable

QProgressBar currently does not expose the default value
for translation automatically. This is an issue for languages
that use a different percent formatting other than the
standard 100%. Default format has to be made explicitly
available for translation, and it is not common among the
most Qt and KDE software. This aims to fix the issue via
making it available for translation, so that it could be
translated at one source instead of fixing it in various
software.

Fixes: QTBUG-127713
Change-Id: Icd73cf48ad3cdf441e8e7aba58151cc538adff6a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Emir SARI 2025-03-05 17:10:01 +03:00 committed by Volker Hilsheimer
parent 9c87c99180
commit d5f00591cd

View File

@ -54,7 +54,14 @@ QProgressBarPrivate::QProgressBarPrivate()
void QProgressBarPrivate::initDefaultFormat()
{
if (defaultFormat)
if (defaultFormat) {
//: %p is the percent value, % is the percent sign. When translated
//: to the identical %p%, then the second % symbol will be replaced
//: by the percentage-symbol from the user's locale.
format = QProgressBar::tr("%p%");
}
if (format == "%p%"_L1)
format = "%p"_L1 + locale.percent();
}