← Start Here

START HERE FEATURE

Locale Setup

Locale should become a boring, explicit part of project setup: pick the default, declare supported locales, add JSON catalogs, and verify one translated string end to end.

Feature Guide

A quick orientation block that answers the essential questions: what this feature does, how it works, why it matters, and the key concepts behind it.

What this does

Configure the minimal Locale contract so translations and locale-aware rendering become explicit early.

Locale Baseline

Add the smallest locale setup that is still real

Declare the locale boundary in `.env`, add one JSON file per language, render one translated string through Twig, and restart once so the catalogs reload cleanly.

Step 1

Declare the locale contract in `.env`

Keep the first setup tiny. You usually need only the default locale, fallback locale, supported locales, and whether locale prefixes belong in URLs.

LOCALE_DEFAULT=en
LOCALE_FALLBACK=en
LOCALE_SUPPORTED=en,uk
LOCALE_URL_PREFIX=false

Step 2

Add one JSON catalog per language

Locale files are module-local. Start with one or two keys, not a giant spreadsheet dump.

src/Application/View/locales/en.json
{"ContactForm.title":"Contact us","ContactForm.submit":"Send"}
src/Application/View/locales/uk.json
{"ContactForm.title":"Zvjazhit`sja z namy","ContactForm.submit":"Nadislaty"}

Step 3

Render and verify one translated string

Use `trans()` in Twig, restart once so the worker reloads catalogs, then verify the output through the locale path or request headers.

{{ trans('ContactForm.title') }}
bin/semitexa server:restart
curl -H 'Accept-Language: uk' http://semitexa.test
http://semitexa.test

Important Defaults

  • If you installed from `semitexa/ultimate`, the locale package is already part of the baseline stack.
  • JSON locale catalogs are loaded at worker boot, so restart or reload after editing them.
  • Turn `LOCALE_URL_PREFIX=true` on only when you really want locale-prefixed URLs like `/uk/...`.
  • Keep keys module-scoped from day one. `ContactForm.title` ages much better than `title`.
locale supported locales translation catalogs trans()

Verified against Semitexa Ultimate 2026.09.19.1020

Locale Setup

Semitexa keeps locale as an explicit contract. Even when phase 1 ships English-only documentation, the runtime should still make locale handling visible and deterministic.

Canonical flow

  1. Define the default locale.
  2. Declare supported locales.
  3. Wire translation catalogs.
  4. Verify one translation in Twig so the path is proven.

What to preserve

  • locale resolution remains explicit
  • fallback behavior is deterministic
  • translation keys do not turn into scattered string guesses

Why this matters

Multilingual support is easiest to preserve when the first locale setup is explicit, even if only English content is active at the beginning.

Minimal Means Reviewable

What the first locale pass should already prove

The first locale setup does not need plural rules, per-tenant overrides, or a language switcher yet. It only needs to prove that the contract is real and inspectable.

Keep `LOCALE_SUPPORTED` short until you have real copy for each language.

Use one translated Twig key as a smoke test before you spread `trans()` across the app.

If locale output looks wrong, check `.env`, then the JSON file path, then restart the worker before debugging deeper.

When tenant-specific locale defaults matter, continue with the Tenancy and platform locale pages after this baseline is working.

Support Semitexa
Built for developers who prefer control over magic. Your support helps keep it fast, open, and evolving.

Donate via PayPal