Localization
Support multiple languages in your application.
Passage Elements
The passage-auth
, passage-login
, passage-register
, passage-profile
, and passage-passkey-table
elements all support localization to the following languages:
- "en" - English
- "es" - Spanish
- "de" - German
- "it" - Italian
- "pl" - Polish
- "pt" - Portuguese
- "zh" - Chinese
To use the localization feature simply add a lang
attribute to the elements like this:
<passage-auth app-id="<Your App ID>" lang="de" />
If the lang tag is set to a supported language the elements will render all text in that language. If the lang
attribute is updated at run-time then the elements will adapt to this change and re-render in the newly provided language.
Language auto-detection and fallbacks
Auto-detection by default
The elements also support auto-detecting the current language set by the browser. This is the default behavior of the element, so if no lang
attribute is provided then the element will attempt to localize to the default browser language setting.
Default language
If the browser language is not a supported language or an unsupported language is passed to the lang
attribute, the elements will fallback to the application's default language.
The default language can be configured in Passage Console under Authentication > Languages.
Emails and text messages
Default behavior
If your application uses the default emails and text messages to send the Magic Link emails, Passage will automatically localize to the supported languages, or the default language if the currently set language is unsupported.
Custom emails and text message templates
If you have customized the default email or sms templates. then you will need to add in support for localized language to your templates.
The currently used language for the link to be sent is provided as a template variable {{.magic_link.locale}}
and can be used with Go templating syntax (opens in a new tab)to make decisions on what text to render in the custom emails.
{{ if (eq .magic_link.locale "de") }}
Dies ist eine deutsche Saite
{{else if (eq .magic_link.locale "it") }}
Questa è una stringa italiana
{{else}}
This is English string
{{end}}
Embedded links
Most of the time when you use embedded links, you will send them using your own email provider and template. However if you do want to send a Magic Link through Passage using the management API, just include the language
parameter in the JSON.
Request a specific language
Have a request for a specific language? Email us at support@passage.id and let us know!