@@ -4,6 +4,7 @@ import { ChangeEventHandler, useCallback, useEffect, useState } from "react"
44import { Button , Col , Form , InputGroup , Row , Spinner } from "../bootstrap"
55import { AttachmentInfo , UseDraftTestimonyAttachment } from "../db"
66import { External } from "../links"
7+ import { useTranslation } from "next-i18next"
78
89export function Attachment ( {
910 attachment,
@@ -65,11 +66,10 @@ const Label = ({
6566} : {
6667 attachment : UseDraftTestimonyAttachment
6768} ) => {
69+ const { t } = useTranslation ( "attachment" )
6870 return (
6971 < Form . Label >
70- < span className = "me-1" >
71- (Optional) Provide your testimony as a file attachment
72- </ span >
72+ < span className = "me-1" > { t ( "provide_testimony_as_file" ) } </ span >
7373 { status === "loading" && < Spinner animation = "border" size = "sm" /> }
7474 { status === "error" && (
7575 < FontAwesomeIcon icon = { faExclamationTriangle } className = "text-danger" />
@@ -85,13 +85,10 @@ export const AttachmentLink = ({
8585 attachment : AttachmentInfo
8686 className ?: string
8787} ) => {
88- const linkLabel = [
89- "Attached" ,
90- name ?? "Testimony" ,
91- size ? formatSize ( size ) : null
92- ]
93- . filter ( Boolean )
94- . join ( " - " )
88+ const { t } = useTranslation ( "attachment" )
89+ const linkLabelParts = [ t ( "attached" ) , name ?? t ( "testimony" ) ]
90+ if ( size ) linkLabelParts . push ( formatSize ( size ) )
91+ const linkLabel = linkLabelParts . join ( " - " )
9592 return (
9693 < External className = { className } href = { url } >
9794 { linkLabel }
@@ -106,13 +103,10 @@ const Attached = ({
106103 attachment : UseDraftTestimonyAttachment
107104 confirmRemove : boolean
108105} ) => {
106+ const { t } = useTranslation ( "attachment" )
109107 const { url, name, size, id, remove, status } = attachment
110108 const onClick = ( ) => {
111- if (
112- ! confirmRemove ||
113- confirm ( "Are you sure you want to remove your attachment?" )
114- )
115- remove ( )
109+ if ( ! confirmRemove || confirm ( t ( "confirm_remove" ) ) ) remove ( )
116110 }
117111 return (
118112 < Row className = "align-items-center" >
@@ -128,7 +122,7 @@ const Attached = ({
128122 onClick = { onClick }
129123 disabled = { status === "loading" }
130124 >
131- Remove
125+ { t ( "remove" ) }
132126 </ Button >
133127 </ Col >
134128 </ Row >
@@ -140,19 +134,18 @@ const StatusMessage = ({
140134} : {
141135 attachment : UseDraftTestimonyAttachment
142136} ) => {
137+ const { t } = useTranslation ( "attachment" )
143138 if ( status === "error" ) {
144139 let message : string
145140 if ( error ?. code === "storage/unauthorized" ) {
146- message = "Invalid file. Please upload PDF's less than 10 MB"
141+ message = t ( "error.storage_unauthorized" )
147142 } else {
148- message = "Something went wrong. Please try again."
143+ message = t ( "error.generic" )
149144 }
150145
151146 return < Form . Text className = "text-danger" > { message } </ Form . Text >
152147 } else if ( status === "ok" && ! id ) {
153- return (
154- < Form . Text > Files must be PDF documents and less than 10 MB.</ Form . Text >
155- )
148+ return < Form . Text > { t ( "file_requirements" ) } </ Form . Text >
156149 } else {
157150 return null
158151 }
0 commit comments