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. Multiple qrc files
Forum Updated to NodeBB v4.3 + New Features

Multiple qrc files

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 490 Views 3 Watching
  • 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.
  • PerdrixP Offline
    PerdrixP Offline
    Perdrix
    wrote on last edited by Perdrix
    #1

    We've just split our code into two projects. One project is the kernel or engine code that doesn't do GUI which is build into a static library. The other is the GUI code which is built to an executable.

    The GUI project has a set of ts files and "translations.qrc" that looks like:

    <!DOCTYPE RCC><RCC version="1.0">
    <qresource prefix="i18n">
        <file>DSS.ca.qm</file>
        <file>DSS.cs.qm</file>
        <file>DSS.de.qm</file>
        <file>DSS.en.qm</file>
              :
    </qresource>
    </RCC>
    

    The kernel project has ts filenames starting with DSSKernel. Can we have a qrc file in that project with (I assume) a different name than "translations" that looks like:

    <!DOCTYPE RCC><RCC version="1.0">
    <qresource prefix="i18n">
        <file>DSSKernel.ca.qm</file>
             :
    </qresource>
    </RCC>
    

    OR

    Do we neeed to modify translations.qrc so that it looks like:

    <!DOCTYPE RCC><RCC version="1.0">
    <qresource prefix="i18n">
        <file>DSS.ca.qm</file>
        <file>DSS.cs.qm</file>
        <file>DSS.de.qm</file>
        <file>DSS.en.qm</file>
              :
        <file>../../DSSKernel/i18n/DSSKernel.ca.qm</file>
    </qresource>
    </RCC>
    

    When we load the languages, can we "wild card" the names of the files to load? e.g.

    translatorFileName = QLatin1String("DSS*.");
    	translatorFileName += language;
    	qDebug() << "app translator filename: " << translatorFileName;
    	//
    	// Install the language if it actually exists.
    	//
    	if (theAppTranslator.load(translatorFileName, ":/i18n/"))
    	{
    		app.installTranslator(&theAppTranslator);
    	}
    

    So that both DSS and DSSKernel qm files are picked up?

    Many thanks
    David

    A S 2 Replies Last reply
    0
    • PerdrixP Perdrix

      We've just split our code into two projects. One project is the kernel or engine code that doesn't do GUI which is build into a static library. The other is the GUI code which is built to an executable.

      The GUI project has a set of ts files and "translations.qrc" that looks like:

      <!DOCTYPE RCC><RCC version="1.0">
      <qresource prefix="i18n">
          <file>DSS.ca.qm</file>
          <file>DSS.cs.qm</file>
          <file>DSS.de.qm</file>
          <file>DSS.en.qm</file>
                :
      </qresource>
      </RCC>
      

      The kernel project has ts filenames starting with DSSKernel. Can we have a qrc file in that project with (I assume) a different name than "translations" that looks like:

      <!DOCTYPE RCC><RCC version="1.0">
      <qresource prefix="i18n">
          <file>DSSKernel.ca.qm</file>
               :
      </qresource>
      </RCC>
      

      OR

      Do we neeed to modify translations.qrc so that it looks like:

      <!DOCTYPE RCC><RCC version="1.0">
      <qresource prefix="i18n">
          <file>DSS.ca.qm</file>
          <file>DSS.cs.qm</file>
          <file>DSS.de.qm</file>
          <file>DSS.en.qm</file>
                :
          <file>../../DSSKernel/i18n/DSSKernel.ca.qm</file>
      </qresource>
      </RCC>
      

      When we load the languages, can we "wild card" the names of the files to load? e.g.

      translatorFileName = QLatin1String("DSS*.");
      	translatorFileName += language;
      	qDebug() << "app translator filename: " << translatorFileName;
      	//
      	// Install the language if it actually exists.
      	//
      	if (theAppTranslator.load(translatorFileName, ":/i18n/"))
      	{
      		app.installTranslator(&theAppTranslator);
      	}
      

      So that both DSS and DSSKernel qm files are picked up?

      Many thanks
      David

      A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      @Perdrix You can use multiple qrc files, you just have to make sure they are added to each project where they are needed, and that you don't have naming conflicts in single resources.
      You may want to add aliases to your files so you can have a consistent naming scheme when accessing resources.

      1 Reply Last reply
      1
      • PerdrixP Perdrix

        We've just split our code into two projects. One project is the kernel or engine code that doesn't do GUI which is build into a static library. The other is the GUI code which is built to an executable.

        The GUI project has a set of ts files and "translations.qrc" that looks like:

        <!DOCTYPE RCC><RCC version="1.0">
        <qresource prefix="i18n">
            <file>DSS.ca.qm</file>
            <file>DSS.cs.qm</file>
            <file>DSS.de.qm</file>
            <file>DSS.en.qm</file>
                  :
        </qresource>
        </RCC>
        

        The kernel project has ts filenames starting with DSSKernel. Can we have a qrc file in that project with (I assume) a different name than "translations" that looks like:

        <!DOCTYPE RCC><RCC version="1.0">
        <qresource prefix="i18n">
            <file>DSSKernel.ca.qm</file>
                 :
        </qresource>
        </RCC>
        

        OR

        Do we neeed to modify translations.qrc so that it looks like:

        <!DOCTYPE RCC><RCC version="1.0">
        <qresource prefix="i18n">
            <file>DSS.ca.qm</file>
            <file>DSS.cs.qm</file>
            <file>DSS.de.qm</file>
            <file>DSS.en.qm</file>
                  :
            <file>../../DSSKernel/i18n/DSSKernel.ca.qm</file>
        </qresource>
        </RCC>
        

        When we load the languages, can we "wild card" the names of the files to load? e.g.

        translatorFileName = QLatin1String("DSS*.");
        	translatorFileName += language;
        	qDebug() << "app translator filename: " << translatorFileName;
        	//
        	// Install the language if it actually exists.
        	//
        	if (theAppTranslator.load(translatorFileName, ":/i18n/"))
        	{
        		app.installTranslator(&theAppTranslator);
        	}
        

        So that both DSS and DSSKernel qm files are picked up?

        Many thanks
        David

        S Online
        S Online
        SimonSchroeder
        wrote on last edited by
        #3

        @Perdrix said in Multiple qrc files:

        Can we have a qrc file in that project with (I assume) a different name than "translations" that looks like:

        Multiple qrc files are not a problem for Qt. You should just make sure that you don't have the same file names in different qrc files. This is not the case in your example.

        @Perdrix said in Multiple qrc files:

        So that both DSS and DSSKernel qm files are picked up?

        You cannot use a wildcard for this. Wildcards are usually resolved by the command line. So, you would need explicit code in any application (Qt or not) to resolve wildcards. However, the documentation for QTranslator talks about multiple translations:

        Multiple translation files can be installed in an application. Translations are searched for in the reverse order in which they were installed, so the most recently installed translation file is searched for translations first and the earliest translation file is searched last. The search stops as soon as a translation containing a matching string is found.

        So, you need to manually install both translation files to use them. The origin (i.e. two different qrc files) does not matter to QTranslator.

        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