mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-18 11:36:53 +02:00
refactor(v2): format post date using Intl (#4344)
* refactor(v2): format post date using Intl * Fix test * Blog: add localized blog post date test Co-authored-by: slorber <lorber.sebastien@gmail.com>
This commit is contained in:
parent
a4b409c93b
commit
1dd400db7e
18 changed files with 87 additions and 214 deletions
|
@ -23,6 +23,7 @@ import {
|
|||
// @ts-expect-error: no typedefs :s
|
||||
import resolvePathnameUnsafe from 'resolve-pathname';
|
||||
import {mapValues} from 'lodash';
|
||||
import areIntlLocalesSupported from 'intl-locales-supported';
|
||||
|
||||
const fileHash = new Map();
|
||||
export async function generate(
|
||||
|
@ -634,3 +635,10 @@ export async function readDefaultCodeTranslationMessages({
|
|||
|
||||
return {};
|
||||
}
|
||||
|
||||
export function getDateTimeFormat(locale: string) {
|
||||
return areIntlLocalesSupported([locale])
|
||||
? global.Intl.DateTimeFormat
|
||||
: // eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
require('intl').DateTimeFormat;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue