diff --git a/src/components/hooks/dates.ts b/src/components/hooks/dates.ts index f4eef4e53e..c295e53296 100644 --- a/src/components/hooks/dates.ts +++ b/src/components/hooks/dates.ts @@ -1,3 +1,12 @@ +/** + * Hooks for date-fns localized formatters. + * + * Our app supports some languages that are not included in date-fns by + * default, in which case it will fall back to English. + * + * {@link https://github.com/date-fns/date-fns/blob/main/docs/i18n.md} + */ + import React from 'react' import {formatDistance, Locale} from 'date-fns' import { @@ -18,8 +27,13 @@ import { zhTW, } from 'date-fns/locale' +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import {AppLanguage} from '#/locale/languages' import {useLanguagePrefs} from '#/state/preferences' +/** + * {@link AppLanguage} + */ const locales: Record = { ca, de, @@ -38,6 +52,10 @@ const locales: Record = { zhTW, } +/** + * Returns a localized `formatDistance` function. + * {@link formatDistance} + */ export function useFormatDistance() { const {appLanguage} = useLanguagePrefs() return React.useCallback(