aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/plugins/i18n.ts
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/plugins/i18n.ts')
-rw-r--r--viewer/src/plugins/i18n.ts23
1 files changed, 23 insertions, 0 deletions
diff --git a/viewer/src/plugins/i18n.ts b/viewer/src/plugins/i18n.ts
new file mode 100644
index 0000000..da2cd87
--- /dev/null
+++ b/viewer/src/plugins/i18n.ts
@@ -0,0 +1,23 @@
1import Vue from "vue";
2import VueI18n, { LocaleMessages } from "vue-i18n";
3
4Vue.use(VueI18n);
5
6function loadLocaleMessages(): LocaleMessages {
7 const locales = require.context("@/locales", true, /[A-Za-z0-9-_,\s]+\.json$/i);
8 const messages: LocaleMessages = {};
9 locales.keys().forEach(key => {
10 const matched = key.match(/([A-Za-z0-9-_]+)\./i);
11 if (matched && matched.length > 1) {
12 const locale = matched[1];
13 messages[locale] = locales(key);
14 }
15 });
16 return messages;
17}
18
19export default new VueI18n({
20 locale: process.env.VUE_APP_I18N_LOCALE || "en",
21 fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || "en",
22 messages: loadLocaleMessages(),
23});