@@ -16,6 +16,7 @@ import { Separator } from '@/components/ui/separator';
1616import { UnreadBadge } from '@/components/ui/unread-badge' ;
1717import { useSetPageActions } from '@/hooks/use-page-actions' ;
1818import { m } from '@/paraglide/messages' ;
19+ import { getLocale } from '@/paraglide/runtime' ;
1920import { AnalyticsEvent } from '@/utils/analytics-events' ;
2021import { isCapacitor } from '@/utils/capacitor' ;
2122import { calculateUnreadCount } from '@/utils/messages' ;
@@ -29,6 +30,15 @@ import { AgentThread, MessageThread } from '@openathlete/shared';
2930
3031type ThreadFilter = 'all' | 'unread' ;
3132
33+ function formatConversationCount ( count : number ) {
34+ const label =
35+ new Intl . PluralRules ( getLocale ( ) ) . select ( count ) === 'one'
36+ ? m . chatbot_conversation ( )
37+ : m . chatbot_conversations ( ) ;
38+
39+ return `${ count } ${ label } ` ;
40+ }
41+
3242export function MessagesPage ( ) {
3343 const posthog = usePostHog ( ) ;
3444 const [ filter , setFilter ] = useState < ThreadFilter > ( 'all' ) ;
@@ -94,7 +104,7 @@ export function MessagesPage() {
94104 ! createMessageThreadMutation . isPending
95105 ) {
96106 createMessageThreadMutation . mutate (
97- { title : 'New Thread' , participantUserIds : [ ] } ,
107+ { title : m . chatbot_new_conversation ( ) , participantUserIds : [ ] } ,
98108 {
99109 onSuccess : ( newThread ) => {
100110 posthog ?. capture ( AnalyticsEvent . messages_thread_created , {
@@ -177,7 +187,7 @@ export function MessagesPage() {
177187 const pageTitle = m . messages ( ) ;
178188 const conversationTitle = activeId
179189 ? messageThreads ?. find ( ( t ) => t . messageThreadId === activeMessageThreadId )
180- ?. title || `Thread ${ activeId } `
190+ ?. title || m . message_thread_title ( { id : activeId } )
181191 : pageTitle ;
182192
183193 const createAction = useMemo (
@@ -257,8 +267,7 @@ export function MessagesPage() {
257267 < div className = "flex-shrink-0 px-4 py-2 border-b border-border bg-background" >
258268 < div className = "flex items-center justify-between gap-2 mb-2" >
259269 < p className = "text-xs text-muted-foreground" >
260- { threads ?. length || 0 } { ' ' }
261- { ( threads ?. length || 0 ) > 1 ? 'conversations' : 'conversation' }
270+ { formatConversationCount ( threads ?. length || 0 ) }
262271 </ p >
263272 </ div >
264273 < div className = "flex items-center gap-2" >
@@ -268,15 +277,15 @@ export function MessagesPage() {
268277 onClick = { ( ) => setFilter ( 'all' ) }
269278 className = "h-7 text-xs"
270279 >
271- Tous
280+ { m . messages_filter_all ( ) }
272281 </ Button >
273282 < Button
274283 variant = { filter === 'unread' ? 'default' : 'ghost' }
275284 size = "sm"
276285 onClick = { ( ) => setFilter ( 'unread' ) }
277286 className = "h-7 text-xs"
278287 >
279- Non lus
288+ { m . messages_filter_unread ( ) }
280289 </ Button >
281290 </ div >
282291 </ div >
@@ -314,7 +323,7 @@ export function MessagesPage() {
314323 ? threadTitle . length > 25
315324 ? threadTitle . substring ( 0 , 25 ) + '...'
316325 : threadTitle
317- : `Thread ${ threadId } ` }
326+ : m . message_thread_title ( { id : threadId } ) }
318327 </ h3 >
319328 { unreadCount > 0 && < UnreadBadge count = { unreadCount } /> }
320329 </ div >
@@ -393,7 +402,7 @@ export function MessagesPage() {
393402 < div className = "flex-1 flex items-center justify-center text-muted-foreground" >
394403 < div className = "text-center" >
395404 < MessageCircle className = "h-16 w-16 mx-auto mb-4 opacity-20" />
396- < p > Select or create a conversation </ p >
405+ < p > { m . chatbot_select_or_create ( ) } </ p >
397406 </ div >
398407 </ div >
399408 ) }
@@ -431,20 +440,19 @@ export function MessagesPage() {
431440 onClick = { ( ) => setFilter ( 'all' ) }
432441 className = "h-7"
433442 >
434- Tous
443+ { m . messages_filter_all ( ) }
435444 </ Button >
436445 < Button
437446 variant = { filter === 'unread' ? 'default' : 'ghost' }
438447 size = "sm"
439448 onClick = { ( ) => setFilter ( 'unread' ) }
440449 className = "h-7"
441450 >
442- Non lus
451+ { m . messages_filter_unread ( ) }
443452 </ Button >
444453 </ div >
445454 < p className = "text-sm text-muted-foreground" >
446- { threads ?. length || 0 } { ' ' }
447- { ( threads ?. length || 0 ) > 1 ? 'conversations' : 'conversation' }
455+ { formatConversationCount ( threads ?. length || 0 ) }
448456 </ p >
449457 </ div >
450458
@@ -482,7 +490,7 @@ export function MessagesPage() {
482490 ? threadTitle . length > 25
483491 ? threadTitle . substring ( 0 , 25 ) + '...'
484492 : threadTitle
485- : `Thread ${ threadId } ` }
493+ : m . message_thread_title ( { id : threadId } ) }
486494 </ h3 >
487495 { unreadCount > 0 && < UnreadBadge count = { unreadCount } /> }
488496 </ div >
@@ -516,7 +524,7 @@ export function MessagesPage() {
516524 < h2 className = "text-lg font-semibold" >
517525 { messageThreads ?. find (
518526 ( t ) => t . messageThreadId === activeMessageThreadId ,
519- ) ?. title || `Thread ${ activeId } ` }
527+ ) ?. title || m . message_thread_title ( { id : activeId } ) }
520528 </ h2 >
521529 </ div >
522530
@@ -537,7 +545,7 @@ export function MessagesPage() {
537545 < div className = "flex-1 flex items-center justify-center text-muted-foreground" >
538546 < div className = "text-center" >
539547 < MessageCircle className = "h-16 w-16 mx-auto mb-4 opacity-20" />
540- < p > Select or create a conversation </ p >
548+ < p > { m . chatbot_select_or_create ( ) } </ p >
541549 </ div >
542550 </ div >
543551 ) }
0 commit comments