Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Several translation languages in same time
Forum Updated to NodeBB v4.3 + New Features

Several translation languages in same time

Scheduled Pinned Locked Moved General and Desktop
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.
  • N Offline
    N Offline
    nouch64
    wrote on last edited by
    #1

    Hi,

    By using the qsTr/qsTranslate... is it possible to specify which language to use ?
    I would like to be able to load several translations files, like French, Spanish, Chinese and display in same time the three translations.

    Here is an idea of what I'm expecting...

    For the loader, we charge 3 languages Fr/Cn/Es
    @
    QTranslator qt( 0 );
    qt.load( QString( "qml/i18n/lang_fr.qm" ), "." );
    app->installTranslator( &qt );
    qt.load( QString( "qml/i18n/lang_cn.qm" ), "." );
    app->installTranslator( &qt );
    qt.load( QString( "qml/i18n/lang_es.qm" ), "." );
    app->installTranslator( &qt );
    @

    For the implementation in QML (but it can be in C++ also)
    @
    Text {
    text: {
    var res = "";
    res += "FR:" + qsTr("fr", "hello") + "\n";
    res += "ES:" + qsTr("es", "hello") + "\n";
    res += "CN:" + qsTr("cn", "hello") + "\n";
    res += "DE:" + qsTr("de", "hello") + "\n"; // <-- this one would return "hello" as the language "de" is not loaded.

           return res;
       }    
    }
    

    @

    Thanks for your comments.
    Best regards.
    Nouch.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      No, this doesn't work. Qt only supports one translation at a time.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nouch64
        wrote on last edited by
        #3

        Hi,

        Thanks for the reply.
        I will try in that case to make it with some temporary containers and playing with the load/unload of the languages...

        I'l keep update the thread if I have a good solution.

        Best regards,
        Nouch.

        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