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

    Framework
    2
    2
    942
    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.
    • D0KT0P
      D0KT0P last edited by

      I’m trying to set the user’s language (assume from local storage) to ‘he’.
      I do this in the plugin ‘boot’ like this:

      // src/plugins/boot.js
      
      import Quasar from 'quasar'
      
      export default ({ app, Vue }) => {
      	let language = 'he' //LocalStorage.get.item('language')
         	import(`quasar-framework/i18n/${language}`).then(lang => {
                Quasar.i18n.set(lang.default)
              })
        	new Vue(app) 
      }
      

      After loading the page, the language $ q.i18n is set correctly (‘he’),
      but the html tags lang and dir are set to ‘en-us’ and ‘ltr’.

      <html lang="en-us" dir="ltr">...</html>
      

      If the language is switched directly to the page via <select>, then everything works correctly.

      Am I doing something wrong?

      1 Reply Last reply Reply Quote 0
      • rstoenescu
        rstoenescu Admin last edited by

        Dynamic import is asynchronous. new Vue(app) gets called before the Promise fulfils.
        Correct way:

        import(`quasar-framework/i18n/${language}`).then(lang => {
          Quasar.i18n.set(lang.default)
          new Vue(app)
        })
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post