2

I'm trying to have a translated version of my installer which I've already created using a pre-built version of Qt installer framework, but the documentation is Inadequate and I need to know where I should put the translation file(en.qm file which I've translated to the destination language)

I've tried putting the translation file in the config folder and setting the <Translations> element in config.xml but nothing changes comparing to creating the installer without this element. the only progress that I've achieved was when I put the en.qm in one of package folders in meta folder and adding the <Translations> element in it's package.xml. but in this solution only half of the pages are translated.

this is the translation element which I've added to config.xml and package.xml
<Translations> <Translation>en.qm</Translation> </Translations>

when en.qm is added to package file in meta folder ,new pages and some of default pages are translated ,but the fist page( welcome...) and start menu shortcuts page and next and back buttons are never translated.


P.S:I need the installer in the my own language and the OS language is always English.


P.S_2:I'm using Qt 5.9.1 and pre-built Qt installer framework 3.0.6 and I have created the en.qm file using the following command on the installerfw.pro of the source code of installer framework releases version 3.0.6.
lupdate en.ts
and then
lrelease installerfw.pro -ts en.ts


Thank you

Amy jonas
  • 91
  • 6

1 Answers1

0

Unfortunately, you must translate each package separately.

I made a pri file for myself with the automation of the whole interpolator translation process.

Consider it in detail:

installer.pri

QT_DIR = $$dirname(QMAKE_QMAKE)
win32:LUPDATE = $$QT_DIR/lupdate.exe
unix:LUPDATE = $$QT_DIR/lupdate

win32:LRELEASE = $$QT_DIR/lrelease.exe
unix:LRELEASE = $$QT_DIR/lrelease


SUPPORT_LANGS = ru

# this file search function with a specific extension
defineReplace(findFiles) {
    patern = $$1
    path = $$2

    all_files = $$files(*$${patern}, true)
    win32:all_files ~= s|\\\\|/|g
    win32:path ~= s|\\\\|/|g

    for(file, all_files) {
        result += $$find(file, $$path)
    }

    return($$result)
}

# here we get a list of our installer's xml files (since each package must contain its own config.xml, I consider each xml file a potential package)
XML_FILES = $$files(*.xml, true)

# and for each language I support
for(LANG, SUPPORT_LANGS) {
    # i add run lupdate command for all js and ui files of package
    for(XML, XML_FILES) {
        FILE_PATH = $$dirname(XML)

        JS_FILES = $$findFiles(".js", $$FILE_PATH)
        UI_FILES = $$findFiles(".ui", $$FILE_PATH)

        commands += "$$LUPDATE $$JS_FILES $$UI_FILES -ts $$FILE_PATH/$${LANG}.ts"
        TS_FILES += $$FILE_PATH/$${LANG}.ts

    }

    # I also add commands to lrelease for each ts file I created 
    for(TS, TS_FILES) {
        commands += "$$LRELEASE $$TS"
    }
}

# and execute all the accumulated commands 
for(command, commands) {
    system($$command)|error("Failed to run: $$command")
}

All you need is to put this installer.pri file in the root directory of your installer and connect it in the main pro file

main.pro

include($$PWD/installer/installer.pri)

Andrey Yankovich
  • 868
  • 9
  • 13