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
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 oft:
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 theAccept-Language header and pass it to each call:
Adding a custom locale
Pass atranslations map, or call addLocale at runtime:
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.