Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85891

QCoreApplication::installTranslator without LanguageChange Event

    XMLWordPrintable

Details

    • All

    Description

      Installing or removing a QTranslator generates a LanguageChange event for the QCoreApplication instance. A QApplication instance will propagate the event to all toplevel widgets.

      Using the translator functionality within QML/Javascript modules and functions that are loaded dynamically the event is not necessary (the retranslateUi function for the new object is called anyway). The event bring a lot of degradation when using dynamics loaded modules that contains similar translation. In order to prevent translation conflicts, prior to call a QML/Javascript function, it necessary to install the translator and remove it after it is used.

      The installTranslator and removeTranslator functions use private members so it is not possible to modify the behavior by creating a derived class. In order to prevent the event a workaround is needed, consisting in setting that the nextLanguageChangeEvent should not be considered, and modify the event member function to do so.

      I suggest to modify the API of the member functions, by adding a parameter that let the developer decide if the LanguageChange event should be send or not
      For compatibility the parameters should default to true.

      bool QCoreApplication::installTranslator(QTranslator *translationFile, bool changeEvent = true)

      bool QCoreApplication::removeTranslator(QTranslator *translationFile, bool changeEvent = true)

      A further improvement could be to add a system that prevent translations defined in a module to interfere with other translations. Currently when two Translator contain the same context the last installed overwrite the previous one. That could easily bring translation conflicts when using modules created by different developers.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            cnn Qt Core & Network
            domezuk Domenico Zucchetti
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes