Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to display text which are other than english ?

How to display text which are other than english ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 4 Posters 853 Views
  • 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.
  • D Offline
    D Offline
    divaindie
    wrote on last edited by
    #1

    In my QML application i want to display text in local language ,how i can achive this.
    example : suppose if i have to display "NEXT" in french ("suivant") what i have to do? please give me an example code?

    Button
    {
        height:50
        width:50
        text
       {
           anchor.centrein:parent;
           text:"NEXT";
       }
    }
    
    J.HilkJ ODБOïO 2 Replies Last reply
    0
    • D divaindie

      In my QML application i want to display text in local language ,how i can achive this.
      example : suppose if i have to display "NEXT" in french ("suivant") what i have to do? please give me an example code?

      Button
      {
          height:50
          width:50
          text
         {
             anchor.centrein:parent;
             text:"NEXT";
         }
      }
      
      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      hi @divaindie
      Qt has a couple of macros for that. in cpp you have tr("Your text goes in here") and in qml it is qsTr("Your text goes here")

      That way you can write your code in one language only, and once your finished, you extract those texts and create translations for them. Those can than be loaded at runtime later on.

      For more information check the docu:
      https://doc.qt.io/qt-5/internationalization.html


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      3
      • D Offline
        D Offline
        divaindie
        wrote on last edited by
        #3

        @J.Hilk said in How to display text which are other than english ?:

        That way you can write your code in one language only, and once your finished, you extract those texts and create translations for them. Those can than be loaded at runtime later on.

        basically i want have multi language feature ? i read about internationalization but i didn't understand how it works.also somewhere people mentioned about " QTextCodec" ,iam not able to figure out which one is better.
        also i want to know what are all the options available to achieve this?

        JonBJ 1 Reply Last reply
        0
        • D divaindie

          @J.Hilk said in How to display text which are other than english ?:

          That way you can write your code in one language only, and once your finished, you extract those texts and create translations for them. Those can than be loaded at runtime later on.

          basically i want have multi language feature ? i read about internationalization but i didn't understand how it works.also somewhere people mentioned about " QTextCodec" ,iam not able to figure out which one is better.
          also i want to know what are all the options available to achieve this?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @divaindie
          As @J-Hilk has pointed you to.
          Wrt QTextCodec, that is just for dealing with text encodings, e.g. Western European languages use a different encoding from Asian ones. In itself QTextCodec has absolutely nothing to do with translating strings from one language to another, so it's not some kind of "alternative" to doing the translation work. For that you still need tr(literal-string) macro or the https://doc.qt.io/qt-5/qtranslator.html class for dynamic look-up.

          1 Reply Last reply
          3
          • D divaindie

            In my QML application i want to display text in local language ,how i can achive this.
            example : suppose if i have to display "NEXT" in french ("suivant") what i have to do? please give me an example code?

            Button
            {
                height:50
                width:50
                text
               {
                   anchor.centrein:parent;
                   text:"NEXT";
               }
            }
            
            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #5

            @divaindie hi,
            see also :
            Internationalization and Localization with Qt Quick
            How to create a multi language application

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved