1 | import { createApp } from "vue";
|
---|
2 | import { createStore } from "vuex"
|
---|
3 | import Util from "./js/Util"
|
---|
4 | import App from "./App.vue";
|
---|
5 | import ToggleButton from "./components/ToggleButton.vue"
|
---|
6 |
|
---|
7 | const store = createStore({
|
---|
8 | state() {
|
---|
9 | return {
|
---|
10 | /** @type {Map<String, String>} */
|
---|
11 | translations: new Map(),
|
---|
12 | macronisedFileInfos: [],
|
---|
13 | directInput: null,
|
---|
14 | directOutput: []
|
---|
15 | }
|
---|
16 | },
|
---|
17 | mutations: {
|
---|
18 | setTranslations(state, translations) {
|
---|
19 | state.translations = translations;
|
---|
20 | },
|
---|
21 | pushFileInfo(state, fileInfo) {
|
---|
22 | state.macronisedFileInfos.push({
|
---|
23 | id: Util.generateUuid(),
|
---|
24 | ...fileInfo
|
---|
25 | });
|
---|
26 | },
|
---|
27 | setDirectInput(state, input) {
|
---|
28 | state.directInput = input;
|
---|
29 | },
|
---|
30 | setDirectOutput(state, output) {
|
---|
31 | state.directOutput = output;
|
---|
32 | }
|
---|
33 | }
|
---|
34 | });
|
---|
35 |
|
---|
36 | const app = createApp(App);
|
---|
37 |
|
---|
38 | app.use(store);
|
---|
39 | app.component("ToggleButton", ToggleButton)
|
---|
40 | .mount("#app");
|
---|
41 |
|
---|
42 | /* === Get interface translations === */
|
---|
43 |
|
---|
44 | /** @type {Map<String, String>} */
|
---|
45 | const translations = new Map();
|
---|
46 |
|
---|
47 | /* We might be running under Greenstone, so pull the tranlsations from there if so */
|
---|
48 | /* eslint-disable no-undef */
|
---|
49 | if (typeof gs !== "undefined" && gs.text && gs.text.atea && gs.text.atea.macroniser) {
|
---|
50 | for (const key in gs.text.atea.macroniser) {
|
---|
51 | translations.set(key, gs.text.atea.macroniser[key]);
|
---|
52 | }
|
---|
53 |
|
---|
54 | store.commit("setTranslations", translations)
|
---|
55 | }
|
---|
56 | /* eslint-enable no-undef */
|
---|
57 | else {
|
---|
58 | fetch("resources/interface_atea.properties")
|
---|
59 | .then(
|
---|
60 | async response => {
|
---|
61 | const responseText = await response.text();
|
---|
62 | const responseTranslations = responseText.split("\n");
|
---|
63 |
|
---|
64 | for (const translation of responseTranslations) {
|
---|
65 | const keyvalue = translation.split("=");
|
---|
66 |
|
---|
67 | if (keyvalue.length !== 2) {
|
---|
68 | continue;
|
---|
69 | }
|
---|
70 |
|
---|
71 | const namespace = keyvalue[0].split(".");
|
---|
72 | if (namespace.length !== 3 || namespace[1] !== "macroniser") {
|
---|
73 | continue;
|
---|
74 | }
|
---|
75 |
|
---|
76 | translations.set(namespace[namespace.length - 1], keyvalue[1]);
|
---|
77 | }
|
---|
78 |
|
---|
79 | store.commit("setTranslations", translations)
|
---|
80 | }
|
---|
81 | );
|
---|
82 | }
|
---|