---
title: Localize Arc backends
editUrl: https://github.com/Cratis/Arc.Kotlin/edit/main/Documentation/guides/localization.md
description: Configure Arc localization in Spring Boot, select a UI language for HTTP and observable queries, and expose structured validation findings to clients.
lastUpdated: 2026-12-03T00:00:00.000Z
---


Localization is opt-in. Publish an `ArcLocalization` bean in a Spring Boot application using the Arc starter. Without the bean, Arc does not negotiate a UI language, change response headers, or add framework validation descriptors.

```kotlin
import io.cratis.arc.springboot.localization.ArcLocalization
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

@Configuration
class LocalizationConfiguration {
    @Bean
    fun arcLocalization(): ArcLocalization = ArcLocalization.Builder(
        languages = listOf("en", "fr", "fr-CA"),
        defaultLanguage = "en"
    )
        .addCatalog("en", mapOf("orders.accepted" to "Order accepted."))
        .addCatalog("fr", mapOf("orders.accepted" to "Commande acceptée."))
        .build()
}
```

## Negotiate the UI language

By default, Arc uses `Accept-Language`, including quality weights, wildcards, and exclusions. Arc tries exact matches, configured aliases, parent languages, then a unique eligible descendant. It does not guess between regional siblings. When no preference can select a language, Arc uses the eligible default, then the first eligible supported language, then the configured default if every language is excluded.

Pass an ordered `providers` list to `ArcLocalization.Builder` to opt in to `LocalizationProvider.QueryString` (`ui-culture`) or `LocalizationProvider.Cookie` (`.AspNetCore.Culture`, containing `c=...|uic=...`). Include `LocalizationProvider.AcceptLanguage` in that list to continue honoring the header. The cookie's UI value wins over its formatting value. Normal HTTP requests ignore `_cratisUiCulture`; an SSE or WebSocket handshake can use one valid `_cratisUiCulture` query value before the configured providers. The hint is not a query argument or a subscription override.

Localized responses set `Content-Language`, including errors and stream handshakes. The header provider adds `Vary: Accept-Language`; the cookie provider adds `Vary: Cookie` and sets `Cache-Control: no-store, private`. Enabling a provider changes caching even when a different provider chooses the language. The query provider needs no additional `Vary` token.

## Look up application messages

In a suspending Arc handler, read `UiLanguage.current()` from `io.cratis.arc.localization`. In a Spring MVC handler, read `localization.language(request)`. At a background-work boundary, use a recipient's chosen language instead of the JVM default: pass `UiLanguage.withLanguage("fr-CA")` to `localization.message(context, id)`, or use it with `withContext` before calling suspending code. If you use Spring `MessageSource` instead of Arc catalogs, call `getMessage` with an explicit `Locale.forLanguageTag(recipientTag)`. Java callers can use `UiLanguage.get(context)` and the same context-based lookup.

Register catalogs before building the policy. Duplicate IDs for the same language reject the whole registration. For missing entries, lookup falls back from a regional language to its parent and then the default language. Unknown IDs return `null`. A UI language does not change date or number formatting and setting one manually does not enable framework validation descriptors.

## Format validation findings on the client

The server keeps the existing English fallback message. Localized hosts add stable `reasonDetail` values and, where needed, named `messageArguments` to supported framework findings. Application validators can supply named arguments on a `ValidationResult` using `withMessageArguments(...)`; use only strings, booleans, and finite numbers with integer values in the JavaScript safe-integer range. Do not put submitted values or personal data into an argument. Clients can look up a localized message using the descriptor and fall back to the supplied message when no translation exists.
