Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. internationalization support
QtWS25 Last Chance

internationalization support

Scheduled Pinned Locked Moved Solved Qt for WebAssembly
translations
15 Posts 4 Posters 1.3k 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 Offline
    S Offline
    SimonSchroeder
    wrote on 29 Jun 2023, 07:13 last edited by
    #6

    Within Qt, i.e. QFile, it doesn't matter if you have a regular file or an embedded file. In any case you install the translation with the corresponding path. I don't use WA, so I don't know how to access local files there. In order to embed a file you need to create a resource file (.qrc) and add the .qm file into it. Only then can you use paths starting with :/. And embedded files are part of the executable which hopefully work even when local files don't work with WA.

    Concerning local files: Are you using relative paths to access them? Then maybe the web app is running in a different folder than you are assuming. First try with absolute paths (just for testing) to see if local files work at all.

    G 1 Reply Last reply 29 Jun 2023, 08:29
    1
    • S SimonSchroeder
      29 Jun 2023, 07:13

      Within Qt, i.e. QFile, it doesn't matter if you have a regular file or an embedded file. In any case you install the translation with the corresponding path. I don't use WA, so I don't know how to access local files there. In order to embed a file you need to create a resource file (.qrc) and add the .qm file into it. Only then can you use paths starting with :/. And embedded files are part of the executable which hopefully work even when local files don't work with WA.

      Concerning local files: Are you using relative paths to access them? Then maybe the web app is running in a different folder than you are assuming. First try with absolute paths (just for testing) to see if local files work at all.

      G Offline
      G Offline
      Gilboonet
      wrote on 29 Jun 2023, 08:29 last edited by
      #7

      @SimonSchroeder For the moment I only tried to run the Web app (I mean with internationalization code) from Qt Creator. I'm using relative path, as I give a filename and a folder to translator.load(). I can change the folder to an absolute path, but I will also try to create a ressource file.

      J 1 Reply Last reply 29 Jun 2023, 08:55
      0
      • G Gilboonet
        29 Jun 2023, 08:29

        @SimonSchroeder For the moment I only tried to run the Web app (I mean with internationalization code) from Qt Creator. I'm using relative path, as I give a filename and a folder to translator.load(). I can change the folder to an absolute path, but I will also try to create a ressource file.

        J Offline
        J Offline
        JonB
        wrote on 29 Jun 2023, 08:55 last edited by
        #8

        @Gilboonet
        If you give any kind of relative path in your code you are relying on what the current working directory is when you run your application. And you don't know what that might be. Certainly it is likely to be different from what it is when you run from Creator.

        Paths for this sort of thing should always be either absolute file paths (possibly built with the help of QStandardPaths) or embedded resources paths. However these two work with WebAssembly. Using any relative path is just asking for trouble....

        G 1 Reply Last reply 29 Jun 2023, 09:26
        2
        • J JonB
          29 Jun 2023, 08:55

          @Gilboonet
          If you give any kind of relative path in your code you are relying on what the current working directory is when you run your application. And you don't know what that might be. Certainly it is likely to be different from what it is when you run from Creator.

          Paths for this sort of thing should always be either absolute file paths (possibly built with the help of QStandardPaths) or embedded resources paths. However these two work with WebAssembly. Using any relative path is just asking for trouble....

          G Offline
          G Offline
          Gilboonet
          wrote on 29 Jun 2023, 09:26 last edited by Gilboonet
          #9

          @JonB You're going too far too fast but as what I read from your posts you're prone to do so. It's not that I use any relative path, just that I used a function that needs one file name and one folder, function that was an example given by someone here and that worked on the Desktop Application it was given for. I simply start by using that working code and compile for Web Assembly to start from somewhere, but I would be happy to learn a way to get out of trouble from the start, digging into a new field where people here say that they don't use. And how is it that now you tell something about WebAssembly when just a few post before you told that you knew nothing about it (sorry I mismatch WA and QML)?

          J 1 Reply Last reply 29 Jun 2023, 10:44
          0
          • G Gilboonet
            29 Jun 2023, 09:26

            @JonB You're going too far too fast but as what I read from your posts you're prone to do so. It's not that I use any relative path, just that I used a function that needs one file name and one folder, function that was an example given by someone here and that worked on the Desktop Application it was given for. I simply start by using that working code and compile for Web Assembly to start from somewhere, but I would be happy to learn a way to get out of trouble from the start, digging into a new field where people here say that they don't use. And how is it that now you tell something about WebAssembly when just a few post before you told that you knew nothing about it (sorry I mismatch WA and QML)?

            J Offline
            J Offline
            JonB
            wrote on 29 Jun 2023, 10:44 last edited by JonB
            #10

            @Gilboonet said in internationalization support:

            You're going too far too fast

            I have no idea what this means, or what the rest of your post adds up to.

            It's not that I use any relative path

            You wrote earlier:

            I'm using relative path

            That's me being "prone to do so" is it?

            I explained what happens to a relative path. I explained that it will probably differ in what it resolves to between running desktop from Creator, running desktop outside Creator and running WebAssembly version. As a developer I'm sure you know what the current directory is, and how that works. If you really have a relative path then best of luck.

            One thing you could do: in your code immediately before passing whatever path you do to the translator check what QFile::exists() returns on the identical path. If it's false you have a problem.

            Anyway I don't know about WebAssembly so I will leave you to it.

            G 1 Reply Last reply 30 Jun 2023, 07:17
            1
            • G Offline
              G Offline
              Gilboonet
              wrote on 30 Jun 2023, 07:11 last edited by
              #11

              Looking at the documentation about Qt Resource System, I found an entry that seems to miss what needs to be added to the QMake project file (it's blank). I found it on the online version of the doc. Maybe this needs to be updated ?

              Screenshot_20230630_090644.png

              1 Reply Last reply
              0
              • J JonB
                29 Jun 2023, 10:44

                @Gilboonet said in internationalization support:

                You're going too far too fast

                I have no idea what this means, or what the rest of your post adds up to.

                It's not that I use any relative path

                You wrote earlier:

                I'm using relative path

                That's me being "prone to do so" is it?

                I explained what happens to a relative path. I explained that it will probably differ in what it resolves to between running desktop from Creator, running desktop outside Creator and running WebAssembly version. As a developer I'm sure you know what the current directory is, and how that works. If you really have a relative path then best of luck.

                One thing you could do: in your code immediately before passing whatever path you do to the translator check what QFile::exists() returns on the identical path. If it's false you have a problem.

                Anyway I don't know about WebAssembly so I will leave you to it.

                G Offline
                G Offline
                Gilboonet
                wrote on 30 Jun 2023, 07:17 last edited by
                #12

                @JonB Well I said I used a relative path AND added as i used a filename and a folder, that's certainly the fact that the folder part was not absolute that can lead to it being relative, that's not the same thing, and YES that is you being once again prone to going too far too fast, period. it's good news that you leave this to me, as on almost all your posts you start with stating that you don't know about this and that, then at the end you didn't help but only hammered things we all already know.

                J 1 Reply Last reply 30 Jun 2023, 08:11
                0
                • G Gilboonet
                  30 Jun 2023, 07:17

                  @JonB Well I said I used a relative path AND added as i used a filename and a folder, that's certainly the fact that the folder part was not absolute that can lead to it being relative, that's not the same thing, and YES that is you being once again prone to going too far too fast, period. it's good news that you leave this to me, as on almost all your posts you start with stating that you don't know about this and that, then at the end you didn't help but only hammered things we all already know.

                  J Offline
                  J Offline
                  JonB
                  wrote on 30 Jun 2023, 08:11 last edited by
                  #13

                  @Gilboonet
                  Great to hear. Sorry I wasted my time trying to help you. Stick to your relative paths, they are good. Best of luck.

                  G 1 Reply Last reply 30 Jun 2023, 09:39
                  0
                  • J JonB
                    30 Jun 2023, 08:11

                    @Gilboonet
                    Great to hear. Sorry I wasted my time trying to help you. Stick to your relative paths, they are good. Best of luck.

                    G Offline
                    G Offline
                    Gilboonet
                    wrote on 30 Jun 2023, 09:39 last edited by
                    #14

                    @JonB Well, here is is, by simply using Qt Resource System, it is working, absolutely not due to anything from you but all others who gave me good hints to follow instead of only criticizing.
                    Screenshot_20230630_113404.png
                    ( the menu is originally on french and using embedded resource .qm it is translated accorgindly to browser language.

                    J 1 Reply Last reply 30 Jun 2023, 09:48
                    0
                    • G Gilboonet has marked this topic as solved on 30 Jun 2023, 09:39
                    • G Gilboonet
                      30 Jun 2023, 09:39

                      @JonB Well, here is is, by simply using Qt Resource System, it is working, absolutely not due to anything from you but all others who gave me good hints to follow instead of only criticizing.
                      Screenshot_20230630_113404.png
                      ( the menu is originally on french and using embedded resource .qm it is translated accorgindly to browser language.

                      J Offline
                      J Offline
                      JonB
                      wrote on 30 Jun 2023, 09:48 last edited by JonB
                      #15

                      @Gilboonet
                      Nowhere did I criticize you at any point. Not once. Just tried to help. Politely, unlike your reponse.

                      Since you have expressed your opinion of my time and efforts in trying to help you, could you now please get off my case and stop putting in my name in your posts to express how dissatisfied you are with my unpaid efforts to aid you. Thanks.

                      1 Reply Last reply
                      0

                      15/15

                      30 Jun 2023, 09:48

                      • Login

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