Skip to content
No results found.

Customizing Templates

PlusAuth uses Twig as its templating engine. We've prepared an Introductory Guide to Twig to help you get started.

Preview and Variables

When editing a template:

  • Switch to the Preview tab to see how your template will look.
  • Use the Edit preview variables button above the editor to adjust test data.

Preview variables are only for testing purposes. Changes made to the preview JSON do not affect real usage.

Available Variables

Each template may have a different set of variables. You can find the list of variables for each template in their preview variables from the dashboard. The following variables are available for every template:

KeyDescription

request.language

Language parameter of request. See Localization

application.name

Initiating Client's name

application.id

Initiating Client's id

application.metadata

Initiating Client's metadata

tenant.id

Your tenant's id

tenant.display_name

Your tenant's display name

user

Target user object. See Reference

Localizing Templates

The most straightforward way to localize your templates is to use the user.profile.locale variable.

You can use the request.language variable to localize your templates. This variable contains the language code that represents the user's preferred language.

The value of request.language is determined from:

  • X-Request-Language header – You can explicitly set this header to send a custom locale value.
  • Accept-Language header – This header is sent automatically by browsers to indicate the user's preferred languages.

If both headers are present, X-Request-Language takes priority. This allows you to override the browser's default language when needed.

The following template snippet checks the user's locale, falling back to first locale defined at request.language if not set:

{# Use the user's profile locale if available, otherwise take the first language from request.language #}
{% set locale = user.profile.locale ? user.profile.locale : (request.language | split(";") | at(0)) %}
{% if 'de' in locale %}
Verfügbar
{% elseif 'tr' in locale %}
Mevcut
{% else %}
Available
{% endif %}