Quasar i18n
-
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?
-
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) })