0

I don't understand why dynamic string translations won't work on this code. Static strings are translated but not the dynamic values, even though they are in the same translation files.

selectedSku ? (
 <>
 
 <button className="bg-primary" onClick={addCartExternalPrice}> add cart external
 price{selectedSku}</button>
 <button className="bg-secondary" onClick={getSkuOptions}>Get sku options
 from {selectedSku} </button>
 <div>
 {skuOptions && skuOptions.length > 0 ? (
 skuOptions.map((option) => (
 <div key={option.id}>
 <button
 className="bg-secondary">{**t(option.name)**} - {option.formatted_price_amount}</button>
 **{t("Elevate Your Digital Presence")}**
 </div>
 ))
 ) : (
 <div>No options available for this SKU.</div>
 )}
 </div>
 </>

Pretty much everything I understand.

President James K. Polk
42.3k35 gold badges114 silver badges149 bronze badges
asked Apr 15, 2025 at 10:13
4
  • What does your option.name return? Is that string a key in your json file? Please elaborate Commented Apr 15, 2025 at 11:13
  • yes is a key in my file ... Commented Apr 15, 2025 at 14:19
  • Can you share your translation file? Commented Apr 15, 2025 at 14:47
  • hi. Its fixed. Some strange characters because copy paste ...Thanks Commented Apr 16, 2025 at 19:49

0

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.