Fix i18n when the kcm code is embedded in the plasmoid config
ClosedPublic

Authored by aacid on Nov 1 2018, 6:55 PM.

Details

Summary

You can get to this code by right clicking on the plasmoid, when doing that the kcm translation catalog is not loaded so we must make all th1 i18n calls be i18nd calls and specify the catalog manually

Test Plan

it works

Diff Detail

Repository
R115 Plasma Audio Volume Applet
Branch
Plasma/5.14
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 4447
Build 4465: arc lint + arc unit
aacid created this revision.Nov 1 2018, 6:55 PM
Restricted Application added a project: Plasma. · View Herald TranscriptNov 1 2018, 6:55 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
aacid requested review of this revision.Nov 1 2018, 6:55 PM
broulik added a subscriber: broulik.Nov 1 2018, 9:31 PM

This is only covering an underlying problem where KDeclarative fails to set the translation context on QQmlContext as the engines are shared and it then refuses to set anything on the "internal context". But since I haven't found a solution, perhaps this is better than having non-translated UI

aacid added a comment.Nov 1 2018, 10:40 PM

This is only covering an underlying problem where KDeclarative fails to set the translation context on QQmlContext as the engines are shared and it then refuses to set anything on the "internal context". But since I haven't found a solution, perhaps this is better than having non-translated UI

Where in kdeclarative/plasma-framework are you trying to set the translation context?

I had a quick look without knowing anything about the architecture and it seems ConfigViewPrivate::init would be the place, but there's nothing there. Or you mean you tried and it didn't work and that's why the code isn't there?

Anyhow the thing is, it can't work, you're using this code "as a library", and what you have to do in library code is hardcode the translation domain since there can only be one "default domain" and obviously that's the applet here and not the kcm (which acts as a library).

The thing is that most of the times in library C++ code we don't see ourselves hardcoding the domain via i18nd calls because we use the -DTRANSLATION_DOMAIN trick to do it for us, but since QML isn't compiled we can't have anything that, so for QML that can show in various processes we need to use i18nd.

We use everything in Plasma "as a library", that's why KDeclarative::QmlObject sets a translation context on the root context, so that plasmoids, wallpaper plugins, and other QML bits can use i18n with no translation domain (only exception really being the look and feel packages). I'm too tired to explain right now but note when you run the KCM from within Plasma you get a warning like:

QQmlContext: Cannot set context object for internal context.
QQmlContext: Cannot set property on internal context.

That is what breaks the translations in this case and used to work until we shared QQmlEngines between the KCM and the window around it. However, if we don't then the KCM uses the Plasma Qt Quick Controls style which is also undesirable. We also don't want separate QQmlEngines as then you run into bugs and crashes since we would have objects (e.g. context properties and singletons) between engines and they clean up each other's stuff and crash.

aacid added a comment.Nov 5 2018, 9:58 AM

Ok, understood, there's a plan to maybe make it work but isn't really working.

Can i commit this today so it gets in Plasma 5.14.3 and our users get to understand the UI?

davidedmundson accepted this revision.Nov 16 2018, 2:05 PM

Sure, lets get this into stable till a magic fix comes along

This revision is now accepted and ready to land.Nov 16 2018, 2:05 PM
aacid closed this revision.Nov 17 2018, 8:47 AM