Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to use Qt translation resources?
Forum Updated to NodeBB v4.3 + New Features

How to use Qt translation resources?

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.0k 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.
  • N Offline
    N Offline
    nen777w
    wrote on last edited by
    #1

    Each Qt library contains translation resources (files *.qm) which is usually located in:
    <QTFOLDER>/qtbase/translations/

    I want to include these files in my myapp_resources.qrc file, but I do not want to specify the full path, because in this case when I decide to change the Qt library, I should be changing these paths also.

    Is it possible to include these files in my resources using special macros like a, for example:

    <file>$QTFOLDER/qtbase/translations/qtbase_bg.qm</file>

    If these macros exist, which should use?

    If it's not possible then, how to use these resources?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      Actually the usual way is just deploying the translation files with the executable file.
      When you use windeployqt tool on Windows, some translation files will be copied just like the plugins by default.

      If you want to add them to the resource it is also possible.
      I think you can't use MACROs in qrc file.
      But you can use them in the .pro file and let it generate a qrc file for you.

      qm_file.files = $$[QT_INSTALL_TRANSLATIONS]/qtbase_bg.qm #can be multiple files
      qm_file.base = $$[QT_INSTALL_TRANSLATIONS] #add relative alias automatically
      qm_file.prefix = i18n
      RESOURCES += qm_file
      

      This will generate a qrc file qmake_qm_file.qrc in the build folder and add it to the Makefile.
      Then you would be able to access the file by :/i18n/qtbase_bg.qm.

      1 Reply Last reply
      5

      • Login

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