Skip to content

Commit cef465b

Browse files
committed
feat(i18n): use dictionary in components
1 parent 26719ad commit cef465b

File tree

7 files changed

+88
-27
lines changed

7 files changed

+88
-27
lines changed

apps/web/src/components/copy-button.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { ComponentProps, useRef, useState } from 'react'
44
import { twMerge } from 'tailwind-merge'
55

66
import { Button } from './ui/button'
7+
import { useDictionary } from '@/state/dictionary'
78

89
export interface CopyButtonProps extends ComponentProps<typeof Button> {
910
textToCopy: string
1011
}
1112

1213
export function CopyButton({ textToCopy, ...props }: CopyButtonProps) {
14+
const dictionary = useDictionary()
1315
const [wasCopiedRecently, setWasCopiedRecently] = useState(false)
1416
const copyTimeoutRef = useRef<NodeJS.Timeout>()
1517

@@ -35,7 +37,7 @@ export function CopyButton({ textToCopy, ...props }: CopyButtonProps) {
3537
props.className,
3638
)}
3739
>
38-
{wasCopiedRecently ? 'Copied!' : props.children}
40+
{wasCopiedRecently ? dictionary.copy_button_copied : props.children}
3941
</Button>
4042
)
4143
}

apps/web/src/components/intercepted-sheet-content.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import { useRouter } from 'next/navigation'
66
import React from 'react'
77

88
import { SheetOverlay, sheetVariants } from './ui/sheet'
9+
import { useDictionary } from '@/state/dictionary'
910

