Bug 443023 - private/TextFieldContextMenu.qml:103: ReferenceError: i18nc is not defined
Summary: private/TextFieldContextMenu.qml:103: ReferenceError: i18nc is not defined
Status: RESOLVED INTENTIONAL
Alias: None
Product: frameworks-qqc2-desktop-style
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Marco Martin
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-09-27 17:01 UTC by ratijas
Modified: 2023-06-13 23:01 UTC (History)
4 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 ratijas 2021-09-27 17:01:01 UTC
SUMMARY
Internal error in "QtQuick/Controls.2/org.kde.desktop".

Root QML type of TextFieldContextMenu.qml is QtQuick.Controls.2/Menu, and I have no idea where i18nc is supposed to be pulled from.

STEPS TO REPRODUCE
1. Create a stub application in Qt Creator.
2. Add QuickControls2 to Qt, and `find_package(KF5Kirigami2 2.7.0)`.
3. `Import org.kde.kirigami 2.4 as Kirigami` in your main.qml.
4. Declare a QQC2/TextField item.
5. Build & Run.
6. Click on a text field to give it a focus.


OBSERVED RESULT
file:///home/ratijas/kde/usr/lib/qml/QtQuick/Controls.2/org.kde.desktop/private/TextFieldContextMenu.qml:103: ReferenceError: i18nc is not defined
file:///home/ratijas/kde/usr/lib/qml/QtQuick/Controls.2/org.kde.desktop/private/TextFieldContextMenu.qml:116: ReferenceError: i18nc is not defined
file:///home/ratijas/kde/usr/lib/qml/QtQuick/Controls.2/org.kde.desktop/private/TextFieldContextMenu.qml:132: ReferenceError: i18nc is not defined
file:///home/ratijas/kde/usr/lib/qml/QtQuick/Controls.2/org.kde.desktop/private/TextFieldContextMenu.qml:144: ReferenceError: i18nc is not defined
file:///home/ratijas/kde/usr/lib/qml/QtQuick/Controls.2/org.kde.desktop/private/TextFieldContextMenu.qml:158: ReferenceError: i18nc is not defined
file:///home/ratijas/kde/usr/lib/qml/QtQuick/Controls.2/org.kde.desktop/private/TextFieldContextMenu.qml:171: ReferenceError: i18nc is not defined
file:///home/ratijas/kde/usr/lib/qml/QtQuick/Controls.2/org.kde.desktop/private/TextFieldContextMenu.qml:186: ReferenceError: i18nc is not defined

EXPECTED RESULT
Not this.

SOFTWARE/OS VERSIONS
Operating System: Arch Linux
KDE Plasma Version: 5.23.80
KDE Frameworks Version: 5.87.0
Qt Version: 5.15.2
Kernel Version: 5.14.8-arch1-1 (64-bit)
Graphics Platform: X11
Processors: 8 × Intel® Core™ i7-6700HQ CPU @ 2.60GHz
Memory: 15.6 GiB of RAM
Graphics Processor: NVIDIA GeForce GTX 970M/PCIe/SSE2

ADDITIONAL INFORMATION
Comment 1 ratijas 2023-06-13 23:01:29 UTC
The i18n() function (as well as many others in that family) comes from a context object KLocalizationContext from KF::I18n package. This object should be initialized and set to QML engine in C++ code, there's currently no way around doing that. QQC2 Desktop Style, by not being a Tier 1 framework, can expect that i18n stuff will be set up by any calling code. On the other hand, for example Kirigami is a Tier 1 framework which can not depend on KI18n, so can only use simpler qsTr() functions in its components.

So, to sum up: these reference errors are not bugs in org.kde.desktop but an issue with me using a runtime without expected context object. To solve this problem I created `kqml` — QML runtime with initialized KLocalizedContext. Read more: https://invent.kde.org/plasma/plasma-sdk/-/merge_requests/79