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
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