---
title: Localization
description: Translate WireKit's built-in strings — the JSON key reference, publishing it, and adding your own locale
visibility: guest
draft: false
---

# Localization

Every user- and screen-reader-visible string WireKit renders itself — `Close`, `Next`, `Uploading`, `Add to cart`, the pagination summary, the "is typing…" announcement — runs through Laravel's `__()` translation helper. The English text **is** the translation key, so out of the box everything reads in English and nothing breaks. To ship another language you translate those keys.

> **What this covers.** Only the strings WireKit hard-codes. Text **you** pass into a component (labels, slot content, your own copy) is yours to translate however your app already does. This page is about the handful of built-in words WireKit adds on your behalf.

## The key reference

WireKit ships `lang/en.json` — the complete, generated list of every string key its components emit, each mapped to its English text. This is your reference: it is exactly the set of keys you can translate, nothing more to hunt for.

Publish a copy into your app to work from:

```bash
# 1. Copy WireKit's English key reference into your app's lang directory.
#    Lands at lang/vendor/wirekit/en.json — a read-only reference to copy from.
php artisan vendor:publish --tag=wirekit-lang
```

## Adding a locale

Laravel's JSON translation loader matches on the key, so a translated file in your app's own `lang/` directory overrides WireKit's English per key — no configuration, no per-package wiring.

```bash
# 2. Create a locale file named for the target locale (German shown here).
#    It lives in your app's lang/ root, NOT under vendor/ — that is where
#    Laravel looks first, so your values win over WireKit's English.
cp lang/vendor/wirekit/en.json lang/de.json
```

```json
// 3. lang/de.json — translate the VALUES, keep the keys verbatim.
//    Untranslated keys fall back to their English text, so you can
//    translate incrementally; there is no all-or-nothing requirement.
{
    "Close": "Schließen",
    "Next": "Weiter",
    "Previous": "Zurück",
    "Add to cart": "In den Warenkorb",
    "Out of stock": "Ausverkauft"
}
```

Set your app's locale as usual (`app()->setLocale('de')`, or your locale middleware) and WireKit's strings follow.

## Placeholders and pluralization

Some keys carry placeholders or plural forms. Keep the placeholder tokens (`:current`, `:last`, `:page`, `:total`, `:count`, `:status`, `:n`) exactly as they appear — only the words around them are yours to translate.

```json
// 4. Placeholder keys: move the :tokens to where your grammar needs them,
//    but never rename or drop them.
{
    "Page :current of :last": "Seite :current von :last",
    "Showing :first to :last of :total results": ":first bis :last von :total Ergebnissen",
    "Go to page :page": "Zu Seite :page"
}
```

```json
// 5. Pluralization keys use Laravel's pipe syntax (trans_choice). Preserve
//    the {0} / {1} / [2,*] range markers; translate only the phrases.
{
    "{0} no reactions|{1} :count person reacted|[2,*] :count people reacted": "{0} keine Reaktionen|{1} :count Person hat reagiert|[2,*] :count Personen haben reagiert"
}
```

## How it stays complete

The key reference is guarded against drift: a WireKit release can never add a built-in string without adding its key to `lang/en.json`, so the file you translate is always the full set. When you upgrade WireKit and new keys appear, re-run the publish above and diff `lang/vendor/wirekit/en.json` against your locale file to see exactly which new strings need a translation.
