# General Translation Platform: Variable
URL: https://generaltranslation.com/en-GB/docs/platform/core/reference/types/variable.mdx
Docs index: https://generaltranslation.com/llms.txt
Description: Placeholder for dynamic content in translatable messages. API reference for Variable type.

`Variable` carries a key and an optional formatting type, so General Translation can substitute and format runtime values inside translatable [`JsxChildren`](/docs/platform/core/reference/types/jsx-children) content.

## Overview [#overview]

A `Variable` is identified by its key `k`, with an optional internal identifier `i` and an optional formatting type `v`.

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

## Properties [#properties]

| Property              | Description          | Type           | Optional |
| --------------------- | -------------------- | -------------- | -------- |
| [`k`](#key)           | Variable key/name.   | `string`       | No       |
| [`i`](#id)            | Internal identifier. | `number`       | Yes      |
| [`v`](#variable-type) | Formatting type.     | `VariableType` | Yes      |

### `k` [#key]

**Type** `string` · **Required**

The variable&#39;s key or name, used to match it to a runtime value.

### `i` [#id]

**Type** `number` · **Optional**

Internal identifier used by General Translation.

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

**Type** `VariableType` · **Optional**

The formatting type applied to the substituted value:

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

| Value  | Description               |
| ------ | ------------------------- |
| `'v'`  | Plain text substitution.  |
| `'n'`  | Number formatting.        |
| `'d'`  | Date formatting.          |
| `'c'`  | Currency formatting.      |
| `'rt'` | Relative time formatting. |

*Note:* the older docs omitted `'rt'`; it is present in the current source.

## Example [#example]

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

// Text variable
const nameVariable: Variable = {
  k: 'userName'
};

// Number variable
const countVariable: Variable = {
  k: 'itemCount',
  v: 'n'
};

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

```typescript
// In JSX content
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.
