<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Remy Mongin, Author at Be on the Right Side of Change</title>
	<atom:link href="https://blog.finxter.com/author/remymongin/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.finxter.com/author/remymongin/</link>
	<description></description>
	<lastBuildDate>Wed, 16 Sep 2020 12:36:38 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.finxter.com/wp-content/uploads/2020/08/cropped-cropped-finxter_nobackground-32x32.png</url>
	<title>Remy Mongin, Author at Be on the Right Side of Change</title>
	<link>https://blog.finxter.com/author/remymongin/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Python Application Translation With Qt Linguist</title>
		<link>https://blog.finxter.com/python-application-translation-with-qt-linguist/</link>
		
		<dc:creator><![CDATA[Remy Mongin]]></dc:creator>
		<pubDate>Wed, 16 Sep 2020 12:25:36 +0000</pubDate>
				<category><![CDATA[Python]]></category>
		<guid isPermaLink="false">https://blog.finxter.com/?p=13169</guid>

					<description><![CDATA[<p>The translation of an application is usually a fastidious and painful process. Hopefully, Qt provides excellent support for translating into local language applications developed in C++ or Python.  Qt lets you load language translation files into an application at run-time. This means that application texts (i.e., menus, screen titles, field labels, help files, etc.) are ... <a title="Python Application Translation With Qt Linguist" class="read-more" href="https://blog.finxter.com/python-application-translation-with-qt-linguist/" aria-label="Read more about Python Application Translation With Qt Linguist">Read more</a></p>
<p>The post <a href="https://blog.finxter.com/python-application-translation-with-qt-linguist/">Python Application Translation With Qt Linguist</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>The translation of an application is usually a fastidious and painful process.</p>



<p>Hopefully, Qt provides excellent support for translating into local language applications developed in C++ or <a href="https://blog.finxter.com/python-crash-course/" target="_blank" rel="noreferrer noopener" title="Python Programming Tutorial [+Cheat Sheets]">Python</a>. </p>



<p>Qt lets you load language translation files into an application at run-time. This means that application texts (i.e., menus, screen titles, field labels, help files, etc.) are displayed in the local language.&nbsp;</p>



<p>Qt uses its QString class exclusively to manage the strings. This comprehensive class handles Unicode, the world standard for Text and Emoji, natively.</p>



<p>In this article, I will explain the translation process step-by-step. However, I will not go through the tool’s details because <a href="https://www.qt.io/qt-for-python" target="_blank" rel="noreferrer noopener" title="https://www.qt.io/qt-for-python">Qt provides excellent documentation</a> and many tutorials are available on the Web.</p>



<h2 class="wp-block-heading">Software Requirements</h2>



<p>Apart from Python interpreter and your favorite Python IDE, you will have to install the <strong>qt package</strong>. Qt includes a comprehensive set of tools like <strong>pylupdate5</strong>, <strong>lrelease </strong>and <strong>pyrcc5 </strong>for translating applications into local languages. I will come back to these tools below.</p>



<p><em><strong>Remark</strong>: Although it’s not the subject of this article, I strongly recommend you to use <a href="https://blog.finxter.com/python-virtual-environments-with-venv-a-step-by-step-guide/" target="_blank" rel="noreferrer noopener" title="Python Virtual Environments with “venv” — A Step-By-Step Guide">virtual environments</a> (virtualenv or anaconda) for project development. This is one of the essential tools that most of the <a href="https://blog.finxter.com/how-do-python-developers-make-money-other-than-freelancing/" target="_blank" rel="noreferrer noopener" title="How Do Python Developers Make Money Other Than Freelancing?">Python developers</a> use.</em></p>



<h2 class="wp-block-heading">Translation Process</h2>



<p>You will find hereunder a schema showing the translation process:</p>



<div class="wp-block-image"><figure class="aligncenter is-resized"><img fetchpriority="high" decoding="async" src="https://lh5.googleusercontent.com/z5YxcH23a7FM3cOZyBx4eNoeVmSnm5kciJaYhEkV8xgkJ6XTBhhntUpaKQo6yEF2XawMuZv7m3X7lqr1tjA4WlDqEzuALMwYEjwav6wSA75-3BNy62xVfahyf3h-MkQvmw" alt="" width="800" height="500"/></figure></div>



<p>Depending on the type and the size of a project, the developer and the translator can be one unique person.&nbsp;</p>



<p>For the creation of the application’s GUI part, there are two options for the developer:</p>



<ol class="wp-block-list"><li>Use <strong>Qt Designer</strong>, a&nbsp; tool for designing and building graphical user interfaces with <a href="https://doc.qt.io/qt-5/qtwidgets-index.html">Qt Widgets</a>. The Widgets and forms created with Qt Designer can be integrated seamlessly with programmed code. Furthermore, all the properties which are set in Qt Designer can be changed dynamically within the application code.</li></ol>



<ol class="wp-block-list" start="2"><li>Use the Python modules provided by Qt to implement and configure the widgets into the application code manually.</li></ol>



<p>You will find hereunder a quick overview of the process steps:</p>



<ul class="wp-block-list"><li>Step 1 (optional): Design and build the GUI part with Qt Designer.</li><li>Step 2 (optional): Convert the Qt Designer’s files into python files.</li><li>Step 3: Implement the code needed for the translation process.</li><li>Step 4: Creation or update of the translation files.</li><li>Step 5:  Translation of the texts.</li><li>Step 6: Convert translation files into binary files.</li><li>Step 7 (optional): Convert the translation binary files into a python resources module.<br></li></ul>



<h2 class="wp-block-heading">Preparation of the Python application code</h2>



<h3 class="wp-block-heading">GUI code generated by Qt Designer</h3>



<p>If the developer uses the Qt Designer tool to build the GUI, he must first convert the Qt source file (.ui) into a Python source file (.py). This conversion is performed by executing the <strong>pyuic5 </strong>tool (step 2). I recommend using a batch file for this. Here is an example:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/9P8VB7qHBGdIXJVsuG_fpoUfM6VnohvbXmsRRTXI_xym-sN9ttE8v67BgVCuYT2btkrLONbwD89oVWSI5P-BwwTbNvZbXXK8EmZjqIOGhyrtlizwM3hMiSQ1hjA7kIKKnQ" alt=""/></figure>



<p><strong>Pyuic5 </strong>tool automatically adds at the end of the python file a function dedicated to the translation. This <a href="https://blog.finxter.com/how-to-define-a-function-with-default-arguments-in-python/" target="_blank" rel="noreferrer noopener" title="How to Define a Function with Default Arguments in Python?">function </a>translates all the strings found in the Qt source file by using the Qt <strong>translate </strong>function. So the developer doesn’t need to perform additional action regarding the texts:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/9QuJdrqzkviswOnmYtnkOp5HpeUZuQrB0koGty9piN_qUmXE8NWeezSUljy6HWJyQImpd6tRlF4ecakWodIik5GTLkfj7ggN9UOTSdAk_UPPqH9jbArhmswM8sqziNW2Aw" alt=""/></figure>



<h3 class="wp-block-heading">GUI code generated manually</h3>



<p></p>



<ul class="wp-block-list"><li>If the developer builds the GUI manually, he must prepare the code by calling the Qt <strong>translate</strong> function for each string which requires translation (step 3). To make the code more readable, I recommend you to implement the following <strong>tr()</strong> function:</li><li></li></ul>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/-We_857Rkd4Ow3gFm51NRuOHtvAPHtMKJXDNe07QhQnshM4URTqTTvwPPDdrg_l0gru_uz4Ccl4ZvgxPBx76ZQmD7B4WxnxyI9luy-QH1HnyjdMEAiv20IxUwgl6XQQklQ" alt=""/></figure>



<p>Then, the developer just has to call the <code>tr()</code> function for each text to be translated:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/KtoMB_ZA2IulnwCdRr9JrVMc4xvbXA-eIoSjdqAIHQ1UWnSuF5lx1SiHBGp4vdVFoTzKQB6Hkrajj2tpZRi0050ek-nwU8gDDjC-iLdNVKGyYSzbKAhBeRGREa64PVxwLg" alt=""/></figure>



<h2 class="wp-block-heading">Translation Files (.ts)</h2>



<p>The translation files (.ts) must be either created if not existing or updated if a&nbsp; text has been added, modified, or removed. The developer has to use a specific file (.pro) to configure how the translation files will be generated:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/azYK1Hzg4yA8ADNcYlS1hv060BPb29ivQnVDN7IPIup5ajtg972RFq-zo-183EwPblXk8YP9M7FFmuW1IYN4mSaYhmW5Spo8suDJC4EvsxXUFav3AB17KMcKO5MPbNptaw" alt=""/></figure>



<ul class="wp-block-list"><li>SOURCES: Python source files containing the texts to translate</li><li>TRANSLATIONS: Language files. The file’s name is composed of the application name followed by the language and, finally, the .ts extension. See the next chapter for additional information regarding the language.</li></ul>



<p>The developer has to use the <strong>pylupdate5 </strong>Qt tool to generate the translation files:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh3.googleusercontent.com/pBcSlJXnwfFKg5iwxQVwOcOLf6EjWF__b1rw4kWLNSv28TdKsNfPRTWSU0ahL5a2nT3y9hP-V9_TZ8iXkspNL0E3cVlQrqkR954kq4tM3z8-aXDJxAa4JjbGppG6G2McVw" alt=""/></figure>



<p>The execution of this batch file will automatically generate the two translation files specified in the .pro configuration file, namely <em>pptslidegenerator.fr.ts</em> and <em>pptslidegenerator.en.ts</em>.</p>



<h2 class="wp-block-heading">Local Language Code</h2>



<p>The language used in the translation file’s name must follow strict rules. It is composed of the first letters group of the language string compliant with RFC 1766. In the following table, you will find an extract of the commonly supported language strings provided by Microsoft (<a href="https://docs.microsoft.com/en-us/windows/win32/wmformat/language-strings">Microsoft Language Strings</a>):</p>



<figure class="wp-block-table is-style-stripes"><table><tbody><tr><td><strong>Language strings</strong></td><td><strong>Description</strong></td></tr><tr><td>en-us</td><td>English (United Kingdom)</td></tr><tr><td>en-gb</td><td>English (United States)</td></tr><tr><td>de</td><td>German (Germany)</td></tr><tr><td>es</td><td>Spanish</td></tr><tr><td>it</td><td>Italian (Italy)</td></tr><tr><td>fr</td><td>French (France)</td></tr></tbody></table></figure>



<p>Thanks to the Python <em>locale </em>module and its <em>getdefaultlocale </em>function, it’s possible to retrieve the computer system’s local language. This allows us to load the right language file at the application startup automatically. The <em>getdefaultlocale </em>function tries to determine the default locale settings. If the call is successful, it returns them as a tuple of the form (<strong>language code</strong>, encoding). The <strong>language code</strong> is composed of two parts, the language, and the country:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh6.googleusercontent.com/deMagS8bOfItCRQ6ZuWB7NAJqLoWC52EG87Pc1jFvToF-BvB-nK-mvTlllSBGI1DfhP29g7YWg0I4xLasu7t3yuAbdMM5Gfw9WpC-aP5UuU0Qx-sBx7Ul5D3gRf0M7hg-g" alt=""/></figure>



<p>As we are interested only by the language, the developer has to use the following code:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/Iqs9I0Ak5yv93DlQ10o2Zfct51ie-VAPc9jI-OivMwv5xfqB_KXG9BxeIaXcHSm2xdQUvAtyjgq-4tKjq-kohmdj33ZBLkgzSMM9e1rzNZu9R_3kTG66VFtbvG56tEfrZg" alt=""/></figure>



<p><img decoding="async" src="https://lh3.googleusercontent.com/F8TSVguvG60UXtfW6vEFk1R88Sl1sumOvAdJrpU3KylgBG0njD0qEBrFeerBrovl9_1nT0FtKnuxv1bG5jJLSrf0SuLf9dYUSY3oTfcA98i71qNVF5GttM9k0CFOjBsz0w" width="48" height="48"></p>



<h2 class="wp-block-heading">Translation with Qt Linguist </h2>



<p>Qt Linguist is a handy tool used to makes text translation very easy.&nbsp;</p>



<p>The translator has first to open a .ts translation file (step 5). It’s also possible to open all the translation files simultaneously to translate the texts in different languages in parallel. The translator can now proceed to the translation of the different texts:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/w7TNog9nMRTFrgKpaS-GmjEQpTdTLzhyu8HA2YiAXM47IPyIoOJ7rLp5cy_X1YxB7nwfH00zecW1ENLL-zcAnekLY_Wde4ixYTqNNCUTq9nQ7XKQbGrptncDkE-dyKGfVQ" alt=""/></figure>



<p>Let’s have a quick look at the different sections of this window:</p>



<ul class="wp-block-list"><li><strong>Context</strong>: The Context view lists the contexts in which the strings to be translated appear. In this example, @default corresponds to the <em>pptslidegenerator.py</em> project file as MainWindow corresponds to the <em>mainwin.py</em> file (MainWindow is the object name set in Qt Designer for the main window). The number of translated strings is mentioned on the right side.</li></ul>



<ul class="wp-block-list"><li><strong>Strings</strong>: The Strings view lists the strings found in a context. These strings were extracted thanks to the presence of the tr() or translate() function into the source code. The following table indicates the current translation state for each string:</li></ul>



<figure class="wp-block-table is-style-stripes"><table><tbody><tr><td><strong>State</strong></td><td><strong>Icon</strong></td><td><strong>Description</strong></td></tr><tr><td>Accepted/<br>Correct</td><td><img decoding="async" src="https://lh6.googleusercontent.com/MK5eSfPVE1lakKaXOCxGz82HkJtccrMNQ-OLHId30jImt_kz6VV1rdUJVDKOEF-MxEYj2ZRT6Ypzu3wnbgeeCywlhzi2-WFna-_KXOmBumpIbvK6HrA-mJM-H-UAyjOfCQ" width="16" height="16"></td><td>The translator has accepted the translation, and the translation passed all the <a href="https://doc.qt.io/qt-5/linguist-translators.html#validating-translations">validation tests</a>. If the translation field is empty, the translator has decided to leave it blank.&nbsp;</td></tr><tr><td>Accepted/<br>Warnings</td><td><img loading="lazy" decoding="async" src="https://lh6.googleusercontent.com/vjsQfO3wiYGlu_LHFsWTZtKScaMmRPhos0pnTm2bD4zkNiPjOiMfFsebx6Cvs6FyrUPcm3RoVH-VQPAbi2KjjVrXHbecaKqHH2lJ5_iihpxfPzqy6iV5yZVpCEDp7zkQUw" width="16" height="16"></td><td>The translator has accepted the translation, but the translation didn’t pass all the validation tests. The validation test failures are displayed in the Warnings view.&nbsp;</td></tr><tr><td>Not Accepted</td><td><img loading="lazy" decoding="async" src="https://lh3.googleusercontent.com/aafsOYiTSZFdH7awMjbEU_yIIJNzGV9SlnSfTN5Zkh7VHdbEqF7-33KXMXDZHpSXJh65CXCe4L3tSRwr3XPRxQHhpzif4Pu4t9-O8ZUTIW9Tq2QyRxIe_R9YAqQJNgO04Q" width="16" height="16"></td><td>The string has a translation that passed all the validation tests, but the translator didn’t accept the translation yet.&nbsp;</td></tr><tr><td>No Translation</td><td><img loading="lazy" decoding="async" src="https://lh4.googleusercontent.com/PdatQxcUQhjBF4YuyPUsQCs-EQszDg8Up53xORRcdvScFbnYuj9SxpCCKJECo0gBB0MF-5y_WL8e_Vv34Flkqt3GJvctjfSyVgJASF4N1tJGW16pmLxj6biPR5nNNgGh7A" width="16" height="16"></td><td>There is no translation for the string.</td></tr><tr><td>Validation Failures</td><td><img loading="lazy" decoding="async" src="https://lh4.googleusercontent.com/rV8H2PqD1LuVChAstNqzO265ja7tml1mtC0IvDt1EsRUlWpMG6DXft0AuIKci06UWJdnx4RFyy2YT4aXNMjk8WEEq8S1cp-9Zo5zBhMmsyZQfyD-ZTcsMf8Auoylk8d5Cw" width="16" height="16"></td><td>The string has a translation, but the translation didn’t pass all the validation tests. Validation test failures are displayed in the Warnings view.&nbsp;</td></tr><tr><td>Obsolete</td><td><img loading="lazy" decoding="async" src="https://lh4.googleusercontent.com/A3v1Yg_HL2iohwHen4x6_L2X-vw8C4vIXnMhQ5soEljYyckoeTXyDqAyzHikbHJc7q7fGXthdvg4JYN8VfLRLL1sWSCZMc5WTM5KRrsepnp2w5WM5pbGWDwBeFepkG89KA" width="16" height="16"></td><td>The string is obsolete because it is no longer used in the context.&nbsp;</td></tr></tbody></table></figure>



<ul class="wp-block-list"><li><strong>Translation area</strong> (middle right): Area dedicated to translating the current string in the <strong>Translation </strong>field. Based on the translation file’s name, Qt Linguist automatically detects the language used for the translation.<br>If the string can be translated in the plural, Qt Linguist will ask for two translations: one in the singular (&#8220;<em>There is %n file</em>&#8220;) and one in the plural (&#8220;<em>There are %n files</em>&#8220;).<br></li><li><strong>Warnings</strong>: The Warnings view lists all texts that fail validation tests.&nbsp;</li></ul>



<p>Once the translator has completed the translation and validation of all the texts, he must save the translation file(s).</p>



<h2 class="wp-block-heading">Compilation of Translation Files</h2>



<p>The translator must compile the translation file(s) into a <strong>.qm</strong> binary format (step 6). The easiest way for the translator consists of using the Qt Linguist integrated release function (“<em>Release</em>” if only one file is open or “<em>Release All</em>” for multiple files):</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/mYFSS8IzpT5-J5zuUou9FptlZmOUyx3Wrzaxm-xNu9OigxE1Y7vKJUzcMpBm9TgLWbN1IoKWDTbZAxAkIe8eQoKSsCETV3uzAn4UtVQ8_YZC_DzjTIjrhcO3iAVFf2uh7w" alt=""/></figure>



<p>To keep your application’s coherence, I strongly recommend storing your binary translation files with other resources (logo, pictures, etc.) into a specific resources folder:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh4.googleusercontent.com/d_jJTib83RLaYCcawaPvXd-qD7wC6QKRAWAZi9xdqHtex6pR07A_EP916sCrypYGBS8jPaN87yqsYQAVGgWQDzDR3jovHbQDBnW7Mn4NHdVz9Vrq6N8jvAx_a8kmvd88xg" alt=""/></figure>



<p>Resources folder:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh3.googleusercontent.com/hPKWCSJ_4ITaPk0E9qie9gdbDZaO14CPnnTP8CrRwtmC310pr-RyXmAdCmtw9CCCbQWjGH7idIvnF8_VjANP0uyNwOT6beQe5UueAfbjDqzneveqtwKVLLbvHluDtlGVNw" alt=""/></figure>



<h2 class="wp-block-heading">Loading of Translation File(s) into Python Application</h2>



<p>The last step of the process consists of loading the translation files into the application. When the developer decides to distribute the application, two options are available for the resources files:<br></p>



<ol class="wp-block-list"><li>Distribute the application with the resources files folder, which will be separate from the application’s executable.</li></ol>



<ol class="wp-block-list" start="2"><li>Compile the resources files into a <a href="https://blog.finxter.com/how-to-search-and-replace-a-line-in-a-file-in-python/" target="_blank" rel="noreferrer noopener" title="How to Search and Replace a Line in a File in Python?">Python file</a>, which will be part of the application’s executable (step 7, recommended solution).</li></ol>



<p>For option <strong>B</strong>, the developer must first update the resources file <strong>Resources.qrc</strong> generated by Qt Designer by adding the translation binary files:</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/itydAUz-RS0bYRWSBdzFWiaM58EhKDf498a5Q76khV_Ob5rNC6xPF3MmSD8fCP-cIXJzTwUJA_tC-cs2vXDMhcka9yRAe61LeyKYVYg0NZqQpL5ts8nZsHGHaFD3gbLHMw" alt=""/></figure>



<p>The section related to the language is defined inside the <strong>qresource</strong> tag.</p>



<p>Then, the developer has to use the <strong>pyrcc5 </strong>Qt tool to generate the Python resources file which will contain all the compiled resources (logo and translation files in our example):</p>



<figure class="wp-block-image"><img decoding="async" src="https://lh5.googleusercontent.com/qi0IaWx0hJjOVcKrT_pT9TJxxFIFOtXR1coIPxysqjJXhlTeTJNmQ_5diD6YkcQy2pOGaFJOsavrNipJciB8rqTIDAF7SUK5QSOmeV2MhN4nEm1VFkse7fZSc_DOn7bHUQ" alt=""/></figure>



<p>You will find hereunder the code to implement with the specificities related to each option (<strong>A</strong><strong> </strong>or <strong>B</strong>):</p>



<ul class="wp-block-list"><li><strong>Modules import</strong><img decoding="async" src="https://lh4.googleusercontent.com/gdNIsJ961Sf6kxy_gKlTda_uY-N-nWpNvGwLewnmHPbMQ7T8WKC5MkZ6tBrvJufmLbw8De6Gg0deEif95Nws6nga09ysXAGKv4fOl_n9kMGhaOJfpa59-RUAHewyM0TLew" width="2311.893239101607" height="1420.8210867227426"></li></ul>



<p>&nbsp;&nbsp;&nbsp; <strong>A</strong>:<br><img decoding="async" src="https://lh4.googleusercontent.com/gdNIsJ961Sf6kxy_gKlTda_uY-N-nWpNvGwLewnmHPbMQ7T8WKC5MkZ6tBrvJufmLbw8De6Gg0deEif95Nws6nga09ysXAGKv4fOl_n9kMGhaOJfpa59-RUAHewyM0TLew" width="2311.893239101607" height="1428.9202192894995"></p>



<p><strong>B</strong>:&nbsp;</p>



<ul class="wp-block-list"><li><strong>Translator class initialization</strong><img decoding="async" src="https://lh6.googleusercontent.com/WBvZv3rFCf9CQSW_D-xO7LvumAVcxvyWC3xIh3kcQa6pcXM32vtzZ27mNmFbnjvZdLaMgi5XVw0Cs00ONk-7IfZ4GYF5WR4wNLRTaPrBUQNFgzM4g0GlYQKTEXOdiCLHUA" width="2207.783656830274" height="1353.9939636703944"></li></ul>



<p><strong>A </strong><strong>/</strong><strong> B</strong>:</p>



<p><img decoding="async" src="https://lh5.googleusercontent.com/Iqs9I0Ak5yv93DlQ10o2Zfct51ie-VAPc9jI-OivMwv5xfqB_KXG9BxeIaXcHSm2xdQUvAtyjgq-4tKjq-kohmdj33ZBLkgzSMM9e1rzNZu9R_3kTG66VFtbvG56tEfrZg" width="1823.64611325854" height="1121.704882102306"></p>



<p><strong>A</strong>:&nbsp;</p>



<p><img decoding="async" src="https://lh4.googleusercontent.com/Fhv8UV-45NGzGCTl_4vc8BS3AwIiNMrFQUZIFoOz3X6HaTjdw4MW8UlgdnCI_MTUSFqWRFwsuXugNuVnceeoBqJKuBlVVAeDIhLJdVlZEVHyEkkejV94W54NFG5zF0VLCw" width="1863.6265284259146" height="1132.8386678293257"></p>



<p>We recognize in this code the language determined with the <em>getdefaultlocale </em>function. Furthermore, we have to add a specific <em>resource_path</em> function to get the path of the resources folder.&nbsp;&nbsp;&nbsp; This is particularly important when the developer decides to &nbsp;&nbsp;&nbsp; bundle the application and all its dependencies into a single executable. It’s indeed due to the fact that, when started, the executable creates a temporary folder named _MEIxxxxxx (xxxxxx is a random number) in the appropriate &nbsp;&nbsp;&nbsp; temporary folder location for this Operating System.<br><img decoding="async" src="https://lh4.googleusercontent.com/Y39nMXv34u-ms0inFnxdhDc_S-qCE2UjJ54ZIUoP_JIhpZxmNcz6r8R1m-QGpoqAaJcmuorV4H6Aae7ka27S__1w3O8wrSGJh-HMhiJR2TehN-qtvk0pWSrO8mh6R52ezw" width="1886.6812322266333" height="1147.4842307134406"></p>



<p><strong>B</strong>:&nbsp;</p>



<ul class="wp-block-list"><li><strong>Language Change</strong></li></ul>



<p>Thanks to the following code, it’s possible to change the language at run-time:&nbsp;&nbsp;&nbsp;<br><img decoding="async" src="https://lh4.googleusercontent.com/yyhpb1Ob-rBseIddRjigzrNt6b9GJAbegtDd5wFFoHvWBFloPCd7GVhlmsQefwROYcwAU-BVxawsK40R_Ipcbijr69fhu1gfofqp3fVykpod1jJPVozWtPW9yIYDFZBqug" width="2131.332959586374" height="1301.625773485848"></p>



<p><strong>A</strong>:</p>



<p><img decoding="async" src="https://lh6.googleusercontent.com/jFPo0VkCkbPLY70dfewqQKfkPEt0pGjaVYlM60QKP2xosWCyV3-PnLu9_znFuTqqIofP1Fe5KgylD-e5UPBVDDSp78b4X9iari2LLtbb7qMb0-FGt87jM31oN6GiObO3WA" width="2390.807596848695" height="1468.9883932737762"></p>



<p><strong>B</strong>:</p>



<h2 class="wp-block-heading">Conclusion</h2>



<p>As you may have noticed, translating Qt applications is a very well thought process and everything is planned.</p>



<p>You now have all the tools in hand to broadcast your program anywhere in the world, you just need to find the good translator!&nbsp;&nbsp;</p>
<p>The post <a href="https://blog.finxter.com/python-application-translation-with-qt-linguist/">Python Application Translation With Qt Linguist</a> appeared first on <a href="https://blog.finxter.com">Be on the Right Side of Change</a>.</p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: blog.finxter.com @ 2026-04-10 04:18:53 by W3 Total Cache
-->