Skip to content

Commit 6ed95fd

Browse files
paul43210claude
authored andcommitted
fix(photo-addon): use oCIS locale for all date formatting
Several date formatting calls in PhotosView and usePhotos were using browser default locale (undefined) instead of the oCIS user's preferred language. Now consistently uses getUserLocale() from useTranslations for timeline group labels (week ranges, month names, full dates). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 46e50e1 commit 6ed95fd

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

packages/web-app-photo-addon/src/composables/usePhotos.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ export function usePhotos() {
269269
/**
270270
* Format date key for display based on mode
271271
*/
272-
function formatDateKey(dateKey: string, mode: GroupMode): string {
272+
function formatDateKey(dateKey: string, mode: GroupMode, locale?: string): string {
273+
const loc = locale || undefined
273274
const today = new Date()
274275
const yesterday = new Date(today)
275276
yesterday.setDate(yesterday.getDate() - 1)
@@ -280,21 +281,21 @@ export function usePhotos() {
280281
case 'month': {
281282
const [year, month] = dateKey.split('-').map(Number)
282283
const date = new Date(year, month - 1, 1)
283-
return date.toLocaleDateString(undefined, { year: 'numeric', month: 'long' })
284+
return date.toLocaleDateString(loc, { year: 'numeric', month: 'long' })
284285
}
285286
case 'week': {
286287
const [year, weekPart] = dateKey.split('-W')
287288
const weekNum = parseInt(weekPart)
288289
const { start: weekStart, end: weekEnd } = getWeekDateRange(parseInt(year), weekNum)
289-
return `${weekStart.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })} - ${weekEnd.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })}`
290+
return `${weekStart.toLocaleDateString(loc, { month: 'short', day: 'numeric' })} - ${weekEnd.toLocaleDateString(loc, { month: 'short', day: 'numeric', year: 'numeric' })}`
290291
}
291292
case 'day':
292293
default: {
293294
const [year, month, day] = dateKey.split('-').map(Number)
294295
const date = new Date(year, month - 1, day)
295296
if (date.toDateString() === today.toDateString()) return 'Today'
296297
if (date.toDateString() === yesterday.toDateString()) return 'Yesterday'
297-
return date.toLocaleDateString(undefined, {
298+
return date.toLocaleDateString(loc, {
298299
weekday: 'long',
299300
year: 'numeric',
300301
month: 'long',

packages/web-app-photo-addon/src/views/PhotosView.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,8 @@ const {
224224
} = usePhotos()
225225
226226
// Initialize translations
227-
const { $gettext, getMonthNames } = useTranslations()
227+
const { $gettext, getUserLocale, getMonthNames } = useTranslations()
228+
const userLocale = getUserLocale()
228229
229230
const clientService = useClientService()
230231
const spacesStore = useSpacesStore()
@@ -850,7 +851,7 @@ function formatDateHeader(dateKey: string): string {
850851
startDate.setDate(jan1.getDate() + (weekNum - 1) * 7 - jan1.getDay() + 1)
851852
const endDate = new Date(startDate)
852853
endDate.setDate(startDate.getDate() + 6)
853-
return `${startDate.toLocaleDateString(undefined, { month: 'short', day: 'numeric' })} - ${endDate.toLocaleDateString(undefined, { month: 'short', day: 'numeric', year: 'numeric' })}`
854+
return `${startDate.toLocaleDateString(userLocale, { month: 'short', day: 'numeric' })} - ${endDate.toLocaleDateString(userLocale, { month: 'short', day: 'numeric', year: 'numeric' })}`
854855
}
855856
856857
const parts = dateKey.split('-')
@@ -861,7 +862,7 @@ function formatDateHeader(dateKey: string): string {
861862
if (parts.length === 2) {
862863
// Month: 2026-01
863864
const date = new Date(parseInt(parts[0]), parseInt(parts[1]) - 1, 1)
864-
return date.toLocaleDateString(undefined, { year: 'numeric', month: 'long' })
865+
return date.toLocaleDateString(userLocale, { year: 'numeric', month: 'long' })
865866
}
866867
867868
// Full date: 2026-01-11
@@ -870,7 +871,7 @@ function formatDateHeader(dateKey: string): string {
870871
if (date.toDateString() === today.toDateString()) return $gettext('Today')
871872
if (date.toDateString() === yesterday.toDateString()) return $gettext('Yesterday')
872873
873-
return date.toLocaleDateString(undefined, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
874+
return date.toLocaleDateString(userLocale, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
874875
}
875876
876877
// Handle date filter change - reload photos starting from selected month

0 commit comments

Comments
 (0)