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

Auto generated code for Qt Quick Application with multi-language is insufficient

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.4.2
    • Core: Locales (i18n)
    • None
    • All

    Description

      Summary of the issue

      When new QML project is created through Qt Creator with multi language support enabled, its add a .ts file and also, in main.cpp, add a process to load .qm file at start up. The CMakeLists.txt file doesn’t have any function to process the .ts file, so developer have to manually add functions in CMakeLists.txt or manually process the .ts file to generate .qm file and store them in Qt resource system. If the developer want to have the mechanism to automatically reload .qm file when language is changed, he/she have to have additional C/C++ implementation to make it possible. As QtCore already have automatic .qm file loading and reloading mechanism, it might be better the auto generated project code use the mechanism.

      Reproducible steps

      1. Create new Qt Quick Application in Qt Creator. At the Translation setting of the new project creation wizard, select any language and create the project.

      Expected behavior

      1. The auto generated project code uses QML engine's pre-embedded language file loading mechanism. For example
        • default name of .ts file is set to qml_<lang>.ts
        • No language file loading code in main.cpp. (Use QML engine's embedded functionalities instead).
        • CMakeLists.txt file have qt_add_translations function.Example:
          • qt_add_translations(<project name>
                TS_FILES
                i18n/qml_ja.ts
                i18n/qml_en.ts
                RESOURCE_PREFIX <URI of main.qml>/i18n
            )
          • (It seems qt_add_translations is deprecated in Qt6.4, there may be better code).

      Actual Behavior

      Autogenerated code have language file loading process in main.cpp. No .qm file generation mechanism in CMakeLists.txt file. 

      Note

      There are miltiple inconsistency for multi-language support in Qt6. I took a note for it.

      About QML Multi-language support inconsistency - Qt Site Japan - Global Site

      Attachments

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

        Activity

          People

            kkohne Kai Köhne
            takujikawata Takuji Kawata
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes