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