# gt-react: General Translation React SDK: Stringhe URL: https://generaltranslation.com/it/docs/react/guides/strings.mdx --- title: Stringhe description: Come internazionalizzare semplici stringhe di testo con useGT --- {/* GENERATO AUTOMATICAMENTE: non modificare direttamente. Modifica il modello in content/docs-templates/. */} La traduzione di stringhe consente di accedere direttamente alle traduzioni di testo senza JSX, ed è ideale per attributi, proprietà di oggetti e valori di testo semplice. Usa [`useGT`](/docs/react/api/strings/use-gt) nei componenti React per tradurre le stringhe. ## Guida rapida ```jsx import { useGT } from 'gt-react'; function MyComponent() { const gt = useGT(); return ( ); } ``` ## Quando usare la traduzione di stringhe La traduzione di stringhe è ideale quando ti serve testo normale anziché JSX: ### Attributi HTML ```jsx const gt = useGT(); ``` ### Proprietà dell'oggetto ```jsx const gt = useGT(); const user = { name: 'John', role: 'admin', bio: gt('Experienced software developer with 5 years in React'), status: gt('Currently available for projects') }; ``` ### Configurazione e costanti ```jsx const gt = useGT(); const navigationItems = [ { label: gt('Home'), href: '/' }, { label: gt('Products'), href: '/products' }, { label: gt('Contact'), href: '/contact' } ]; ``` ### Quando usare invece T Usa il [componente ``](/docs/react/api/components/t) per i contenuti JSX: ```jsx // ✅ Usa per contenuto JSX

Welcome to our store!

// ✅ Usa la traduzione di stringhe per testo normale ``` ## Utilizzare le variabili ### Variabili di base Sostituisci i segnaposto con valori dinamici: ```jsx const gt = useGT(); const itemCount = 5; // Stringa con segnaposto const message = gt('You have {count} items in your cart', { count: itemCount }); // Risultato: "You have 5 items in your cart" ``` ### Più variabili ```jsx const gt = useGT(); const order = { id: 'ORD-123', total: 99.99, date: '2024-01-15' }; const confirmation = gt( 'Order {orderId} for ${total} was placed on {date}', { orderId: order.id, total: order.total, date: order.date } ); ``` ### Formato dei messaggi ICU Per una formattazione avanzata, usa la sintassi ICU: ```jsx const gt = useGT(); translate('There are {count, plural, =0 {no items} =1 {one item} other {{count} items}} in the cart', { count: 10 }); ``` Scopri di più sul formato dei messaggi ICU nella [documentazione di Unicode](https://unicode-org.github.io/icu/userguide/format_parse/messages/). ## Esempi ### Campi del form ```jsx import { useGT } from 'gt-react'; function ContactForm() { const gt = useGT(); return (