feat: localize authentication and account shell

This commit is contained in:
biss committed 2026-10-30 21:26:10 +08:00
1 parent c7499f05e3
commit 6727f72121
20 files changed
+518 -204

No files matched your search

+25
View File
@@ -1,4 +1,5 @@
import { branding } from '../config/branding'
import { currentLocale } from '../i18n'
export interface SmartGreeting {
title: string
@@ -12,6 +13,12 @@ const dailySubtitles = [
'把每一次学习,都变成看得见的进步。',
]
const englishDailySubtitles = [
'Wishing you a clear and productive day.',
'Start the day with a well-organized plan.',
'Make every learning step visible.',
]
function lunarFestival(date: Date) {
try {
const parts = new Intl.DateTimeFormat('zh-CN-u-ca-chinese', {
@@ -56,6 +63,24 @@ export function getSmartGreeting(
date = new Date(),
displayName?: string | null,
): SmartGreeting {
if (currentLocale.value === 'en-US') {
const hour = date.getHours()
const greeting = hour < 5 ? 'Good night' : hour < 12 ? 'Good morning'
: hour < 18 ? 'Good afternoon' : 'Good evening'
const name = displayName?.trim()
const index = Math.abs(date.getFullYear() * 372 + date.getMonth() * 31 + date.getDate())
% englishDailySubtitles.length
return {
title: name ? `${greeting}, ${name}` : `${greeting}. Welcome to ${branding.shortName}`,
subtitle: date.getDay() === 0 || date.getDay() === 6
? 'Take time to recharge this weekend and check your schedule when ready.'
: englishDailySubtitles[index],
label: new Intl.DateTimeFormat('en-US', {
month: 'long', day: 'numeric', weekday: 'long',
}).format(date),
}
}
const greeting = festivalGreeting(date) || timeGreeting(date)
const name = displayName?.trim()
const weekday = new Intl.DateTimeFormat('zh-CN', { weekday: 'long' }).format(date)