No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Quasar i18n and Localazy

    Help
    3
    7
    373
    Loading More Posts
    • 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.
    • B
      btmi last edited by btmi

      I saw a demo of Localazy here: https://vaclavhodek.com/how-to-localize-vuejs-app-with-vue-i18n-and-localazy and I LOVE the idea of outsourcing my localisation via an online portal so I thought I would check it out.

      I got everything working to a point, and before I contact Localazy - has anyone got their library working? From what I can see it is expecting a straight js file and so:

      {
        "helloworld": "Hello World!"
      }
      

      works but the default format for a quasar language file:

      export default {
        helloworld: "Hello World!"
      }
      

      Does not, and neither does the export have the correct header. I can use intermediate files of course (which is what I am doing for testing) but is there a more elegant way?

      1 Reply Last reply Reply Quote 0
      • B
        btmi last edited by

        I have answered my own question: all that was required was to use the file type js instead of json and it works beautifully.

        Nice stuff!

        dobbel 1 Reply Last reply Reply Quote 0
        • dobbel
          dobbel @btmi last edited by

          @btmi

          That’s a great find! Could you explain what the (possible) extra steps are to integrate Localazy with Quasars i18n?

          B 1 Reply Last reply Reply Quote 0
          • B
            btmi @dobbel last edited by

            @dobbel It is really very easy.

            Follow the instructions here to set up internationalization
            https://quasar.dev/options/app-internationalization

            Sign up to the Localazy service to get your application keys

            Add the localazy.json file to the root of your app with content like this:

            {
            
              "writeKey": "[your write key]",
              "readKey": "[your read key]",
              
              "upload": {  
                "type": "js",
                "files": "src/i18n/en-us/index.js"
              },
              
              "download": {
                "files": "src/i18n/${lang}/index.js"
              }
              
            }
            

            (this is based on the folders created with the default i18n installation)

            then use the commands:

            localazy upload
            

            check your translations and

            localazy download
            

            It is as simple as that.

            1 Reply Last reply Reply Quote 1
            • B
              btmi last edited by

              Actually I found a small issue with the output (the output files have quotes around the key values, even though they are not present in the source) and so I have asked the developers for clarification on how to resolve this.

              Apart from that, i think this is a brilliant idea, very well executed.

              1 Reply Last reply Reply Quote 0
              • B
                btmi last edited by

                The authors came back and said that this behaviour was expected, and that the inclusion of the quotes makes no difference to the outcome, which may be right, but it does add to the payload and reduces readability so I will suggest that they include this as an option in the future.

                Now I have to find out how I can have multiple language files for each language, so I can have dynamic translations that need to be maintained by this program, and static translations (for things like country names) which do no change. Any ideas how I can have more that 1 js file in each language folder?

                1 Reply Last reply Reply Quote 0
                • V
                  vaclav.hodek last edited by

                  I’m the founder of Localazy and author of a lot of its backend and CLI code, so you can ask me anything. Sorry, for replying so late. I wasn’t aware of this discussion.

                  1. Thanks a lot for using Localazy and for your kind words!

                  2. The removal of quotes around keys is on our list - not yet done since we are more focused on versioning now. Apart from adding a few bytes, it’s not an issue since any JSON is also valid JS.

                  3. You can upload as many files from the folder as you want. You can use wildcard operators (?, 😉 or define several different rules: https://localazy.com/docs/cli/upload-reference#multiple-rules

                  4. We have recently added support for metadata, so you can export also metadata file with a list of languages (and their names): https://localazy.com/docs/cli/metadata-file

                  If you need anything else, just ask or contact us via email ;-).

                  1 Reply Last reply Reply Quote 1
                  • First post
                    Last post