Bug 416247 - KLocalizedString::toString not behaving as documented
Summary: KLocalizedString::toString not behaving as documented
Status: CONFIRMED
Alias: None
Product: frameworks-ki18n
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Chusslove Illich
URL:
Keywords:
: 453313 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-01-14 13:27 UTC by Harald Sitter
Modified: 2024-09-08 20:52 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Sitter 2020-01-14 13:27:16 UTC
SUMMARY
Documentation says "If \p languages is empty, original message is returned." which is not actually what's happening.

OBSERVED RESULT
`label.toString(QStringList());`

returns the localized string when I have LANGUAGE=de

EXPECTED RESULT
Returned value should be the original input string.

ADDITIONAL INFORMATION
The use case is in kinfocenter's about system module, which offers the ability to copy a textual dump to clipboard when the current system language is not english (i.e. an auto-untranslate feature if you will). Currently this is hardcoded but would be nice to just use KLS I suppose.
Comment 1 Claudius Ellsel 2020-06-15 19:53:11 UTC
Reproduced with https://invent.kde.org/plasma/kinfocenter/-/blob/master/Modules/about-distro/src/Entry.cpp#L43

Using an empty list as argument returns the German Strings for me.

Documentation: https://api.kde.org/frameworks/ki18n/html/classKLocalizedString.html

Probably relevant part of the implementation: https://api.kde.org/frameworks/ki18n/html/klocalizedstring_8cpp_source.html#l00530
Comment 2 ratijas 2022-05-02 18:47:36 UTC
*** Bug 453313 has been marked as a duplicate of this bug. ***
Comment 3 ratijas 2022-05-02 19:25:41 UTC
Still relevant today. I browsed source code, and tracked this problem down to the definition of `KFormatPrivate::formatByteSize`: it uses a bunch of unqualified tr() calls. The function tr() is declared by Q_DECLARE_TR_FUNCTIONS(KFormat), and delegates actual work to QCoreApplication::translate() which uses globally installed QTranslator object.