Overview
createI18n gives you typed access to KavachOS’s built-in translation strings. Use it to return localized error messages to users, translate email subjects, or power a multi-language UI.
Setup
defaultLocale. You can override it per-request (see below).
Built-in locales
| Code | Language |
|---|---|
en | English |
es | Spanish |
fr | French |
de | German |
ja | Japanese |
zh | Chinese (Simplified) |
Translating a string
Variable interpolation
Pass a variables object as the second argument. Variables are referenced with{{name}} in translation strings.
Per-request locale
Detect the user’s locale from theAccept-Language header and pass it to each call:
Adding a custom locale
Register additional locales at runtime by passing alocales map:
defaultLocale.
Missing keys always fall back to the
defaultLocale value rather than throwing. This means partial translations are safe to ship.Translation key reference
| Key | Variables | Description |
|---|---|---|
auth.invalidCredentials | , | Wrong email or password |
auth.rateLimited | retryAfter | Too many login attempts |
auth.sessionExpired | , | Session has expired |
auth.unauthorized | , | Request is not authenticated |
auth.forbidden | , | Authenticated but lacks permission |
auth.emailNotVerified | , | Email address not yet verified |
auth.otpInvalid | , | OTP code is incorrect or expired |
agent.notFound | agentId | Agent ID does not exist |
agent.revoked | agentId | Agent has been revoked |
delegation.expired | , | Delegation grant has expired |
errors.internal | , | Unexpected server error |
email.verification.subject | appName | Email verification subject line |
email.passwordReset.subject | appName | Password reset subject line |
email.magicLink.subject | appName | Magic link subject line |
email.otp.subject | appName | OTP delivery subject line |
email.invitation.subject | orgName | Organization invitation subject |
email.welcome.subject | appName, name | Welcome email subject line |
Next steps
Email templates
Built-in HTML templates for every auth flow.
Error reference
Full list of KavachOS error codes.