Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Localizing Qt Quick Apps

Localizing Qt Quick Apps

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
localizationtranslations
5 Posts 2 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ekkescornerE Offline
    ekkescornerE Offline
    ekkescorner
    Qt Champions 2016
    wrote on last edited by
    #1

    while evaluating Qt 5.6 for Android / iOS and preparing blogs with recipes for BlackBery Cascades developers HowTo go with Qt 5.6 I run into a problem.

    Using Cascades (qt 4.8) and Eclipse Momentics translation is easy:

    Open Projectfile (bardescriptor.xml)
    add languages
    

    and you're done. All the work under the hood: creation of .ts files and generating .qm files was done automagically.
    I only had to use QtLinguist, translate the strings, save, go back to Eclipse Momentics, refresh and run on device.

    Have expected something similar with Qt Creator and learned that there are many (for newcomers confusing - steps of file creation, copy files, running commands from commandline ...:
    https://blog.qt.io/blog/2014/03/19/qt-weekly-2-localizing-qt-quick-apps/

    fortunately I found this article:
    https://wiki.qt.io/Automating_generation_of_qm_files

    then looked at the .pro from mentioned sample:
    https://qt.gitorious.org/qt-labs/weather-app?p=qt-labs:weather-app.git;a=blob_plain;f=weatherapp.pro;hb=HEAD

    tried to understand all what happened inside the .pro and thought that I added the important parts to a .pro file from my sample. project.
    Here's the .pro - the part below qml.qrc was inserted by me

    TEMPLATE = app
    
    QT += qml quick
    
    CONFIG += c++11
    
    SOURCES += main.cpp
    
    # Additional import path used to resolve QML modules in Qt Creator's code model
    QML_IMPORT_PATH =
    
    # Default rules for deployment.
    include(deployment.pri)
    
    RESOURCES += qml.qrc
    
    # var, prepend, append
     defineReplace(prependAll) {
         for(a,$$1):result += $$2$${a}$$3
         return($$result)
     }
    # Supported languages
    LANGUAGES = de en
    # Available translations
    TRANSLATIONS = $$prependAll(LANGUAGES, $$PWD/translations/EkkesSampleApp_, .ts)
    # Used to embed the qm files in resources
    TRANSLATIONS_FILES =
    # run LRELEASE to generate the qm files
    qtPrepareTool(LRELEASE, lrelease)
     for(tsfile, TRANSLATIONS) {
         qmfile = $$shadowed($$tsfile)
         qmfile ~= s,\\.ts$,.qm,
         qmdir = $$dirname(qmfile)
         !exists($$qmdir) {
             mkpath($$qmdir)|error("Aborting.")
         }
         command = $$LRELEASE -removeidentical $$tsfile -qm  $$qmfile
         system($$command)|error("Failed to run: $$command")
         TRANSLATIONS_FILES += $$qmfile
     }
    
     # TRANSLATIONS - Create extra targets for convenience
     wd = $$replace(PWD, /, $$QMAKE_DIR_SEP)
     # LUPDATE - Make new targets for each and all languages
     qtPrepareTool(LUPDATE, lupdate)
     LUPDATE += -locations relative -no-ui-lines
     TSFILES = $$files($$PWD/translations/QuickForecast_*.ts) $$PWD/translations/EkkesSampleApp_untranslated.ts
     for(file, TSFILES) {
         lang = $$replace(file, .*_([^/]*)\\.ts, \\1)
         v = ts-$${lang}.commands
         $$v = cd $$wd && $$LUPDATE $$SOURCES $$APP_FILES -ts $$file
         QMAKE_EXTRA_TARGETS += ts-$$lang
     }
    

    Getting an error:

    12:14:37: Starting: "/usr/bin/make" 
    /daten/_QT/5.6/android_armv7/bin/qmake -spec android-g++ CONFIG+=debug CONFIG+=qml_debug -o Makefile ../EkkesSampleApp/EkkesSampleApp.pro
    lrelease error: Cannot open /daten/_qt_work/EkkesSampleApp/translations/EkkesSampleApp_de.ts: No such file or directory
    Project ERROR: Failed to run: /daten/_QT/5.6/android_armv7/bin/lrelease -removeidentical /daten/_qt_work/EkkesSampleApp/translations/EkkesSampleApp_de.ts -qm /daten/_qt_work/build-EkkesSampleApp-Android_f_r_armeabi_v7a_GCC_4_9_Qt_5_6_0-Debug/translations/EkkesSampleApp_de.qm
    make: *** [Makefile] Error 3
    12:14:37: The process "/usr/bin/make" exited with code 2.
    Error while building/deploying project EkkesSampleApp (kit: Android für armeabi-v7a (GCC 4.9, Qt 5.6.0))
    When executing step "Make"
    

    Am I missing anything ?
    Or do I have to add something to the project ?
    Tried creating the folder translations inside project outside QtCreator from OSX Finder but didn't help.
    Or must folders added another way from inside Qt Creator ?

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.8 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you call lupdate once before calling lrelease ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      ekkescornerE 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        Did you call lupdate once before calling lrelease ?

        ekkescornerE Offline
        ekkescornerE Offline
        ekkescorner
        Qt Champions 2016
        wrote on last edited by
        #3

        @SGaist I did it exactly as described above.
        there's a lupdate at the end

        I followed the sample from wiki

        please can you tell me what exactly I should insert into the .pro and where ?

        this kind of stuff is new for me - in cascades it was handled automatically udner the hood

        thanks

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.8 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I meant call it by hand the first time to generate the .ts files

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          ekkescornerE 1 Reply Last reply
          0
          • SGaistS SGaist

            I meant call it by hand the first time to generate the .ts files

            ekkescornerE Offline
            ekkescornerE Offline
            ekkescorner
            Qt Champions 2016
            wrote on last edited by
            #5

            @SGaist generation of qm files works if at first lupdate was run manually.
            so the part of creation of ts files from
            https://wiki.qt.io/Automating_generation_of_qm_files
            doesn't work as expected

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.8 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved