<?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[Qt Linguist: recover text to the base language]]></title><description><![CDATA[<p dir="auto">Hi everyone!</p>
<p dir="auto">I have the text table . In runtime I change the text language from lang1 (base lang) to lang2.<br />
Table text is saves to the file in the end of the process.</p>
<p dir="auto">Is it possible to recover text from lang2 to lang1 at the start of app or save text to file in base language?</p>
]]></description><link>https://forum.qt.io/topic/158069/qt-linguist-recover-text-to-the-base-language</link><generator>RSS for Node</generator><lastBuildDate>Fri, 06 Nov 2026 07:02:03 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/158069.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Aug 2024 16:03:50 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Tue, 06 Aug 2024 10:28:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sitesv">@<bdi>sitesv</bdi></a> said in <a href="/post/806681">Qt Linguist: recover text to the base language</a>:</p>
<blockquote>
<p dir="auto">I use QComboBox, that shows a list of the parameter variants. QComboBox is connected to the QTableWidget as a delegate.</p>
</blockquote>
<p dir="auto">Okay, I understand why this might get complicated. In a lot of cases it is sufficient to be able to compare the text that was read in from the file with a specific string (where we can use the translated string again).</p>
<p dir="auto">In your case, I suggest the following: For each entry in the QComboBox add the non-translated text as user data. When adding items you can use <code>QComboBox::addItem(tr(text),text)</code>. When the user selects something you get back the non-translated string using <code>comboBox-&gt;itemData(comboBox-&gt;currentIndex()).toString()</code>. Now, it gets slightly more complicated: Change from a QTableWidget to a QTableView. This also means that you need to write your own model class derived from <code>QAbstractItemModel</code>. Inside the model store the non-translated texts. The magic now happens with your derived class which needs to override <code>data(...)</code>. For the <code>DisplayRole</code> of this function you then return the translated string, i.e. only when displaying the string in the table will you translate the text and everything before that is the non-translated text. You can then still get out the non-translated text from the model (your own derived class) and store this in your xml file.</p>
]]></description><link>https://forum.qt.io/post/806697</link><guid isPermaLink="true">https://forum.qt.io/post/806697</guid><dc:creator><![CDATA[SimonSchroeder]]></dc:creator><pubDate>Tue, 06 Aug 2024 10:28:28 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Tue, 06 Aug 2024 13:23:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/simonschroeder">@<bdi>SimonSchroeder</bdi></a> Thank You!</p>
]]></description><link>https://forum.qt.io/post/806708</link><guid isPermaLink="true">https://forum.qt.io/post/806708</guid><dc:creator><![CDATA[sitesv]]></dc:creator><pubDate>Tue, 06 Aug 2024 13:23:50 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Tue, 06 Aug 2024 10:28:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sitesv">@<bdi>sitesv</bdi></a> said in <a href="/post/806681">Qt Linguist: recover text to the base language</a>:</p>
<blockquote>
<p dir="auto">I use QComboBox, that shows a list of the parameter variants. QComboBox is connected to the QTableWidget as a delegate.</p>
</blockquote>
<p dir="auto">Okay, I understand why this might get complicated. In a lot of cases it is sufficient to be able to compare the text that was read in from the file with a specific string (where we can use the translated string again).</p>
<p dir="auto">In your case, I suggest the following: For each entry in the QComboBox add the non-translated text as user data. When adding items you can use <code>QComboBox::addItem(tr(text),text)</code>. When the user selects something you get back the non-translated string using <code>comboBox-&gt;itemData(comboBox-&gt;currentIndex()).toString()</code>. Now, it gets slightly more complicated: Change from a QTableWidget to a QTableView. This also means that you need to write your own model class derived from <code>QAbstractItemModel</code>. Inside the model store the non-translated texts. The magic now happens with your derived class which needs to override <code>data(...)</code>. For the <code>DisplayRole</code> of this function you then return the translated string, i.e. only when displaying the string in the table will you translate the text and everything before that is the non-translated text. You can then still get out the non-translated text from the model (your own derived class) and store this in your xml file.</p>
]]></description><link>https://forum.qt.io/post/806697</link><guid isPermaLink="true">https://forum.qt.io/post/806697</guid><dc:creator><![CDATA[SimonSchroeder]]></dc:creator><pubDate>Tue, 06 Aug 2024 10:28:28 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Tue, 06 Aug 2024 10:24:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sitesv">@<bdi>sitesv</bdi></a> Ignore that user, it's spam!</p>
]]></description><link>https://forum.qt.io/post/806695</link><guid isPermaLink="true">https://forum.qt.io/post/806695</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Tue, 06 Aug 2024 10:24:35 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Tue, 06 Aug 2024 10:04:20 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/davidbland889">@<bdi>davidbland889</bdi></a>, thanks for reply.<br />
but I trying to figure out for possibility to resolve my case without external api. I think my case is simple and common  :)</p>
]]></description><link>https://forum.qt.io/post/806692</link><guid isPermaLink="true">https://forum.qt.io/post/806692</guid><dc:creator><![CDATA[sitesv]]></dc:creator><pubDate>Tue, 06 Aug 2024 10:04:20 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Tue, 06 Aug 2024 09:00:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a>, yes, I use QTranslator to change language.<br />
My case:<br />
I use QComboBox, that shows a list of the parameter variants. QComboBox is connected to the QTableWidget as a delegate.<br />
So, user selects one of the QComboBox variant (ver.1). After translation, this parameter contains translated version (ver.2) of the text. This text saves to the xml.<br />
But when the app starts and xml reads, variable has ver.2 and it can't be shown correctly.</p>
]]></description><link>https://forum.qt.io/post/806681</link><guid isPermaLink="true">https://forum.qt.io/post/806681</guid><dc:creator><![CDATA[sitesv]]></dc:creator><pubDate>Tue, 06 Aug 2024 09:00:45 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Tue, 06 Aug 2024 06:39:06 GMT]]></title><description><![CDATA[<p dir="auto">With Qt Linguist you are editing .ts files. These get converted to .qm files. The .qm files store the information in binary format as a hash table for quicker access. IIRC the base language string is saved alongside the translation because of possible collisions. However, Qt does not provide a way to access the original string (which you actually know when you are looking up the translation). Hash tables also just work well one way. It is not feasible to do the inverse look up. As the data is all stored inside the .qm file you could read that information yourself or change the Qt source code to give you the information you want.</p>
]]></description><link>https://forum.qt.io/post/806662</link><guid isPermaLink="true">https://forum.qt.io/post/806662</guid><dc:creator><![CDATA[SimonSchroeder]]></dc:creator><pubDate>Tue, 06 Aug 2024 06:39:06 GMT</pubDate></item><item><title><![CDATA[Reply to Qt Linguist: recover text to the base language on Mon, 05 Aug 2024 19:59:54 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">If you are using QTranslator, it's a one way translation from the original text in code to the one provided by QTranslator.</p>
<p dir="auto">You need to provide more information about your text table. What is it ? Is it user modifiable ? How do you save and restore it ?</p>
]]></description><link>https://forum.qt.io/post/806637</link><guid isPermaLink="true">https://forum.qt.io/post/806637</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Mon, 05 Aug 2024 19:59:54 GMT</pubDate></item></channel></rss>