Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localization in Custom Policy Azure B2C

I have localized DisplayName and UserHelpText (like shown below). How to localize the email pattern HelpText ("The email you provided is not valid")? Please advise

<ClaimType Id="signInName">
    <DisplayName>Please enter your email</DisplayName>
    <DataType>string</DataType>
    <UserHelpText>Enter your email address to signin</UserHelpText>
    <Restriction>
        <Pattern RegularExpression="^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$" HelpText="The email you provided is not valid"/>
    </Restriction>
</ClaimType>

<Localization Enabled="true">
    <SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
        <SupportedLanguage>en</SupportedLanguage>
        <SupportedLanguage>es</SupportedLanguage>
    </SupportedLanguages>
    <LocalizedResources Id="en">
        <LocalizedStrings>
            <LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="DisplayName">Please enter your email</LocalizedString>
            <LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="UserHelpText">Enter your email address to signin</LocalizedString>
        </LocalizedStrings>
    </LocalizedResources>
    <LocalizedResources Id="es">
        <LocalizedStrings>
            <LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="DisplayName">Por favor introduzca su correo electrónico</LocalizedString>
            <LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="UserHelpText">Ingrese su dirección de correo electrónico para iniciar sesión</LocalizedString>
        </LocalizedStrings>
    </LocalizedResources>
</Localization>
like image 207
Baloon1985 Avatar asked Nov 25 '25 10:11

Baloon1985


1 Answers

For invalid email Id, you can use inbuilt invalid_email UXElement and add the below LocalizedString:

<LocalizedString ElementType="UxElement" StringId="invalid_email">#Please enter a valid email address</LocalizedString>

Reference docs:

  • https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-localization

  • https://medium.com/the-new-control-plane/customising-the-message-error-text-in-azure-ad-b2c-custom-policies-d1e1ff2640d3

like image 64
Harshita Singh Avatar answered Nov 28 '25 17:11

Harshita Singh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!