Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QLinguist and Chinese
Forum Update on Monday, May 27th 2025

QLinguist and Chinese

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
chinesetranslationstatic textembedded linux
12 Posts 4 Posters 7.7k 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.
  • S SGaist
    7 Mar 2016, 20:46

    Hi and welcome to devnet,

    Did you make your font available to your application using QFontDatabase ?

    G Offline
    G Offline
    Gazzer
    wrote on 7 Mar 2016, 23:05 last edited by
    #3

    @SGaist Hi, thanks for reply.

    Yes I sent a QChar(1000) character into the QLabel and it displayed the same character as on the PC using the same Chinese font - so I'm fairly sure the Font is installed and working.

    Again, thank you.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 8 Mar 2016, 07:45 last edited by
      #4

      The fact that it works on your desktop machine doesn't mean that it will on your target device. Did you at least deploy the font on your device ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      G 1 Reply Last reply 8 Mar 2016, 11:21
      0
      • S SGaist
        8 Mar 2016, 07:45

        The fact that it works on your desktop machine doesn't mean that it will on your target device. Did you at least deploy the font on your device ?

        G Offline
        G Offline
        Gazzer
        wrote on 8 Mar 2016, 11:21 last edited by
        #5

        @SGaist
        Hi, sorry there seems to be some misunderstanding.

        The font has been deployed both on the target device and the host (windows) development system.

        I have not written any Qt to run on the host - only on the embedded Linux target.

        So I have confirmed that Qt controls like QTextEdit and QLabel correctly display extended characters from the character set by correlating what is displayed appending QChar(0x1000) against what Word displays on the PC when I enter 1000<alt-x>.

        As I said, I think my issues are that the QM file is not gettting the correct unicode translation data or the QTranslator.load() command is somehow not loading the unicode from the QM file.

        Again, thank you.

        Regards,

        Gazzer.

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pablo J. Rogina
          wrote on 8 Mar 2016, 16:28 last edited by
          #6

          @Gazzer before focusing on .qm file I'd like to be sure the translation text file (.ts) is correct. I'm working with Spanish accented characters, and my .ts file is UTF-8 encoded, I can see the "special characters" Ok on Qt Linguist, and if I change the encoding to ANSI, I can see the 2+ bytes used by such special chars.

          So, are you experiencing all this the same as me? I mean, are you able to see the proper Chinese characters while creating the translations with Qt Linguist? What if you open the .ts file with a text editor?. Only after confirming that this is OK I'll move into the compilation phase (getting .ts into .qm file) as the culprit.

          Just my 2 cents.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          G 1 Reply Last reply 9 Mar 2016, 11:47
          0
          • P Pablo J. Rogina
            8 Mar 2016, 16:28

            @Gazzer before focusing on .qm file I'd like to be sure the translation text file (.ts) is correct. I'm working with Spanish accented characters, and my .ts file is UTF-8 encoded, I can see the "special characters" Ok on Qt Linguist, and if I change the encoding to ANSI, I can see the 2+ bytes used by such special chars.

            So, are you experiencing all this the same as me? I mean, are you able to see the proper Chinese characters while creating the translations with Qt Linguist? What if you open the .ts file with a text editor?. Only after confirming that this is OK I'll move into the compilation phase (getting .ts into .qm file) as the culprit.

            Just my 2 cents.

            G Offline
            G Offline
            Gazzer
            wrote on 9 Mar 2016, 11:47 last edited by
            #7

            @Pablo-J.-Rogina Thanks for reply. Yes, I have confirmed that the chinese characters are indeed in the .TS file by viewing with XMLNotepad. Also, I can close QLinguist down, restart and reload the .TS file and still view the chinese characters in the translation.

            I then used the Release command in QLinguist and created a new .QM file. I copied this to my target file system and modified by target app to QTranslate.load() this new .QM file but still only saw blanks or nothing where the Chinese should be. I made one of the translations half Chinese and half English just to confirm the translation is working and the English half only displays correctly...

            If you have a few more cents in your pocket I would be most grateful ha!

            Regards...

            1 Reply Last reply
            0
            • P Offline
              P Offline
              Pablo J. Rogina
              wrote on 9 Mar 2016, 13:45 last edited by
              #8

              @Gazzer it looks like my little piggy bank may not be empty yet... as lrelease is a likely suspect.

              Could you please check the following using an hex editor:

              1. Open the .ts file and look for any translation you made that have a Chinese character, taking at least 2 bytes. My example is a word containing accented o (ó) in Spanish, and that letter is encoded in UTF-8 as 0xC3B3.
              2. Open the .qm file (genereated using lrelease) and check the same word. In my case I just found it takes only 1 byte 0xF3) which is the rerepsentation for the same character ó in Latin1 and matches the Unicode entry point U+00F3.

              So the solution in your case seems to come from both a) adding CODECFORTR=UTF-8 to your .pro file, so lupdate and b) calling QTextCodec::setCodecForTr("UTF-8") from the application's main() function.

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              G 1 Reply Last reply 9 Mar 2016, 14:54
              0
              • P Pablo J. Rogina
                9 Mar 2016, 13:45

                @Gazzer it looks like my little piggy bank may not be empty yet... as lrelease is a likely suspect.

                Could you please check the following using an hex editor:

                1. Open the .ts file and look for any translation you made that have a Chinese character, taking at least 2 bytes. My example is a word containing accented o (ó) in Spanish, and that letter is encoded in UTF-8 as 0xC3B3.
                2. Open the .qm file (genereated using lrelease) and check the same word. In my case I just found it takes only 1 byte 0xF3) which is the rerepsentation for the same character ó in Latin1 and matches the Unicode entry point U+00F3.

                So the solution in your case seems to come from both a) adding CODECFORTR=UTF-8 to your .pro file, so lupdate and b) calling QTextCodec::setCodecForTr("UTF-8") from the application's main() function.

                G Offline
                G Offline
                Gazzer
                wrote on 9 Mar 2016, 14:54 last edited by
                #9

                @Pablo-J.-Rogina Thanks for the extra raid on your piggy bank... After your last comment. I then stepped through the target code and observed that the unicode characters were correctly being translated into a QString "/40000/40001/40002/40003" but not displayed on a QLabel. I then reconfirmed that the character QChar(1000) does display (and also confirmed the QLabel had the correct font set!) and can now only conclude that there are gaps in the font or glyphs that cannot render on our device but can on windows.

                As a reminder. I found a chinese ttf font (HanWang KaiBold-Gb5.ttf). Installed this on windows to get the translation text into QLinguist and then loaded on the embedded target - hoping to get exactly the same characters for each unicode.

                Thank you.

                1 Reply Last reply
                0
                • P Offline
                  P Offline
                  Pablo J. Rogina
                  wrote on 9 Mar 2016, 15:02 last edited by
                  #10

                  @Gazzer I'm glad that you find a workaround. If that finally solves you issue, please don't forget to mark this post as SOLVED.
                  Thank you.

                  Upvote the answer(s) that helped you solve the issue
                  Use "Topic Tools" button to mark your post as Solved
                  Add screenshots via postimage.org
                  Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                  G 1 Reply Last reply 9 Mar 2016, 15:27
                  0
                  • P Pablo J. Rogina
                    9 Mar 2016, 15:02

                    @Gazzer I'm glad that you find a workaround. If that finally solves you issue, please don't forget to mark this post as SOLVED.
                    Thank you.

                    G Offline
                    G Offline
                    Gazzer
                    wrote on 9 Mar 2016, 15:27 last edited by
                    #11

                    @Pablo-J.-Rogina I only discovered - with your help - my real problem. lack of a good or complete Chinese font. I also discovered that a ttf font does not work the same on embedded system as it does on windows.

                    Back to drawing board but thank you for your help...

                    1 Reply Last reply
                    0
                    • jovereschJ Offline
                      jovereschJ Offline
                      joveresch
                      wrote on 18 Mar 2016, 15:22 last edited by
                      #12

                      I am having this exact problem. I compiled my project for an embedded arm device, linux desktop, and windows desktop. The windows and linux hosts display the characters correctly, where the embedded device just shows nothing.

                      I'm using the Noto fonts https://www.google.com/get/noto/#sans-hans and am positive it is being used on the linux desktop, since if I don't copy the font into the same directory as the application, it just shows blocks. When the font is in the directory, it shows everything properly.

                      I tried the same thing with the embedded build, and nothing shows up. The font being loaded, since if it's not in the directory, it complains that it can't load it. Is there some extra switch or rendering tool/application that embedded linux needs? I've tried with both 'linuxfb' and 'egl' platforms with no success.

                      Thanks in advance for any help.

                      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