From 1f3f7f18a6db8c8282b3ae8a5d48d05a8d15eeb9 Mon Sep 17 00:00:00 2001 From: BeneRichi Date: Fri, 20 Jan 2023 11:48:38 +0100 Subject: [PATCH] #131 Defined "month" template and stored it in "const dateTimeFormats" to be used inside the options object in the new VueI18n instance - call i18n.setDateTimeFormat() after fetching current page locale --- src/setup/i18n.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/setup/i18n.js b/src/setup/i18n.js index f5ac8701..ced0122e 100644 --- a/src/setup/i18n.js +++ b/src/setup/i18n.js @@ -22,10 +22,20 @@ if (process.env.NODE_ENV !== 'production') { } } +const dateTimeFormats = { // @see https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat#parameter + month: { // January, February, March, ... + month: 'long', + }, +}; + export const i18n = new VueI18n({ locale: I18N_FALLBACK, fallbackLocale: I18N_FALLBACK, warnHtmlInMessage: process.env.NODE_ENV !== 'production' ? 'error' : 'off', + dateTimeFormats: { + [I18N_FALLBACK]: dateTimeFormats, + [pageLang]: dateTimeFormats, + }, /** * Callback for the 'missing' event, during translation lookup. @@ -89,6 +99,7 @@ export const i18nSetLocale = function(locale) { // eslint-disable-line no-param- if (i18n.locale !== locale) { return i18nLoadMessages(locale).then((newLocale) => { i18n.locale = newLocale; + i18n.setDateTimeFormat(locale, dateTimeFormats); }); }