# General Translation Platform: Variable
URL: https://generaltranslation.com/it/docs/platform/core/reference/types/variable.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Segnaposto per il contenuto dinamico nei messaggi traducibili. Riferimento API per il tipo Variable.

`Variable` ha una chiave e un tipo di formattazione facoltativo, così General Translation può sostituire e formattare i valori in fase di esecuzione all&#39;interno del contenuto traducibile [`JsxChildren`](/docs/platform/core/reference/types/jsx-children).

## Panoramica [#overview]

Una `Variable` è identificata dalla chiave `k`, con un identificatore interno facoltativo `i` e un tipo di formattazione facoltativo `v`.

```typescript
type Variable = {
  k: string;
  i?: number;
  v?: VariableType;
};
```

## Proprietà [#properties]

| Proprietà             | Descrizione                  | Tipo           | Facoltativo |
| --------------------- | ---------------------------- | -------------- | ----------- |
| [`k`](#key)           | Chiave/nome della variabile. | `string`       | No          |
| [`i`](#id)            | Identificatore interno.      | `number`       | Sì          |
| [`v`](#variable-type) | Tipo di formattazione.       | `VariableType` | Sì          |

### `k` [#key]

**Tipo** `string` · **Obbligatorio**

La chiave o il nome della variabile, che serve ad associarla a un valore di runtime.

### `i` [#id]

**Tipo** `number` · **Facoltativo**

Identificatore interno usato da General Translation.

### `v` [#variable-type]

**Tipo** `VariableType` · **Facoltativo**

Il formato applicato al valore sostituito:

```typescript
type VariableType = 'v' | 'n' | 'd' | 'c' | 'rt';
```

| Valore | Descrizione                       |
| ------ | --------------------------------- |
| `'v'`  | Sostituzione di plain text.       |
| `'n'`  | Formattazione numerica.           |
| `'d'`  | Formattazione della data.         |
| `'c'`  | Formattazione Currency.           |
| `'rt'` | Formattazione del tempo relativo. |

*Nota:* nella documentazione meno recente `'rt'` era omesso; è presente nella sorgente attuale.

## Esempio [#example]

```typescript
import { Variable } from 'generaltranslation/types';

// Variabile di testo
const nameVariable: Variable = {
  k: 'userName'
};

// Variabile numerica
const countVariable: Variable = {
  k: 'itemCount',
  v: 'n'
};

// Variabile Currency
const priceVariable: Variable = {
  k: 'price',
  v: 'c'
};
```

```typescript
// Nel contenuto JSX
const welcomeContent = [
  'Welcome back, ',
  { k: 'userName' } as Variable,
  '! You have ',
  { k: 'messageCount', v: 'n' } as Variable,
  ' messages.'
];
```

## Sitemap

See the full [sitemap](https://generaltranslation.com/sitemap.md) for all pages.
