Implement useLocale composable and shared translation dictionaries Translate public pages, booking flow, and receipt views Store booking locale to send localized WhatsApp notifications
13 lines
350 B
TypeScript
13 lines
350 B
TypeScript
import type { AppLocale } from '~~/shared/i18n'
|
|
|
|
export function formatDateTime(value: string | null, fallback = 'Not available', locale: AppLocale = 'en') {
|
|
if (!value) {
|
|
return fallback
|
|
}
|
|
|
|
return new Intl.DateTimeFormat(locale === 'zh' ? 'zh-MY' : 'en-MY', {
|
|
dateStyle: 'medium',
|
|
timeStyle: 'short'
|
|
}).format(new Date(value))
|
|
}
|