Googie
Googie

Reputation: 6017

Message in Qt doesn't get translated

I've created translation for my application. I've installed QTranslator instance with translations file loaded and it seems to be working, except for a single case and only that case.

There is one class with method, which looks like this:

QString MultiEditorNumeric::getTabLabel()
{
    return tr("Number");
}

The message was noticed by lupdate, I translated it and released with lrelease, but in runtime, the message returned from the method is still "Number".

I even modified method, because I couldn't belive it:

QString MultiEditorNumeric::getTabLabel()
{
    QString s = tr("Number");
    qDebug() << s;
    return s;
}

Yes, this is the exact place, where the number doesn't get translated. Debug message doesn't lie.

I release translations under file named with .qm suffix. This file is added to my project resources and is compiled into the binary. I've tried removing the qm file from resources and re-adding it, but it didn't help.

What else can I do? What can I check?

Upvotes: 0

Views: 146

Answers (1)

Googie
Googie

Reputation: 6017

My class didn't have Q_OBJECT macro in the class declaration. I didn't notice it from lupdate, because my script to run lupdate was silencing all messages from lupdate. I've added Q_OBJECT and it immediately started to work.

Upvotes: 1

Related Questions