# Translation Keys

> The Translation Keys are identifiers used in code to look up translated text in translation files.

## How should I name translation keys?

The identifiers, such as 'checkout.payButton', that code uses instead of text. Translation files map each key to text in every language. Clear, namespaced keys make missing and unused translations easy to find.

- Topic: Internationalization
- Type: concept

## Example

Wrong:

```json
{
  "button1": "Pay now",
  "text2": "Order summary"
}
```

Right:

```json
{
  "checkout": {
    "payButton": "Pay now",
    "summaryTitle": "Order summary"
  }
}
```

Namespaced, descriptive keys show translators where text appears and make unused keys easy to find.

## Common mistakes

- Reusing one key for the same English word in different contexts.

## Key points

- Every key used in the code exists in the translation file of each supported language.
- Keys describe meaning and place, not the English text itself.
- Missing keys fall back to the default language instead of showing the raw key.

## Interview questions

### Should translation keys be the English text?

Text-as-key is readable, but editing the English changes the key and orphans every translation. Semantic keys stay stable.

### Flat or nested translation keys?

Both work. Nested keys group by feature, flat dotted keys are easy to search; pick one style and keep it.

### How do I find unused translation keys?

Use a tool that extracts keys from code and compares them with translation files. Avoid building keys at runtime like `t('status.' + s)`.

## Related cards

- [ICU Message Format](https://wonderium.dev/web/icu-message-format.md)
- [i18n](https://wonderium.dev/web/i18n.md)
- [Pseudo-Localization](https://wonderium.dev/web/pseudo-localization.md)

---

- Level: [Web Platform](https://wonderium.dev/web.md)
- HTML version: https://wonderium.dev/web/translation-keys
- Last updated: 2026-11-25
