Hmm... Your plugin class should contain a method to create a translator ready to install, something like:
struct MyPluginInterface {
virtual ~MyPluginInterface(){};
// ...
};
struct MyPluginInterface {
virtual ~MyPluginInterface(){};
virtual QTranslator *pluginTranslator(QString locale) = 0;
// ...
};
To copy to clipboard, switch view to plain text mode
Your plugin should implement it like so:
// you may need to change "this" to something else above
translator->load(":/translations/"+locale+".qm");
return translator;
}
QTranslator *MyPluginImplementation::pluginTranslator(QString locale){
QTranslator *translator = new QTranslator(this);
// you may need to change "this" to something else above
translator->load(":/translations/"+locale+".qm");
return translator;
}
To copy to clipboard, switch view to plain text mode
And your main app:
QObject *plugin
= loader.
instance();
if(plugin){
MyPluginInterface *piface = qobject_cast<MyPluginInterface*>(plugin);
qApp->installTranslator(piface->translator("pl_PL");
}
QObject *plugin = loader.instance();
if(plugin){
MyPluginInterface *piface = qobject_cast<MyPluginInterface*>(plugin);
qApp->installTranslator(piface->translator("pl_PL");
}
To copy to clipboard, switch view to plain text mode
You can try to load the translator directly from the plugin too instead of doing it in the main app.
Bookmarks