Skip to content

Commit 809c952

Browse files
authored
Merge pull request #12 from birosrichard/fix/translate-untranslated-tokens
fix(web): add translations for message-related UI elements in English…
2 parents d178d65 + abcc922 commit 809c952

5 files changed

Lines changed: 59 additions & 33 deletions

File tree

‎apps/web/messages/en.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@
373373
"chatbot_conversations": "conversations",
374374
"chatbot_conversation": "conversation",
375375
"messages": "Messages",
376+
"messages_filter_all": "All",
377+
"messages_filter_unread": "Unread",
378+
"messages_new_conversation_description": "Select the people you want to chat with",
379+
"messages_no_available_people": "No one is available to start a conversation",
380+
"messages_edited": "edited",
381+
"message_thread_title": "Thread {id}",
376382
"chatbot_select_or_create": "Select or create a conversation",
377383
"chatbot_open": "Open chatbot",
378384
"tool_unknown_processing": "Executing {toolName}...",
@@ -967,4 +973,4 @@
967973
"ios_payment_block_go_to_web": "Go to web app",
968974
"feature_unavailable_ios": "Feature unavailable",
969975
"feature_unavailable_ios_description": "This feature is not available on iOS. Please use the web application to access subscription features."
970-
}
976+
}

‎apps/web/messages/fr.json‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,12 @@
373373
"chatbot_conversations": "conversations",
374374
"chatbot_conversation": "conversation",
375375
"messages": "Messages",
376+
"messages_filter_all": "Tous",
377+
"messages_filter_unread": "Non lus",
378+
"messages_new_conversation_description": "Sélectionnez les personnes avec qui vous souhaitez dialoguer",
379+
"messages_no_available_people": "Aucune personne disponible pour démarrer une conversation",
380+
"messages_edited": "modifié",
381+
"message_thread_title": "Conversation {id}",
376382
"chatbot_select_or_create": "Sélectionnez ou créez une conversation",
377383
"chatbot_open": "Ouvrir le chatbot",
378384
"tool_unknown_processing": "Exécution de {toolName}...",
@@ -967,4 +973,4 @@
967973
"ios_payment_block_go_to_web": "Aller à l'application web",
968974
"feature_unavailable_ios": "Fonctionnalité indisponible",
969975
"feature_unavailable_ios_description": "Cette fonctionnalité n'est pas disponible sur iOS. Veuillez utiliser l'application web pour accéder aux fonctionnalités d'abonnement."
970-
}
976+
}

‎apps/web/src/components/messages/message-messages.tsx‎

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ import { useMessagesWebSocket } from '@/api/messages/use-messages-websocket.hook
33
import { useGetMeQuery } from '@/api/user';
44
import { Loader } from '@/components/ui/loader';
55
import { useWindowVisibility } from '@/hooks/use-window-visibility';
6+
import { m } from '@/paraglide/messages';
7+
import { getLocale } from '@/paraglide/runtime';
8+
import { getDateLocale } from '@/utils/locales';
69
import { cn } from '@/utils/shadcn';
710
import { CheckCheck } from 'lucide-react';
811
import { useEffect, useRef, useState } from 'react';
@@ -104,9 +107,9 @@ function MessageBubble({
104107
/>
105108

106109
<div className="flex gap-2 justify-end">
107-
<Button onClick={onCancelEdit}>Annuler</Button>
110+
<Button onClick={onCancelEdit}>{m.cancel()}</Button>
108111
<Button onClick={handleSave} variant="secondary">
109-
Enregistrer
112+
{m.save()}
110113
</Button>
111114
</div>
112115
</div>
@@ -123,13 +126,18 @@ function MessageBubble({
123126

124127
<div className="flex items-center gap-2 mt-2">
125128
<p className="text-xs opacity-60">
126-
{new Date(message.createdAt).toLocaleTimeString('fr-FR', {
127-
hour: '2-digit',
128-
minute: '2-digit',
129-
})}
129+
{new Date(message.createdAt).toLocaleTimeString(
130+
getDateLocale(getLocale()),
131+
{
132+
hour: '2-digit',
133+
minute: '2-digit',
134+
},
135+
)}
130136
</p>
131137
{message.editedAt && (
132-
<p className="text-xs opacity-60 italic">édité</p>
138+
<p className="text-xs opacity-60 italic">
139+
{m.messages_edited()}
140+
</p>
133141
)}
134142
{isUser && (
135143
<>
@@ -145,7 +153,7 @@ function MessageBubble({
145153
onClick={onStartEdit}
146154
className="text-xs opacity-60 hover:opacity-100 ml-auto cursor-pointer"
147155
>
148-
Modifier
156+
{m.edit()}
149157
</button>
150158
)}
151159
</div>
@@ -224,8 +232,8 @@ export function MessageMessages({
224232
return (
225233
<div className="flex items-center justify-center min-h-[200px] text-muted-foreground p-4">
226234
<div className="text-center">
227-
<p className="text-sm">Aucun message</p>
228-
<p className="text-xs mt-2">Commencez la conversation</p>
235+
<p className="text-sm">{m.chatbot_no_messages()}</p>
236+
<p className="text-xs mt-2">{m.chatbot_start_conversation()}</p>
229237
</div>
230238
</div>
231239
);

‎apps/web/src/components/messages/new-message-thread-dialog.tsx‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,17 @@ export function NewMessageThreadDialog({
8989
<Dialog open={open} onOpenChange={onOpenChange}>
9090
<DialogContent className="sm:max-w-[500px] z-[9999]">
9191
<DialogHeader>
92-
<DialogTitle>Nouvelle conversation</DialogTitle>
92+
<DialogTitle>{m.chatbot_new_conversation()}</DialogTitle>
9393
<DialogDescription>
94-
Sélectionnez les personnes avec qui vous souhaitez dialoguer
94+
{m.messages_new_conversation_description()}
9595
</DialogDescription>
9696
</DialogHeader>
9797

9898
<ScrollArea className="max-h-[400px]">
9999
<div className="space-y-2 p-2">
100100
{availableUsers.length === 0 ? (
101101
<div className="flex items-center justify-center py-8 text-muted-foreground">
102-
<p className="text-sm">
103-
Aucune personne disponible pour démarrer une conversation
104-
</p>
102+
<p className="text-sm">{m.messages_no_available_people()}</p>
105103
</div>
106104
) : (
107105
availableUsers.map((user) => (
@@ -130,7 +128,7 @@ export function NewMessageThreadDialog({
130128

131129
<DialogFooter>
132130
<Button variant="outline" onClick={handleCancel} disabled={isLoading}>
133-
Annuler
131+
{m.cancel()}
134132
</Button>
135133
<Button
136134
onClick={handleConfirm}

‎apps/web/src/pages/dashboard/messages/index.tsx‎

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { Separator } from '@/components/ui/separator';
1616
import { UnreadBadge } from '@/components/ui/unread-badge';
1717
import { useSetPageActions } from '@/hooks/use-page-actions';
1818
import { m } from '@/paraglide/messages';
19+
import { getLocale } from '@/paraglide/runtime';
1920
import { AnalyticsEvent } from '@/utils/analytics-events';
2021
import { isCapacitor } from '@/utils/capacitor';
2122
import { calculateUnreadCount } from '@/utils/messages';
@@ -29,6 +30,15 @@ import { AgentThread, MessageThread } from '@openathlete/shared';
2930

3031
type 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+
3242
export 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

Comments
 (0)