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

A more comfortable way of switching languages and locale in Qt Quick apps

    XMLWordPrintable

Details

    • All

    Description

      Since 5.10, Qt provides QQmlEngine::retranslate(). This helps to switch the UI to a new language in the app w/o restarting the app, for example switching from English to German in the UI.

      Still, quite some additional code is required to get this done:

      • the language code should be attached to a base name of the compiled language (qm) files
      • Most probably, the locale should be switched to match the new language
      • Ideally, the same module should provide a list of available languages to the UI which then can be directly used in settings of the app.

      One of the projects in Qt has already implemented this as a QML plugin and used this system in a reference UI:

      https://code.qt.io/cgit/qt-apps/neptune3-ui.git/tree/plugins/translation

      After an initial review, it was seen as impossible to add this functionality a new generic API, since it would lead to a dependency on QtCoreApplication. Plus, retranslate() is an expensive operation leading to reevaluation of all bindings.

      Since this code remains the same in any app and would be needed in basically any Qt Quick app which provides UI in multiple languages, it might make sense to provide this functionality as an additional module Qt Declatative or Qt Quick.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            vminenko Vladimir Minenko
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            2 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes