diff options
author | pacien | 2022-09-03 01:34:26 +0200 |
---|---|---|
committer | pacien | 2022-09-03 01:34:26 +0200 |
commit | a8452594c6571e8003baa2aca14747eeeee08152 (patch) | |
tree | a894d99c22a601197869c7a6928d40bb4ae2c392 /viewer/src/plugins/i18n.ts | |
parent | dd9c9804e9e3da9880c711f53edb9c4a19d782f8 (diff) | |
parent | 00510820a2794efcadbc83f7f8b54318fe198ecb (diff) | |
download | ldgallery-a8452594c6571e8003baa2aca14747eeeee08152.tar.gz |
Merge branch 'vue3-refactoring-staging' into develop
Reviewed-by: pacien <pacien.trangirard@pacien.net>
Diffstat (limited to 'viewer/src/plugins/i18n.ts')
-rw-r--r-- | viewer/src/plugins/i18n.ts | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/viewer/src/plugins/i18n.ts b/viewer/src/plugins/i18n.ts index bc3dde5..c377250 100644 --- a/viewer/src/plugins/i18n.ts +++ b/viewer/src/plugins/i18n.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | /* ldgallery - A static generator which turns a collection of tagged | 1 | /* ldgallery - A static generator which turns a collection of tagged |
2 | -- pictures into a searchable web gallery. | 2 | -- pictures into a searchable web gallery. |
3 | -- | 3 | -- |
4 | -- Copyright (C) 2019-2020 Guillaume FOUET | 4 | -- Copyright (C) 2019-2022 Guillaume FOUET |
5 | -- | 5 | -- |
6 | -- This program is free software: you can redistribute it and/or modify | 6 | -- This program is free software: you can redistribute it and/or modify |
7 | -- it under the terms of the GNU Affero General Public License as | 7 | -- it under the terms of the GNU Affero General Public License as |
@@ -17,14 +17,11 @@ | |||
17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. | 17 | -- along with this program. If not, see <https://www.gnu.org/licenses/>. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | import Vue from "vue"; | 20 | import { createI18n, LocaleMessages, VueMessageType } from 'vue-i18n'; |
21 | import VueI18n, { LocaleMessages } from "vue-i18n"; | ||
22 | 21 | ||
23 | Vue.use(VueI18n); | 22 | function loadLocaleMessages(): LocaleMessages<VueMessageType> { |
24 | 23 | const locales = require.context('../locales', false, /[A-Za-z0-9-_,\s]+\.yml$/i); | |
25 | function loadLocaleMessages(): LocaleMessages { | 24 | const messages: LocaleMessages<VueMessageType> = {}; |
26 | const locales = require.context("@/locales", true, /[A-Za-z0-9-_,\s]+\.json$/i); | ||
27 | const messages: LocaleMessages = {}; | ||
28 | locales.keys().forEach(key => { | 25 | locales.keys().forEach(key => { |
29 | const matched = key.match(/([A-Za-z0-9-_]+)\./i); | 26 | const matched = key.match(/([A-Za-z0-9-_]+)\./i); |
30 | if (matched && matched.length > 1) { | 27 | if (matched && matched.length > 1) { |
@@ -35,8 +32,8 @@ function loadLocaleMessages(): LocaleMessages { | |||
35 | return messages; | 32 | return messages; |
36 | } | 33 | } |
37 | 34 | ||
38 | export default new VueI18n({ | 35 | export default createI18n({ |
39 | locale: process.env.VUE_APP_I18N_LOCALE || "en", | 36 | locale: process.env.VUE_APP_I18N_LOCALE || 'en', |
40 | fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || "en", | 37 | fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || 'en', |
41 | messages: loadLocaleMessages(), | 38 | messages: loadLocaleMessages(), |
42 | }); | 39 | }); |