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. Is there a way to use Linguist in Global context?
Forum Updated to NodeBB v4.3 + New Features

Is there a way to use Linguist in Global context?

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.9k Views 1 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.
  • A Offline
    A Offline
    alexander.merkel
    wrote on last edited by
    #1

    Hi,

    I need all string translations in all files. Is there a way to accomplish this in QML?

    Thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      What do you mean? lupdate will return you a TS file with all strings, both c++ and QML ones.

      You may need to use a .pro file hack to get it working, though:
      @
      lupdate_hack{
      SOURCES +=
      path/to/qml.qml
      path/to/qml2.qml
      }
      @

      This adds qml files to sources in view of lupdate, but does nothing in qmake's eyes. So your project will still compile, and all translations will be taken into account.

      (Z(:^

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alexander.merkel
        wrote on last edited by
        #3

        Thank you for the reply.

        I have already used the hack. And i am doing dynamic translation. Unfortunately I cannot use the approach suggested in "http://qt-project.org/wiki/How_to_do_dynamic_translation_in_QML":http://qt-project.org/wiki/How_to_do_dynamic_translation_in_QML since it will ultimately end in something like:

        main.qml
        @
        MyComponent{
        id: schnidee
        text: qstr("Schmext") + translate.getEmptyString()
        }@

        I want the user to be able to edit everything in design mode. But done like shown above he will see #qstr("Schmext") + translate.getEmptyString()# instead of "Schmext" in the editor.Secondly the translate functionality will not be automatically included if he drags MyComponent onto the canvas.

        So what i did is emit a languageChanged() signal to all MyComponents in C++ and catch it in QML by:

        MyComponent.qml
        @FocusScope{
        ...
        property string myCompText
        Text{
        signal languageChanged()
        id: subtext
        text: myCompText
        onLanguageChanged: text= qstr(myCompText)

        }
        ...
        }@

        Trouble is, the translation of the text the user thinks is in main.qml will actually be done in MyComponent.qml. And requiring the user to do complicated QtLinguist stuff to work around this is not my intention either.

        Since the overall amount of text will be rather small I could live with a global Translation. I want to get rid of the Context in QtLinguist or something like that. All translations may well be available in one global context.

        Thanks

        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