Bug 32030: ERM - I18N
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / js / vue / main-erm.ts
1 import { createApp } from "vue";
2 import { createWebHistory, createRouter } from "vue-router";
3 import { createPinia } from "pinia";
4
5 import { library } from "@fortawesome/fontawesome-svg-core";
6 import { faPlus, faPencil, faTrash } from "@fortawesome/free-solid-svg-icons";
7 import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
8
9 library.add(faPlus, faPencil, faTrash);
10
11 import App from "./components/ERM/ERMMain.vue";
12
13 import { routes } from "./routes";
14
15 const router = createRouter({ history: createWebHistory(), routes });
16
17 import { useMainStore } from "./stores/main";
18
19 import { createI18n } from "vue-i18n";
20
21 import * as en from "./locales/en.json"; // We could async the load here, see https://vue-i18n.intlify.dev/guide/advanced/lazy.html
22 const languages = { en };
23 const messages = Object.assign(languages);
24 const i18n = createI18n({ locale: "en", messages });
25
26 createApp(App)
27     .use(createPinia())
28     .use(router)
29     .use(i18n)
30     .component("font-awesome-icon", FontAwesomeIcon)
31     .mount("#erm");
32 const mainStore = useMainStore();
33 const { removeMessages } = mainStore;
34 router.beforeEach((to, from) => {
35     removeMessages(); // This will actually flag the messages as displayed already
36 });