How to use the translationDomain property of the KLocalizedContext class in qml?


In KLocalizedContext, there is a translationDomain attribute to set the domain of the translated file. According to the function description, it is possible to use this attribute in dynamic libraries, but I don’t know how to use it in dynamic libraries.
A similar problem occurs in plasma-settings, so that the translations of some plugins don’t take effect, such as the plugin kcm_mobile_power, despite the addition of the
add_definitions(-DTRANSLATION_DOMAIN="kcm_mobile_powermanagement") in CMakeLists.txt, but the translationDomain attribute I printed in the plugin’s main.qml is still kcm_mobile_power, so all the translations in the qml don’t work. None of the translations in the qml took effect. By looking at the code of kf6-kcoreaddons and kf6-kcmutils, it seems that the translation domain of the plugin depends on the name of the plugin, so how do I set it if the name is different from the name of the translation file? For example, the translation file name of the kcm_mobile_power plugin is kcm_mobile_powermanagement.

In this case the best thing to do is to rename the translation domain to match the plugin name: [kcms/power] Rename translation catalog to match plugin name (!485) · Merge requests · Plasma / Plasma Mobile · GitLab

Ok, thank you for your response.