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. Lrelease optimization: removal of unused translation
QtWS25 Last Chance

Lrelease optimization: removal of unused translation

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
4 Posts 3 Posters 2.8k 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.
  • O Offline
    O Offline
    ozbum
    wrote on last edited by
    #1

    Hi All,

    Good day, I am very new to QT and have a question about lrelease.

    Currently, we have our own tool that generates TS files from a string database, all strings from this database and its translations are copied to the TS files. My question is, does lrelease has option to automatically excludes unused strings when generating the QM files?

    Thank you very much

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by mostefa
      #2

      Hi @ozbum

      What do you mean by unused strings? do mean that they do not need to be translated ?

      with qt linguist when you need to translate a string you need to write it on your .cpp file in this way :

      tr("your string");
      

      if string does not need to be translated you have to wirte it without tr , just like this :

      ("your string");
      

      then when lupdate will be executed he will search all strings marked with tr() and will on put it on your .ts file

      Also string that was used in the past , and that become no more used on the context can be marked obsolete , on your .ts file like this:

      <message>
          <location filename="your source or ui file" line="190"/>
          <source>text need to translate</source>
          <translation type="obsolete">your translated text</translation>
      </message> 
      

      Or obsolete text will be ignored by lrelease,

      this can done automatically with qt linguist hmi assistant ,

      I advise you to read more in this part of qt linguist doc :

      for qt 4:

      http://doc.qt.io/qt-4.8/linguist-translators.html#strings-window

      for qt 5:

      http://doc.qt.io/qt-5/linguist-translators.html#selecting-context-to-translate

      Hope this will answer to your question

      1 Reply Last reply
      0
      • O Offline
        O Offline
        ozbum
        wrote on last edited by
        #3

        Hi Mostefa,

        Thnak you for replying to my question.

        All strings are translated by our in-house tool (we are not using QT Linguist) and all of them are generated in the TS file. The problem is, not all strings are needed by the application. Is there a way to exclude unused strings when generating the QM file? Please note that the custom TS generator does not know which string is being use by the application that is why all strings are generated in the TS file. Can't mark strings as obsolete because another application may be using it.

        Regards,

        1 Reply Last reply
        0
        • jeanmilostJ Offline
          jeanmilostJ Offline
          jeanmilost
          wrote on last edited by
          #4

          Personally I would open a command prompt and use something like that:
          lupdate.exe "MyProjDir" -ts "MyProjDir\myapp_fr_CH.ts" "MyProjDir\myapp_pt_BR.ts" "MyProjDir\myapp_ja.ts" -no-obsolete

          Thus all files containing strings to translate in my project directory will be updated in my .ts files (in this case the FR_CH, PT_BR and JP languages), but all the strings which are not included in my project will be discarded from the .tr files by the -no-obsolete option.

          And only then, I would call the lresease tool.

          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