aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/plugins/i18n.ts
diff options
context:
space:
mode:
authorpacien2022-09-04 18:18:27 +0200
committerpacien2022-09-04 18:18:27 +0200
commit11bbbae2850b9c45da697a8ed9626495a50a38c0 (patch)
treeff2713118f8b45d36905bfea2933f08d8e70066d /viewer/src/plugins/i18n.ts
parente93f7b1eb84c083d67567115284c0002a3a7d5fc (diff)
parent8349be992b46b77dee921f484cfbff8b758ff756 (diff)
downloadldgallery-11bbbae2850b9c45da697a8ed9626495a50a38c0.tar.gz
Merge branch 'develop': release v2.1v2.1
GitHub: related to #315
Diffstat (limited to 'viewer/src/plugins/i18n.ts')
-rw-r--r--viewer/src/plugins/i18n.ts19
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
20import Vue from "vue"; 20import { createI18n, LocaleMessages, VueMessageType } from 'vue-i18n';
21import VueI18n, { LocaleMessages } from "vue-i18n";
22 21
23Vue.use(VueI18n); 22function loadLocaleMessages(): LocaleMessages<VueMessageType> {
24 23 const locales = require.context('../locales', false, /[A-Za-z0-9-_,\s]+\.yml$/i);
25function 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
38export default new VueI18n({ 35export 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});