Here is a quote from the Qt documentation :
Some resources need to be modified based on a user locale, such as translation files or icons. This is done by adding the lang attribute to the qresource tag, specifying a suitable locale string. For instance:
<qresource> <file>cut.jpg</file> </qresource> <qresource lang="fr"> <file alias="cut.jpg">cut_fr.jpg</file> </qresource>
If the user's locale is French (that is, QLocale :: system (). Name () returns "fr_FR"): / cut.jpg becomes a link to the image cut_fr.jpg. For other locales, cut.jpg is used.
I am trying to do this and I am failing. Here is part of my * .qrc file:
<qresource> <file>HtmlTemplates/angle.html</file> <file>HtmlTemplates/bottom.html</file> <file>HtmlTemplates/top.html</file> </qresource> <qresource lang="en"> <file alias="HtmlTemplates/angle.html">HtmlTemplates/en/angle.html</file> <file alias="HtmlTemplates/bottom.html">HtmlTemplates/en/bottom.html</file> <file alias="HtmlTemplates/top.html">HtmlTemplates/en/top.html</file> </qresource>
As you can see, it exactly follows the same pattern as the example in the manual. However, an attempt to compile this file yields the following:
..\Blinky_2.0\resources.qrc: Warning: potential duplicate alias detected: 'angle.html' ..\Blinky_2.0\resources.qrc: Warning: potential duplicate alias detected: 'bottom.html' ..\Blinky_2.0\resources.qrc: Warning: potential duplicate alias detected: 'top.html'
And if I try to change the * .qrc file in QtCreator, it resets it to the wrong state, removing the lang attributes:
<qresource prefix="/"> <file>HtmlTemplates/angle.html</file> <file>HtmlTemplates/bottom.html</file> <file>HtmlTemplates/top.html</file> <file alias="HtmlTemplates/angle.html">HtmlTemplates/en/angle.html</file> <file alias="HtmlTemplates/bottom.html">HtmlTemplates/en/bottom.html</file> <file alias="HtmlTemplates/top.html">HtmlTemplates/en/top.html</file> </qresource>
So I have to iterate over resources for different locales in my code. Am I missing something or is it a Qt error? Qt version is 4.8.4, QtCreator version is 2.8.1.