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.
  • JasonWongJ JasonWong

    @Gilboonet

    In WASM, you can load the qm file like a normal Qt program, and then install it in the program, such as qApp->installTranslator. Why do you say that the qm file cannot be used?

    My WASM program can use qm files normally. It should be noted that these qm files are in qrc, not http/local files

    GilboonetG Offline
    GilboonetG Offline
    Gilboonet
    wrote on last edited by
    #3

    @JasonWong Thank you for your answer. What I did is simply first develop my application for desktop, with anything need for translation, and when it worked, I tried to compile it for WA, it compiles but even when I was with english locale it appears as in french (which is my default and was the language used on the Qt C++ project).

    I am brand new to Qt ecosystem and it's yesterday that I learnt that ":/" at the start of a directory string means that it uses Qt Resource System. But it was because of that ":/" that my Qt C++ Desktop application didn't work when I added internationalization code. So I certainly need to make it work correctly with that ":/" to have it also working for WA.

    JonBJ 1 Reply Last reply
    0
    • GilboonetG Gilboonet

      @JasonWong Thank you for your answer. What I did is simply first develop my application for desktop, with anything need for translation, and when it worked, I tried to compile it for WA, it compiles but even when I was with english locale it appears as in french (which is my default and was the language used on the Qt C++ project).

      I am brand new to Qt ecosystem and it's yesterday that I learnt that ":/" at the start of a directory string means that it uses Qt Resource System. But it was because of that ":/" that my Qt C++ Desktop application didn't work when I added internationalization code. So I certainly need to make it work correctly with that ":/" to have it also working for WA.

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

      @Gilboonet

      • :/ is special to Qt and indicates the file is actually a Qt resource embedded within the generated executable.
      • Without the leading :/ it refers to an external file.

      I don't know anything about QML or translator files, whether they work with or without resources or you can choose. But you should discover how WebAssembly access resource files if they are allowed, or external files, depending on which you use.

      GilboonetG 1 Reply Last reply
      0
      • JonBJ JonB

        @Gilboonet

        • :/ is special to Qt and indicates the file is actually a Qt resource embedded within the generated executable.
        • Without the leading :/ it refers to an external file.

        I don't know anything about QML or translator files, whether they work with or without resources or you can choose. But you should discover how WebAssembly access resource files if they are allowed, or external files, depending on which you use.

        GilboonetG Offline
        GilboonetG Offline
        Gilboonet
        wrote on last edited by
        #5

        @JonB No QML for this project, It's Qt C++. Indeed for the moment I started making it as a Desktop project, and after I made installer for Linux and Windows, I tried to compile it for WA and it worked even if I needed to change the way it accessed local files to be able to save/load in order to make it fully usable on a browser. Then I tried to add 3d support and it was not possible using Qt3D so I tried QML but didn't find a way to access local files from QML, so I fallback to OpenGL ES 2.0 3D that works for WA but what was easy to do using Qt3D seems much harder with that. Then I finally added translation and I need to dig the way WA access resources files again to use the .qm files.

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SimonSchroeder
          wrote on 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.

          GilboonetG 1 Reply Last reply
          1
          • S SimonSchroeder

            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.

            GilboonetG Offline
            GilboonetG Offline
            Gilboonet
            wrote on 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.

            JonBJ 1 Reply Last reply
            0
            • GilboonetG Gilboonet

              @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.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on 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....

              GilboonetG 1 Reply Last reply
              2
              • JonBJ JonB

                @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....

                GilboonetG Offline
                GilboonetG Offline
                Gilboonet
                wrote on 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)?

                JonBJ 1 Reply Last reply
                0
                • GilboonetG Gilboonet

                  @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)?

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on 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.

                  GilboonetG 1 Reply Last reply
                  1
                  • GilboonetG Offline
                    GilboonetG Offline
                    Gilboonet
                    wrote on 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
                    • JonBJ JonB

                      @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.

                      GilboonetG Offline
                      GilboonetG Offline
                      Gilboonet
                      wrote on 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.

                      JonBJ 1 Reply Last reply
                      0
                      • GilboonetG Gilboonet

                        @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.

                        JonBJ Offline
                        JonBJ Offline
                        JonB
                        wrote on 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.

                        GilboonetG 1 Reply Last reply
                        0
                        • JonBJ JonB

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

                          GilboonetG Offline
                          GilboonetG Offline
                          Gilboonet
                          wrote on 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.

                          JonBJ 1 Reply Last reply
                          0
                          • GilboonetG Gilboonet has marked this topic as solved on
                          • GilboonetG Gilboonet

                            @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.

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on 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

                            • Login

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