Files
gsfdc/demo-dify/dify/web/app/components/base/date-time-picker/use-picker-labels.ts
T
wuzilongandCursor 6519682885 chore: 纳入本地 Dify 1.19.0 源码及品牌与免登改动
演示目录只保留可重建的源码。运行密钥、数据卷、依赖和带口令的本地配置不进入仓库。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 13:59:25 +08:00

39 lines
1.4 KiB
TypeScript

'use client'
import { useTranslation } from 'react-i18next'
import { useLocale } from '#i18n'
export function usePickerLabels() {
const locale = useLocale()
const { t } = useTranslation(['time'])
const period = (hour: number) =>
new Intl.DateTimeFormat(locale, { hour: 'numeric', hour12: true, timeZone: 'UTC' })
.formatToParts(new Date(Date.UTC(2025, 0, 1, hour)))
.find((part) => part.type === 'dayPeriod')?.value ?? (hour < 12 ? 'AM' : 'PM')
return {
locale,
requiredLabel: t(($) => $['picker.requiredLabel']),
validationMessage: t(($) => $['picker.required']),
labels: {
previousMonth: t(($) => $['picker.previousMonth']),
nextMonth: t(($) => $['picker.nextMonth']),
chooseMonthAndYear: t(($) => $['picker.chooseMonthAndYear']),
month: t(($) => $['picker.month']),
year: t(($) => $['picker.year']),
hour: t(($) => $['picker.hour']),
minute: t(($) => $['picker.minute']),
period: t(($) => $['picker.period']),
unavailable: t(($) => $['picker.unavailable']),
backToDate: t(($) => $['operation.pickDate']),
cancel: t(($) => $['operation.cancel']),
close: t(($) => $['operation.close']),
apply: t(($) => $['operation.ok']),
now: t(($) => $['operation.now']),
title: t(($) => $['title.pickTime']),
pickTime: t(($) => $['title.pickTime']),
am: period(0),
pm: period(12),
},
}
}