Skip to main content

Overview

createI18n gives you typed access to theAuth’s built-in translation strings. Use it to return localized error messages to users, translate email subjects, or power a multi-language UI. It is a standalone helper, theAuth’s own endpoints return English error text and do not call it for you.

Setup

Only English is registered by default. The other built-in locale bundles are exported separately (es, fr, de, ja, zh) so you only bundle what you use, and you register them through translations or addLocale. defaultLocale is the locale used when you do not pass one to t.

Built-in locales

Translating a string

The locale is the second argument of t:
t(key, locale?) and t(key, vars, locale?) are the two call shapes. Locale lookup tries an exact match (fr-CA), then the language prefix (fr), then defaultLocale, then en.

Variable interpolation

Pass a variables object as the second argument and the locale as the third. Variables are referenced with {{name}} in translation strings. Unknown variables are left as {{name}}.

Per-request locale

Detect the user’s locale from the Accept-Language header and pass it to each call:

Adding a custom locale

Pass a translations map, or call addLocale at runtime:
Translations you supply merge over any keys already registered for that locale.
A key missing from a locale falls back to the English string, and an unknown key returns the key itself. Partial translations are safe to ship.

Translation key reference

Next steps

Email templates

Built-in HTML templates for auth emails.

Error reference

theAuth error codes and their meanings.
Last modified on October 7, 2026