source: main/trunk/model-interfaces-dev/atea/macron-restoration/src/main.js@ 35715

Last change on this file since 35715 was 35714, checked in by cstephen, 2 years ago

Add macroniser scaffolding.
Update translations.

File size: 2.3 KB
Line 
1import { createApp } from "vue";
2import { createStore } from "vuex"
3// import AudioPlayback from "./js/AudioPlaybackModule";
4import App from "./App.vue";
5import ToggleButton from "./components/ToggleButton.vue"
6
7// export class TranscriptionExistsError extends Error {
8// constructor(message = "", ...args) {
9// super(message, ...args);
10// }
11// }
12
13const 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
33const app = createApp(App);
34
35app.use(store);
36app.component("ToggleButton", ToggleButton)
37 .mount("#app");
38
39/* === Get interface translations === */
40
41/** @type {Map<String, String>} */
42const translations = new Map();
43
44/* We might be running under Greenstone, so pull the tranlsations from there if so */
45/* eslint-disable no-undef */
46if (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 */
54else {
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}
Note: See TracBrowser for help on using the repository browser.