# Translation Entry

> Translation key-value entry with namespace, locale, and placeholders.

- Name: `translation-entry`
- Categories: i18n
- Detail page: https://open-types.dev/types/translation-entry

## Install

```bash
# Types only
npx shadcn add @open-types/translation-entry

# Types + Zod v4 validators
npx shadcn add @open-types/translation-entry-zod

# Types + real-world examples
npx shadcn add @open-types/translation-entry-examples
```

## Types

```typescript
export interface TranslationEntry {
  key: string;
  value: string;
  namespace?: string;
  locale?: string;
  description?: string;
  placeholders?: string[];
}
```

## Zod validator

```typescript
import * as z from "zod";
import type { TranslationEntry } from "../types/translation-entry";

export const translationEntrySchema = z.object({
  key: z.string().min(1, { error: "Key is required" }),
  value: z.string(),
  namespace: z.string().min(1, { error: "Namespace cannot be empty" }).optional(),
  locale: z.string().min(1, { error: "Locale cannot be empty" }).optional(),
  description: z.string().optional(),
  placeholders: z.array(z.string().min(1, { error: "Placeholder cannot be empty" })).optional(),
}) satisfies z.ZodType<TranslationEntry>;

export type { TranslationEntry } from "../types/translation-entry";
```

## Examples

```typescript
// Source: hand-crafted; modeled after i18next/Format.JS message catalogs
import type { TranslationEntry } from "../types/translation-entry";

export const translationEntryExamples = {
  simple: {
    key: "common.welcome",
    value: "Welcome back!",
    locale: "en-US",
  } satisfies TranslationEntry,
  withPlaceholders: {
    key: "checkout.greeting",
    value: "Hi {name}, you have {count} items in your cart.",
    namespace: "checkout",
    locale: "en-US",
    description: "Greeting shown on the checkout page.",
    placeholders: ["name", "count"],
  } satisfies TranslationEntry,
  rtlArabic: {
    key: "common.welcome",
    value: "مرحبًا بعودتك!",
    locale: "ar-SA",
    description: "Welcome message in Arabic.",
  } satisfies TranslationEntry,
  german: {
    key: "common.welcome",
    value: "Willkommen zurück!",
    locale: "de-DE",
  } satisfies TranslationEntry,
  pluralForm: {
    key: "cart.items_plural",
    value: "{count, plural, =0 {No items} one {# item} other {# items}}",
    namespace: "cart",
    locale: "en-US",
    placeholders: ["count"],
  } satisfies TranslationEntry,
  minimal: { key: "noop", value: "" } satisfies TranslationEntry,
} as const;
```
