@@ -6,23 +6,25 @@ import { Button } from "@medusajs/ui"
6
6
import { useParams , usePathname } from "next/navigation"
7
7
import { Fragment , useEffect , useRef , useState } from "react"
8
8
9
+ import { useI18n , useScopedI18n } from "../../../../locales/client"
9
10
import { formatAmount } from "@lib/util/prices"
10
11
import DeleteButton from "@modules/common/components/delete-button"
11
12
import LineItemOptions from "@modules/common/components/line-item-options"
12
13
import LineItemPrice from "@modules/common/components/line-item-price"
13
14
import LocalizedClientLink from "@modules/common/components/localized-client-link"
14
15
import Thumbnail from "@modules/products/components/thumbnail"
15
16
16
- const CartDropdown = ( {
17
+ export default function CartDropdown ( {
17
18
cart : cartState ,
18
19
} : {
19
20
cart ?: Omit < Cart , "beforeInsert" | "afterLoad" > | null
20
- } ) => {
21
+ } ) {
21
22
const [ activeTimer , setActiveTimer ] = useState < NodeJS . Timer | undefined > (
22
23
undefined
23
24
)
24
25
const [ cartDropdownOpen , setCartDropdownOpen ] = useState ( false )
25
26
27
+ const t = useScopedI18n ( "cart.dropdown" )
26
28
const { countryCode } = useParams ( )
27
29
28
30
const open = ( ) => setCartDropdownOpen ( true )
@@ -82,7 +84,11 @@ const CartDropdown = ({
82
84
className = "hover:text-ui-fg-base"
83
85
href = "/cart"
84
86
data-testid = "nav-cart-link"
85
- > { `Cart (${ totalItems } )` } </ LocalizedClientLink >
87
+ >
88
+ { t ( "cart" , {
89
+ count : totalItems ,
90
+ } ) }
91
+ </ LocalizedClientLink >
86
92
</ Popover . Button >
87
93
< Transition
88
94
show = { cartDropdownOpen }
@@ -142,7 +148,7 @@ const CartDropdown = ({
142
148
data-testid = "cart-item-quantity"
143
149
data-value = { item . quantity }
144
150
>
145
- Quantity: { item . quantity }
151
+ { t ( "quantity" ) } { item . quantity }
146
152
</ span >
147
153
</ div >
148
154
< div className = "flex justify-end" >
@@ -159,7 +165,7 @@ const CartDropdown = ({
159
165
className = "mt-1"
160
166
data-testid = "cart-item-remove-button"
161
167
>
162
- Remove
168
+ { t ( "remove" ) }
163
169
</ DeleteButton >
164
170
</ div >
165
171
</ div >
@@ -168,7 +174,7 @@ const CartDropdown = ({
168
174
< div className = "p-4 flex flex-col gap-y-4 text-small-regular" >
169
175
< div className = "flex items-center justify-between" >
170
176
< span className = "text-ui-fg-base font-semibold" >
171
- Subtotal { " " }
177
+ { t ( "subtotal" ) } { " " }
172
178
< span className = "font-normal" > (excl. taxes)</ span >
173
179
</ span >
174
180
< span
@@ -189,7 +195,7 @@ const CartDropdown = ({
189
195
size = "large"
190
196
data-testid = "go-to-cart-button"
191
197
>
192
- Go to cart
198
+ { t ( "gotocart" ) }
193
199
</ Button >
194
200
</ LocalizedClientLink >
195
201
</ div >
@@ -200,12 +206,12 @@ const CartDropdown = ({
200
206
< div className = "bg-gray-900 text-small-regular flex items-center justify-center w-6 h-6 rounded-full text-white" >
201
207
< span > 0</ span >
202
208
</ div >
203
- < span > Your shopping bag is empty. </ span >
209
+ < span > { t ( " empty" ) } </ span >
204
210
< div >
205
211
< LocalizedClientLink href = "/store" >
206
212
< >
207
- < span className = "sr-only" > Go to all products page </ span >
208
- < Button onClick = { close } > Explore products </ Button >
213
+ < span className = "sr-only" > { t ( "gotoall" ) } </ span >
214
+ < Button onClick = { close } > { t ( "explore" ) } </ Button >
209
215
</ >
210
216
</ LocalizedClientLink >
211
217
</ div >
@@ -218,5 +224,3 @@ const CartDropdown = ({
218
224
</ div >
219
225
)
220
226
}
221
-
222
- export default CartDropdown
0 commit comments