2

I would like to translate my installer wizard (Qt Installer Framework based) in English or French (OS language depends).

I added those lines in the "installscript.qs" file :

Component.prototype.retranslateUi = function()
{
    component.languageChanged();
}

and I added those in "config.xml" file :

<Installer>
    ...
    <Translations>
        <Translation>fr.qm</Translation>
    </Translations>
</Installer>

But everything is ok (all long texts are translated) (in French) but the buttons like "Next", "Cancel", "Quit" are not translated (see the screenshot) :

enter image description here

ps: I don't want to use C++ code. (only Script or Xml)

John Smith
  • 133
  • 2
  • 12

2 Answers2

3

You need to load the Qt translation file in addition to your own .qm file(s). The file is located in the translation sub-folder of your Qt installation folder (e.g. ./usr/share/qt5/translations/). For some languages it seems sufficient to load qt_xx (where XX should be replaced with your locale), but for German I had to load "qtbase_XX" to translate the Next and Cancel buttons. In example for the fr locale they are named qt_fr.qm and qtbase_fr.qm.


EDIT:

Because of the comment of John Smith I checked the Installer framework source and the framework is not capable loading more than one translation file:

See installer-framework/src/libs/installer/component.cpp

/*!
     Loads the translations matching the name filters \a qms inside \a directory. Only translations
    with a base name matching the current locale's name are loaded. For more information, see
    \l{Translating Pages}.
*/
void Component::loadTranslations(const QDir &directory, const QStringList &qms)

So my original answer above (which would lead to a translated QWizard::CancelButton) is not working.

I got the Quit button of the Installer Frameworks translation example translated to German by correcting the de.ts file provided within the framworks source in installer-framework/src/sdk/translations

The original translation coming with the feramework is missing an &amp;:

So, changing:

<context>
    <name>QInstaller::IntroductionPage</name>
    ...
    <message>
        <source>Quit</source>
        <translation>Beenden</translation>
    </message>

to

<context>
    <name>QInstaller::IntroductionPage</name>
    ...
    <message>
        <source>&amp;Quit</source>
        <translation>Beenden</translation>
    </message>

and recompiling the Framework leads to a translated Quit button (Beenden) within the framework.

I did not tried, but studying /installer-framework/src/libs/installer/packagemanagergui.cpp should enable you to translate the Next button, too.

enter image description here

Community
  • 1
  • 1
MikeBergmann
  • 193
  • 2
  • 13
1

Adding a context may help:

function Component()
{
  qsTranslate("QInstaller::IntroductionPage", "&Quit");
}

It woked after Next and Back, but could not find where to write the qsTranslate().

huseyinkozan
  • 11
  • 1
  • 3