How to Add Custom Text and Translations Using Auth0 Advanced Customizations for Universal Login (ACUL)
Last Updated:
Overview
Advanced Customization for New Universal Login (ACUL) allows administrators to modify the HTML structure of individual screens, add conditional rendering, and inject trusted JavaScript logic. To customize text and translations, bundle custom strings directly within the React application using a standard localization library and merge them with Auth0 native text.
Applies To
- Advanced Customization for New Universal Login (ACUL)
- React Software Development Kit (SDK)
- Translations
Solution
How are custtom text and translations added using ACUL?
To add custom text and translations in the New Universal Login, bundle the custom strings within the React application and merge them with the native Auth0 text using the screen hook by following these steps.
- Open the React application codebase.
- Define a custom translation dictionary using a standard localization library (e.g.,
react-intl,react-i18next) or a JSON dictionary map. - Import the required screen hook from the
@auth0/auth0-acul-reactpackage. - Call the screen hook within the component to access the native Auth0 text and the current locale.
- Merge the native text with the custom translation dictionary based on the active locale.
- Implement the following code snippet to apply the custom translations to the login screen.
import React from 'react';
//Example using the login-id screen
import { useLoginId } from "@auth0/auth0-acul-react";
const myCustomTranslations = {
en: {
customFooter: "Need help? Call our support team.",
promoBanner: "Sign up today!"
},
es: {
customFooter: "¿Necesita ayuda? Llame a soporte.",
promoBanner: "¡Regístrese hoy para!"
}
};
export function LoginId() {
const loginId = useLoginId();
const locale = loginId.transaction?.locale ?? "en";
const customText = myCustomTranslations[locale] || myCustomTranslations["en"];
}
return (
<div>
<h1>{loginId.title}</h1>
{LOGIN_COMPONENTS}
<div className="promo-banner">
{customText.promoBanner}
</div>
<footer>
{customText.customFooter}
</footer>
</div>
);
};
- Save and deploy the updated application code.