Replies: 3 comments 2 replies
-
One more use case is from pinia/vuex store. Imagine there's an action, it fails, some error should appear, it has to be translated. What is the correct way to import vue-18n-next and where to take |
Beta Was this translation helpful? Give feedback.
-
Is it possible to downgrade and use i18n@8 with vue3? |
Beta Was this translation helpful? Give feedback.
-
The following pattern seems to work at least with Vue 3.2.13 and Vue I18n 9.2.0-beta.35. The main.js file imports an I18n instance and provides the same instance both to Vue and as an export. Other code can then import the same i18n from main.js. In main.js: import { createApp } from 'vue';
import MyApp from './MyApp.vue';
import i18n from './i18n';
const myApp = createApp(MyApp).use(i18n);
myApp.mount('#app');
export { i18n }; In someOther.js: import { i18n } from './main';
let msg = i18n.global.t("my.message.key"); |
Beta Was this translation helpful? Give feedback.
-
It works just fine in
i18n@8
: you can create a file like@/i18n
:and then just use it no matter where. For example, in main.ts:
It works even without Vue instance defined!
We need to have the same behavior in Vue3. There're a lot of Navigator/Logger/Config/SubscriptionManager/VersionManager etc things defined globally. If I try to
it does not work,
Must be called at the top of a
setupfunction
.Beta Was this translation helpful? Give feedback.
All reactions