diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index c51d0f25c..f5320dcc2 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -3,12 +3,8 @@ import VueI18n from "vue-i18n"; Vue.use(VueI18n); -function loadLocaleMessages() { - const locales = require.context( - "./locales", - true, - /[A-Za-z0-9-_,\s]+\.json$/i - ); + +function parseLocaleFiles(locales) { const messages = {}; locales.keys().forEach(key => { const matched = key.match(/([A-Za-z0-9-_]+)\./i); @@ -20,21 +16,22 @@ function loadLocaleMessages() { return messages; } -const dateTimeFormats = { - 'en': { - short: { - month: 'short', - day: 'numeric', - weekday: 'long' - }, - }, - 'fr': { - short: { - month: 'short', - day: 'numeric', - weekday: 'long' - } - } +function loadLocaleMessages() { + const locales = require.context( + "./locales/messages", + true, + /[A-Za-z0-9-_,\s]+\.json$/i + ); + return parseLocaleFiles(locales); +} + +function loadDateTimeFormats() { + const locales = require.context( + "./locales/dateTimeFormats", + true, + /[A-Za-z0-9-_,\s]+\.json$/i + ); + return parseLocaleFiles(locales); } @@ -42,5 +39,5 @@ export default new VueI18n({ locale: "en", fallbackLocale: process.env.VUE_APP_I18N_FALLBACK_LOCALE || "en", messages: loadLocaleMessages(), - dateTimeFormats + dateTimeFormats: loadDateTimeFormats() }); diff --git a/frontend/src/locales/dateTimeFormats/da.json b/frontend/src/locales/dateTimeFormats/da.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/da.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/dateTimeFormats/de.json b/frontend/src/locales/dateTimeFormats/de.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/de.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/dateTimeFormats/en.json b/frontend/src/locales/dateTimeFormats/en.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/en.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/dateTimeFormats/fr.json b/frontend/src/locales/dateTimeFormats/fr.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/fr.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/dateTimeFormats/pl.json b/frontend/src/locales/dateTimeFormats/pl.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/pl.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/dateTimeFormats/sv.json b/frontend/src/locales/dateTimeFormats/sv.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/sv.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/dateTimeFormats/zh-CN.json b/frontend/src/locales/dateTimeFormats/zh-CN.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/zh-CN.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/dateTimeFormats/zh-TW.json b/frontend/src/locales/dateTimeFormats/zh-TW.json new file mode 100644 index 000000000..a0af56a4e --- /dev/null +++ b/frontend/src/locales/dateTimeFormats/zh-TW.json @@ -0,0 +1,7 @@ +{ + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } +} \ No newline at end of file diff --git a/frontend/src/locales/da.json b/frontend/src/locales/messages/da.json similarity index 100% rename from frontend/src/locales/da.json rename to frontend/src/locales/messages/da.json diff --git a/frontend/src/locales/de.json b/frontend/src/locales/messages/de.json similarity index 100% rename from frontend/src/locales/de.json rename to frontend/src/locales/messages/de.json diff --git a/frontend/src/locales/en.json b/frontend/src/locales/messages/en.json similarity index 98% rename from frontend/src/locales/en.json rename to frontend/src/locales/messages/en.json index 324e26329..5cb7928dc 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/messages/en.json @@ -1,4 +1,12 @@ { + + "dateTimeFormats": { + "short": { + "month": "short", + "day": "numeric", + "weekday": "long" + } + }, "404": { "page-not-found": "404 Page Not Found", "take-me-home": "Take me Home" diff --git a/frontend/src/locales/fr.json b/frontend/src/locales/messages/fr.json similarity index 100% rename from frontend/src/locales/fr.json rename to frontend/src/locales/messages/fr.json diff --git a/frontend/src/locales/pl.json b/frontend/src/locales/messages/pl.json similarity index 100% rename from frontend/src/locales/pl.json rename to frontend/src/locales/messages/pl.json diff --git a/frontend/src/locales/sv.json b/frontend/src/locales/messages/sv.json similarity index 100% rename from frontend/src/locales/sv.json rename to frontend/src/locales/messages/sv.json diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/messages/zh-CN.json similarity index 100% rename from frontend/src/locales/zh-CN.json rename to frontend/src/locales/messages/zh-CN.json diff --git a/frontend/src/locales/zh-TW.json b/frontend/src/locales/messages/zh-TW.json similarity index 100% rename from frontend/src/locales/zh-TW.json rename to frontend/src/locales/messages/zh-TW.json