<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Translations and context]]></title><description><![CDATA[<p dir="auto">Hello<br />
I am trying to understand how Qt translation works.<br />
I have an application that has a label placed on it.<br />
The type of this label is derived from QLabel and provides a 'translate' method -<br />
@class StatusLabel: public QLabel<br />
{<br />
public:<br />
typedef enum<br />
{<br />
STOPPED,<br />
LIVE,<br />
HISTORICAL<br />
} status;</p>
<p dir="auto">StatusLabel(const QString &amp; text, QWidget * parent = 0, Qt::WindowFlags f = 0);<br />
virtual ~StatusLabel();</p>
<p dir="auto">void setStatus(const status s);</p>
<p dir="auto">void translate();</p>
<p dir="auto">private:<br />
status m_status;<br />
};<br />
@</p>
<p dir="auto">This is the implementation of the translate method</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> StatusLabel::translate()<br />
{<br />
switch (m_status)<br />
{<br />
case STOPPED:<br />
setText(tr("Stopped"));<br />
break;<br />
case LIVE:<br />
setText(tr("Live"));<br />
break;<br />
case HISTORICAL:<br />
setText(tr("Historical"));<br />
break;<br />
}<br />
}<br />
@</p>
<p dir="auto">And is called from my main window -</p>
<p dir="auto">@m_statusLabel-&gt;translate();@</p>
<p dir="auto">However the string is translated</p>
<p dir="auto">I think this has do with the context<br />
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.</p>
<p dir="auto">Could someone explain when Qt changes the context when translating strings and why my original implementation does not work</p>
<p dir="auto">Thanks very much</p>
]]></description><link>https://forum.qt.io/topic/24599/translations-and-context</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 09:32:47 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/24599.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 25 Feb 2013 12:34:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Translations and context on Mon, 25 Feb 2013 14:25:10 GMT]]></title><description><![CDATA[<p dir="auto">hi<br />
Yes translations are enabled and working in my app</p>
]]></description><link>https://forum.qt.io/post/168395</link><guid isPermaLink="true">https://forum.qt.io/post/168395</guid><dc:creator><![CDATA[GrahamL]]></dc:creator><pubDate>Mon, 25 Feb 2013 14:25:10 GMT</pubDate></item><item><title><![CDATA[Reply to Translations and context on Mon, 25 Feb 2013 13:42:06 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Did you enable translation in your application ?</p>
<p dir="auto"><a href="http://qt-project.org/doc/qt-4.8/i18n-source-translation.html#enabling-translation" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/i18n-source-translation.html#enabling-translation</a></p>
]]></description><link>https://forum.qt.io/post/168384</link><guid isPermaLink="true">https://forum.qt.io/post/168384</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 25 Feb 2013 13:42:06 GMT</pubDate></item></channel></rss>