-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathi18n.config.ts
64 lines (61 loc) · 1.73 KB
/
i18n.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import type { LocaleMessage } from "@intlify/core";
import type { VueMessageType } from "vue-i18n";
import de from "./locales/de.json";
import en from "./locales/en.json";
import nb from "./locales/nb.json";
import nl from "./locales/nl.json";
import sl from "./locales/sl.json";
import tr from "./locales/tr.json";
import fr from "./locales/fr.json";
import ta from "./locales/ta.json";
import da from "./locales/da.json";
import es from "./locales/es.json";
import et from "./locales/et.json";
import fi from "./locales/fi.json";
import hu from "./locales/hu.json";
import pt from "./locales/pt.json";
import ro from "./locales/ro.json";
import ru from "./locales/ru.json";
function cleanupEmptyProperties(obj: any, fallback: any): any {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === "object") {
obj[key] = cleanupEmptyProperties(obj[key], fallback[key]);
}
if (obj[key] === "") {
obj[key] = fallback[key];
}
});
return obj;
}
function cleanup(
locale: LocaleMessage<VueMessageType>,
fallback: LocaleMessage<VueMessageType>,
): LocaleMessage<VueMessageType> {
Object.keys(locale).forEach((key) => {
if (typeof locale[key] === "object") {
locale[key] = cleanupEmptyProperties(locale[key], fallback[key]);
}
});
return locale;
}
export default defineI18nConfig(() => ({
legacy: false,
messages: {
nb: cleanup(nb, en),
en,
de: cleanup(de, en),
nl: cleanup(nl, en),
fr: cleanup(fr, en),
sl: cleanup(sl, en),
tr: cleanup(tr, en),
ta: cleanup(ta, en),
da: cleanup(da, en),
es: cleanup(es, en),
et: cleanup(et, en),
fi: cleanup(fi, en),
hu: cleanup(hu, en),
pt: cleanup(pt, en),
ro: cleanup(ro, en),
ru: cleanup(ru, en),
},
}));