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. Can lupdate extract strings translated with QTranslator::translate()?

Can lupdate extract strings translated with QTranslator::translate()?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
4 Posts 3 Posters 812 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.
  • Mark A. GreenM Offline
    Mark A. GreenM Offline
    Mark A. Green
    wrote on last edited by
    #1

    In the project I'm working on, all of the GUI will be separated into an application constituting the View of an MVC model. The Controller and Model will live in a DLL/dylib/etc. This DLL will be used as a service and any number of host applications (including non-Qt applications) will be able to load and use that service DLL. As such, the service will not contain any GUI objects. However, there is still a need for the Controller DLL to query the user for information from time-to-time, for example: "The file you are opening is an older configuration, do you want to update it?" YES/NO

    For these latter cases we intend to use a callback function where the Controller can ask the host application (View) to open message box and return the result. The strings used to populate that message box would be constructed and managed in the Controller code. Since the Controller doesn't have access to a QApp it won't have access to the tr() macro. However, we do wish for our translation vendors to only need a single method to manage translated strings, i.e. through QtLinguist. It seems that we can have a separate set of string resources for the Controller DLL and that with the absence of a QApp we can create our own QTranslator objects and manage the string resources manually.

    All this brings me to my actual question. The strings in the Controller DLL will not be using the tr() macro from either QObject or QApp, instead they will use the QTranslator::translate() method directly. So the question is, when the lupdate tool is used to extract translatable strings, will it extract strings that are being translated through the QTranslate::translate() method or will it only see strings if they use tr()?

    Thanks,
    ~Mark

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

      Hi,

      Why about using the technique showed in Translating non Qt classes ?

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

      1 Reply Last reply
      1
      • Mark A. GreenM Mark A. Green

        In the project I'm working on, all of the GUI will be separated into an application constituting the View of an MVC model. The Controller and Model will live in a DLL/dylib/etc. This DLL will be used as a service and any number of host applications (including non-Qt applications) will be able to load and use that service DLL. As such, the service will not contain any GUI objects. However, there is still a need for the Controller DLL to query the user for information from time-to-time, for example: "The file you are opening is an older configuration, do you want to update it?" YES/NO

        For these latter cases we intend to use a callback function where the Controller can ask the host application (View) to open message box and return the result. The strings used to populate that message box would be constructed and managed in the Controller code. Since the Controller doesn't have access to a QApp it won't have access to the tr() macro. However, we do wish for our translation vendors to only need a single method to manage translated strings, i.e. through QtLinguist. It seems that we can have a separate set of string resources for the Controller DLL and that with the absence of a QApp we can create our own QTranslator objects and manage the string resources manually.

        All this brings me to my actual question. The strings in the Controller DLL will not be using the tr() macro from either QObject or QApp, instead they will use the QTranslator::translate() method directly. So the question is, when the lupdate tool is used to extract translatable strings, will it extract strings that are being translated through the QTranslate::translate() method or will it only see strings if they use tr()?

        Thanks,
        ~Mark

        kshegunovK Offline
        kshegunovK Offline
        kshegunov
        Moderators
        wrote on last edited by
        #3

        So the question is, when the lupdate tool is used to extract translatable strings, will it extract strings that are being translated through the QTranslate::translate() method or will it only see strings if they use tr()?

        I don't believe so. You can use QT_TR_NOOP to mark things for translation, however I question the wisdom of not having QCoreApplication . It's a requirement for QObjects and you are most probably going to experience weirdness (and possibly crashes) without it.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply
        3
        • Mark A. GreenM Offline
          Mark A. GreenM Offline
          Mark A. Green
          wrote on last edited by
          #4

          Thanks for the replies. Yes, it seems QT_TR_NOOP and QT_TRANSLATE_NOOP are what I was looking for in the absence of QCoreApplication, and Q_DECLARE_TR_FUNCTIONS in the case where QCoreApplication is available. Whether we have QCoreApplication available or not is still an open question, but something for a different discussion thread I think.

          Thanks again,
          ~Mark

          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