I have developed a Qt app and a plugin loaded with QPluginLoader
. I translated my plugin and created a .qm file, but plugin is not translated when I load this .qm file.
Here is my code :
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTranslator translator;
translator.load(QLocale::system(), "tr", "_",
QString("translations/myplugin"));
QCoreApplication::installTranslator(&translator);
I confirmed installTranslator
has succeeded, but no text is translated. Could you tell me how to translate text in plugin?
I can't tell much from your question, but once you installed your translator, you need to call it everytime you need to translate a word. It will give you something like this :
QString word;
if (word.toTranslate()) //you want a word translated
word = translator.tr("This will be translated");
else // you don't need a translation
word = "This will not be translated";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.