diff --git a/.changeset/thirty-drinks-shout.md b/.changeset/thirty-drinks-shout.md index d749298a3212e..815e14dc144da 100644 --- a/.changeset/thirty-drinks-shout.md +++ b/.changeset/thirty-drinks-shout.md @@ -1,5 +1,6 @@ --- 'astro': patch +'create-astro': patch --- Fix [#3309](https://github.com/withastro/astro/issues/3309) default logger locale behavior. diff --git a/packages/create-astro/src/logger.ts b/packages/create-astro/src/logger.ts index 65f354632c005..96965e7ea03aa 100644 --- a/packages/create-astro/src/logger.ts +++ b/packages/create-astro/src/logger.ts @@ -6,20 +6,19 @@ type ConsoleStream = Writable & { fd: 1 | 2; }; -function getLoggerLocale(): string { - const defaultLocale = 'en-US'; - if (process.env.LANG) { - const extractedLocale = process.env.LANG.split('.')[0].replace(/_/g, '-'); - // Check if language code is atleast two characters long (ie. en, es). - // NOTE: if "c" locale is encountered, the default locale will be returned. - if (extractedLocale.length < 2) return defaultLocale; - else return extractedLocale; - } else return defaultLocale; -} - -const dt = new Intl.DateTimeFormat(getLoggerLocale(), { +// Hey, locales are pretty complicated! Be careful modifying this logic... +// If we throw at the top-level, international users can't use Astro. +// +// Using `[]` sets the default locale properly from the system! +// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#parameters +// +// Here be the dragons we've slain: +// https://github.com/withastro/astro/issues/2625 +// https://github.com/withastro/astro/issues/3309 +const dt = new Intl.DateTimeFormat([], { hour: '2-digit', minute: '2-digit', + second: '2-digit', }); export const defaultLogDestination = new Writable({