Translations and context
-
Hello
I am trying to understand how Qt translation works.
I have an application that has a label placed on it.
The type of this label is derived from QLabel and provides a 'translate' method -
@class StatusLabel: public QLabel
{
public:
typedef enum
{
STOPPED,
LIVE,
HISTORICAL
} status;StatusLabel(const QString & text, QWidget * parent = 0, Qt::WindowFlags f = 0);
virtual ~StatusLabel();void setStatus(const status s);
void translate();
private:
status m_status;
};
@This is the implementation of the translate method
@void StatusLabel::translate()
{
switch (m_status)
{
case STOPPED:
setText(tr("Stopped"));
break;
case LIVE:
setText(tr("Live"));
break;
case HISTORICAL:
setText(tr("Historical"));
break;
}
}
@And is called from my main window -
@m_statusLabel->translate();@
However the string is translated
I think this has do with the context
In Linguist the strings are associated with the StatusLabel context and if I directly call the translator with this context I get the translated string.Could someone explain when Qt changes the context when translating strings and why my original implementation does not work
Thanks very much
-
Hi,
Did you enable translation in your application ?
http://qt-project.org/doc/qt-4.8/i18n-source-translation.html#enabling-translation
-
hi
Yes translations are enabled and working in my app