1011
export const InterceptedSheetContent = React.forwardRef<
1112
React.ElementRef<typeof SheetPrimitive.Content>,
1213
React.ComponentPropsWithoutRef<typeof SheetPrimitive.Content>
1314
>(({ className, children, ...props }, ref) => {
15+
const dictionary = useDictionary()
1416
const router = useRouter()
1517

1618
const onDismiss = React.useCallback(() => {
@@ -33,7 +35,7 @@ export const InterceptedSheetContent = React.forwardRef<
3335
className="absolute right-8 top-8 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary"
3436
>
3537
<X className="h-4 w-4" />
36-
<span className="sr-only">Close</span>
38+
<span className="sr-only">{dictionary.intercepted_sheet_close}</span>
3739
</button>
3840
</SheetPrimitive.Content>
3941
</>

apps/web/src/components/transcription-preview.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@ import { Textarea } from '@/components/ui/textarea'
1717
import { trpc } from '@/lib/trpc/react'
1818

1919
import { Button } from './ui/button'
20+
import { useDictionary } from '@/state/dictionary'
2021

2122
export interface TranscriptionPreviewProps {
2223
videoId: string
2324
}
2425

2526
export function TranscriptionPreview({ videoId }: TranscriptionPreviewProps) {
27+
const dictionary = useDictionary()
2628
const [isDialogOpen, setIsDialogOpen] = useState(false)
2729

2830
const {
@@ -51,12 +53,12 @@ export function TranscriptionPreview({ videoId }: TranscriptionPreviewProps) {
5153
<DialogTrigger asChild>
5254
<button className="flex items-center font-medium text-primary hover:underline">
5355
<Link1Icon className="mr-2 h-4 w-4" />
54-
<span>View transcription</span>
56+
<span>{dictionary.transcription_preview_view_transcription}</span>
5557
</button>
5658
</DialogTrigger>
5759
<DialogContent className="w-full max-w-[480px]">
5860
<DialogHeader>
59-
<DialogTitle>Transcrição</DialogTitle>
61+
<DialogTitle>{dictionary.transcription_preview_title}</DialogTitle>
6062
</DialogHeader>
6163
{isLoadingTranscription || isPendingTranscription ? (
6264
<div className="space-y-2">
@@ -76,7 +78,7 @@ export function TranscriptionPreview({ videoId }: TranscriptionPreviewProps) {
7678
<Button variant="secondary" asChild>
7779
<Link href={`/app/videos/${data?.transcription?.uploadId}`}>
7880
<Edit2 className="mr-2 h-3 w-3" />
79-
Review
81+
{dictionary.transcription_preview_button_review}
8082
</Link>
8183
</Button>
8284
</>

apps/web/src/components/upload-item-actions.tsx

+17-19
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
DropdownMenuTrigger,
2626
} from '@/components/ui/dropdown-menu'
2727
import { trpc } from '@/lib/trpc/react'
28+
import { useDictionary } from '@/state/dictionary'
2829

2930
interface UploadItemActionsProps {
3031
videoId: string
@@ -35,6 +36,7 @@ export function UploadItemActions({
3536
videoId,
3637
uploadBatchId,
3738
}: UploadItemActionsProps) {
39+
const dictionary = useDictionary()
3840
const utils = trpc.useUtils()
3941

4042
const [isDeleteDialogOpen, setIsDeleteDialogOpen] = useState(false)
@@ -52,9 +54,8 @@ export function UploadItemActions({
5254

5355
setIsDeleteDialogOpen(false)
5456
} catch {
55-
toast.error('Uh oh! Something went wrong.', {
56-
description:
57-
'An error ocurred while trying to delete the video. If the error persists, please contact an administrator.',
57+
toast.error(dictionary.upload_item_actions_toast_error, {
58+
description: dictionary.upload_item_actions_toast_error_description,
5859
})
5960
}
6061
}
@@ -69,21 +70,21 @@ export function UploadItemActions({
6970
className="data-[state=open]:bg-muted"
7071
>
7172
<MoreHorizontal className="size-3" />
72-
<span className="sr-only">Open menu</span>
73+
<span className="sr-only">{dictionary.upload_item_actions_open_menu}</span>
7374
</Button>
7475
</DropdownMenuTrigger>
7576
<DropdownMenuContent align="end" className="w-[160px]">
7677
<DropdownMenuItem asChild>
7778
<Link href={`/app/videos/${videoId}`} prefetch={false}>
7879
<Pencil2Icon className="mr-2 h-4 w-4" />
79-
<span>Edit</span>
80+
<span>{dictionary.upload_item_actions_edit}</span>
8081
</Link>
8182
</DropdownMenuItem>
8283
{uploadBatchId && (
8384
<DropdownMenuItem asChild>
8485
<Link href={`/app/batches/${uploadBatchId}`} prefetch={false}>
8586
<GroupIcon className="mr-2 h-4 w-4" />
86-
<span>View batch</span>
87+
<span>{dictionary.upload_item_actions_view_batch}</span>
8788
</Link>
8889
</DropdownMenuItem>
8990
)}
@@ -94,36 +95,33 @@ export function UploadItemActions({
9495
disabled={isDeletingVideo}
9596
>
9697
<Trash2 className="mr-2 h-4 w-4" />
97-
Delete
98+
{dictionary.upload_item_actions_delete}
9899
</DropdownMenuItem>
99100
</AlertDialogTrigger>
100101
</DropdownMenuContent>
101102
</DropdownMenu>
102103

103104
<AlertDialogContent>
104105
<AlertDialogHeader>
105-
<AlertDialogTitle>Are you sure?</AlertDialogTitle>
106+
<AlertDialogTitle>{dictionary.upload_item_actions_confirm_title}</AlertDialogTitle>
106107
<AlertDialogDescription className="space-y-3">
108+
<p>{dictionary.upload_item_actions_confirm_description}</p>
107109
<p>
108-
This action can&apos;t be undone and the video will be permanently
109-
deleted from the server.
110-
</p>
111-
<p>
112-
This will{' '}
110+
{dictionary.upload_item_actions_confirm_note_1}
113111
<span className="font-semibold text-accent-foreground">
114-
permanently
112+
{dictionary.upload_item_actions_confirm_note_2}
115113
</span>
116114
:
117115
</p>
118116
<ol className="list-disc space-y-2 pl-4">
119-
<li>Delete the MP4, MP3 and subtitles from storage;</li>
120-
<li>Delete the video on external provider;</li>
121-
<li>Delete the videos on any outside integration;</li>
117+
<li>{dictionary.upload_item_actions_confirm_step_1}</li>
118+
<li>{dictionary.upload_item_actions_confirm_step_2}</li>
119+
<li>{dictionary.upload_item_actions_confirm_step_3}</li>
122120
</ol>
123121
</AlertDialogDescription>
124122
</AlertDialogHeader>
125123
<AlertDialogFooter>
126-
<AlertDialogCancel>Cancel</AlertDialogCancel>
124+
<AlertDialogCancel>{dictionary.upload_item_actions_cancel}</AlertDialogCancel>
127125
<Button
128126
disabled={isDeletingVideo}
129127
variant="destructive"
@@ -133,7 +131,7 @@ export function UploadItemActions({
133131
{isDeletingVideo ? (
134132
<Loader2 className="h-4 w-4 animate-spin" />
135133
) : (
136-
'Delete'
134+
dictionary.upload_item_actions_delete
137135
)}
138136
</Button>
139137
</AlertDialogFooter>

packages/i18n/dictionaries/en.json

+20-1
Original file line numberDiff line numberDiff line change
@@ -334,5 +334,24 @@
334334
"transcription_card_button_save": "Save",
335335
"transcription_skeleton_generating": "Transcription is being generated",
336336
"transcription_skeleton_auto_refresh": "The page will automatically refresh...",
337-
"metadata_tooltip_request_body": "Request body sent to the webhook"
337+
"metadata_tooltip_request_body": "Request body sent to the webhook",
338+
"copy_button_copied": "Copied!",
339+
"intercepted_sheet_close": "Close",
340+
"transcription_preview_view_transcription": "View transcription",
341+
"transcription_preview_title": "Transcription",
342+
"transcription_preview_button_review": "Review",
343+
"upload_item_actions_toast_error": "Uh oh! Something went wrong.",
344+
"upload_item_actions_toast_error_description": "An error occurred while trying to delete the video. If the error persists, please contact an administrator.",
345+
"upload_item_actions_open_menu": "Open menu",
346+
"upload_item_actions_edit": "Edit",
347+
"upload_item_actions_view_batch": "View batch",
348+
"upload_item_actions_delete": "Delete",
349+
"upload_item_actions_confirm_title": "Are you sure?",
350+
"upload_item_actions_confirm_description": "This action can't be undone and the video will be permanently deleted from the server.",
351+
"upload_item_actions_confirm_note_1": "This will ",
352+
"upload_item_actions_confirm_note_2": "permanently",
353+
"upload_item_actions_confirm_step_1": "Delete the MP4, MP3 and subtitles from storage;",
354+
"upload_item_actions_confirm_step_2": "Delete the video on external provider;",
355+
"upload_item_actions_confirm_step_3": "Delete the videos on any outside integration;",
356+
"upload_item_actions_cancel": "Cancel"
338357
}

packages/i18n/dictionaries/es.json

+20-1
Original file line numberDiff line numberDiff line change
@@ -328,5 +328,24 @@
328328
"transcription_card_button_save": "Guardar",
329329
"transcription_skeleton_generating": "La transcripción está siendo generada",
330330
"transcription_skeleton_auto_refresh": "La página se actualizará automáticamente...",
331-
"metadata_tooltip_request_body": "Cuerpo de la solicitud enviado al webhook"
331+
"metadata_tooltip_request_body": "Cuerpo de la solicitud enviado al webhook",
332+
"copy_button_copied": "¡Copiado!",
333+
"intercepted_sheet_close": "Cerrar",
334+
"transcription_preview_view_transcription": "Ver transcripción",
335+
"transcription_preview_title": "Transcripción",
336+
"transcription_preview_button_review": "Revisar",
337+
"upload_item_actions_toast_error": "¡Uh oh! Algo salió mal.",
338+
"upload_item_actions_toast_error_description": "Ocurrió un error al intentar eliminar el video. Si el error persiste, comuníquese con un administrador.",
339+
"upload_item_actions_open_menu": "Abrir menú",
340+
"upload_item_actions_edit": "Editar",
341+
"upload_item_actions_view_batch": "Ver lote",
342+
"upload_item_actions_delete": "Eliminar",
343+
"upload_item_actions_confirm_title": "¿Está seguro?",
344+
"upload_item_actions_confirm_description": "Esta acción no se puede deshacer y el video se eliminará permanentemente del servidor.",
345+
"upload_item_actions_confirm_note_1": "Esto ",
346+
"upload_item_actions_confirm_note_2": "permanentemente",
347+
"upload_item_actions_confirm_step_1": "Eliminar el MP4, MP3 y subtítulos del almacenamiento;",
348+
"upload_item_actions_confirm_step_2": "Eliminar el video en el proveedor externo;",
349+
"upload_item_actions_confirm_step_3": "Eliminar los videos en cualquier integración externa;",
350+
"upload_item_actions_cancel": "Cancelar"
332351
}

packages/i18n/dictionaries/pt.json

+20-1
Original file line numberDiff line numberDiff line change
@@ -328,5 +328,24 @@
328328
"transcription_card_button_save": "Salvar",
329329
"transcription_skeleton_generating": "A transcrição está sendo gerada",
330330
"transcription_skeleton_auto_refresh": "A página será atualizada automaticamente...",
331-
"metadata_tooltip_request_body": "Corpo da solicitação enviado para o webhook"
331+
"metadata_tooltip_request_body": "Corpo da solicitação enviado para o webhook",
332+
"copy_button_copied": "Copiado!",
333+
"intercepted_sheet_close": "Fechar",
334+
"transcription_preview_view_transcription": "Ver transcrição",
335+
"transcription_preview_title": "Transcrição",
336+
"transcription_preview_button_review": "Revisar",
337+
"upload_item_actions_toast_error": "Uh oh! Algo deu errado.",
338+
"upload_item_actions_toast_error_description": "Ocorreu um erro ao tentar excluir o vídeo. Se o erro persistir, entre em contato com um administrador.",
339+
"upload_item_actions_open_menu": "Abrir menu",
340+
"upload_item_actions_edit": "Editar",
341+
"upload_item_actions_view_batch": "Ver lote",
342+
"upload_item_actions_delete": "Excluir",
343+
"upload_item_actions_confirm_title": "Você tem certeza?",
344+
"upload_item_actions_confirm_description": "Esta ação não pode ser desfeita e o vídeo será permanentemente excluído do servidor.",
345+
"upload_item_actions_confirm_note_1": "Isto ",
346+
"upload_item_actions_confirm_note_2": "permanentemente",
347+
"upload_item_actions_confirm_step_1": "Excluir o MP4, MP3 e legendas do armazenamento;",
348+
"upload_item_actions_confirm_step_2": "Excluir o vídeo no provedor externo;",
349+
"upload_item_actions_confirm_step_3": "Excluir os vídeos em qualquer integração externa;",
350+
"upload_item_actions_cancel": "Cancelar"
332351
}

0 commit comments

Comments
 (0)