Localization of 'UserMessageIfWrongCodeEntered' not working - azure-ad-b2c

I'm having problem locating the correct key for an error messages I want to localize to another language when using a custom policy.
The message is when the user has entered the wrong TOTP-code. The english text is "Wrong code entered, please try again.". From this page https://learn.microsoft.com/en-us/azure/active-directory-b2c/localization-string-ids it seems as I have to edit the errormessage with StringId UserMessageIfWrongCodeEntered, and I have done so in the localizedresource with Id api.selfasserted.totp.[lang] with no success.
I also tried to look for the error message in a user flow. I found the message with the same stringId, but after changing the string there as well, the error message was still displayed in english. Which made we wonder if there is some kind of bug with this particular message?
Have anyone managed to successfully localize this error message?
Tried doing this:
<LocalizedResources Id="api.selfasserted.totp.sv">
<LocalizedStrings>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorAppIconControl" StringId="title_text">Ladda ner Microsoft Authenticator med nedladdningslänkarna för iOS och Android eller använd en annan valfri autentiserings-app.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorAppIconControl" StringId="DN">Använd någon av metoderna nedan för att fortsätta efter att du har laddat ner autentiserings-appen.</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="QrCodeScanInstruction" StringId="DisplayName">Använd någon av metoderna nedan för att fortsätta efter att du har laddat ner autentiserings-appen.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="title_text">Scanna QR-koden</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="info_msg">Ladda ner Microsoft Authenticator eller använd en annan valfri autentiserings-app.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="link_text">Kan inte scanna? Klicka här</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="title_text">Skriv in uppgifterna manuellt</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="account_name">Kontonamn:</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="display_prefix">Secret</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="collapse_text">Har du fortfarande problem?</LocalizedString>
<!-- Verification -->
<LocalizedString ElementType="ClaimType" ElementId="QrCodeVerifyInstruction" StringId="DisplayName">Skriv in verifieringskoden från autentiserings-appen.</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="otpCode" StringId="DisplayName">Skriv in din kod.</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="button_continue">Verifiera</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfWrongCodeEntered">Koden är felaktig, försök igen.</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
All other strings other than UserMessageIfWrongCodeEntered works fine.

Related

Azure AD B2C Signup Page Customization

Currently Implementing a b2c signup flow via custom policies. Working on a usecase for b2c user registration page, when a user left the “required fields” as empty then the following error message is displayed as “This information is required” by default.
But how to customize to these mandatory field error message as “Name is required” or “Phone number is required” or “Telephone number is required”?
I haven’t found a right localization string ID to handle these mandatory field error message, Instead of a generic default error message. Any helpful suggestions?
I think you have to use localization to overwrite messages and texts.
<LocalizedResources Id="api.signuporsignin.en">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="email" StringId="DisplayName">Email Address</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="heading">Sign in</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="social_intro">Sign in with your social account</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="local_intro_generic">Sign in with your {0}</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="requiredField_password">Please enter your password</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="requiredField_generic">Please enter your {0}</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="invalid_generic">Please enter a valid {0}</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="createaccount_one_link">Sign up now</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="createaccount_two_links">Sign up with {0} or {1}</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="createaccount_three_links">Sign up with {0}, {1}, or {2}</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="forgotpassword_link">Forgot your password?</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="button_signin">Sign in</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="divider_title">OR</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="unknown_error">We are having trouble signing you in. Please try again later.</LocalizedString>
<!-- Uncomment the remember_me only if the keep me signed in is activated.
<LocalizedString ElementType="UxElement" StringId="remember_me">Keep me signed in</LocalizedString> -->
<LocalizedString ElementType="ClaimsProvider" StringId="FacebookExchange">Facebook</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfInvalidPassword">Your password is incorrect.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfPasswordExpired">Your password has expired.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfClaimsPrincipalDoesNotExist">We can't seem to find your account.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfOldPasswordUsed">Looks like you used an old password.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="DefaultMessage">Invalid username or password.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfUserAccountDisabled">Your account has been locked. Contact your support person to unlock it, then try again.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfUserAccountLocked">Your account is temporarily locked to prevent unauthorized use. Try again later.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="AADRequestsThrottled">There are too many requests at this moment. Please wait for some time and try again.</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
The specific string ID will vary depending on the claim. Use Customize Language guidance via XML policy to edit Localization element for the localized string.
See page layout version for your specific ID (if you require a version update).
I noticed in the example you posted, you had "UserMessageIfMissingRequiredElemnt" rather than "UserMessageIfMissingRequiredElement" (yours is missing that final "e"), this is perhaps why the localization didn't work

Remove text from B2C custom policy sign up flow

In the sign up page, when the existing user tries to sign up, it gives an error, this user already exists. But it shows the text, ''confirmed email address'' , how can we remove the text?
when you create custom policy you should be able to define this message in Localization part of the policy.
Example of this file is here:
https://github.com/Azure-Samples/active-directory-b2c-custom-policy-starterpack/blob/main/Display%20Controls%20Starterpack/LocalAccounts/TrustFrameworkLocalization.xml
<!-- Generic errors -->
<LocalizedString ElementType="ErrorMessage" StringId="ServiceThrottled">There are too many requests at this moment. Please wait for some time and try again.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfClaimNotVerified">Claim not verified: {0}</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfClaimsPrincipalAlreadyExists">A user with the specified ID already exists. Please choose a different one.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfIncorrectPattern">Incorrect pattern for: {0}</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfInvalidInput">{0} has invalid input.</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfMissingRequiredElement">Missing required element: {0}</LocalizedString>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfValidationError">Error in validation by: {0}</LocalizedString>

Localization of TOTP MFA controls

I've implemented TOTP based MFA as described in the documentation (https://learn.microsoft.com/en-us/azure/active-directory-b2c/display-control-time-based-one-time-password) and samples (https://github.com/azure-ad-b2c/samples/tree/master/policies/totp).
Now I would like to translate texts displayed during MFA enrollment and verification. However, I couldn't find anything in documentation regarding StringIds which can be overridden using B2C localization mechanism.
There is a similar question on GitHub - https://github.com/azure-ad-b2c/samples/issues/378, without response since 10 days.
I would like to translate following screens:
If you want to translate the screens as shown above, you can do the following:
In your TrustFrameworkBase.xml, under the node ContentDefinitions, add the following
<ContentDefinition Id="api.selfasserted.totp">
<LoadUri>~/tenant/templates/AzureBlue/selfAsserted.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:2.1.9</DataUri>
<Metadata>
<Item Key="DisplayName">Collect information from user page</Item>
</Metadata>
</ContentDefinition>
In your TrustFrameworkLocalization.xml ContentDefinitions node add
<ContentDefinition Id="api.selfasserted.totp">
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.selfasserted.totp.en" />
<LocalizedResourcesReference Language="af" LocalizedResourcesReferenceId="api.selfasserted.totp.af" />
<!-- Add more languages here -->
</LocalizedResourcesReferences>
</ContentDefinition>
Finally, also in the localization xml, you can add the following translations (Change the .af to your language preference of course)
<!-- Edit profile page English-->
<LocalizedResources Id="api.selfasserted.totp.en">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="totpQrCodeControl" StringId="DisplayName">You can download the Microsoft Authenticator app or use any other authenticator app of your choice.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="title_text">Scan the QR code</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="info_msg">Using your app scan this QR code and click "Continue"</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="link_text">Can't scan? Try this</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="otpCode" StringId="UserHelpText">Enter the 6-digit verification code generated by the the Authenticator app in the box.</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="otpCode" StringId="DisplayName">Enter your code</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="QrCodeVerifyInstruction" StringId="DisplayName">Enter the verification code from your authenticator app​.</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="QrCodeScanInstruction" StringId="DisplayName">Once you've downloaded the Authenticator app, you can use any of the methods below to continue with enrollment.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorAppIconControl" StringId="title_text">Download the Microsoft Authenticator using the download links for iOS and Android or use any other authenticator app of your choice.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="title_text">Enter the account details manually</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="account_name">Account Name:</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="display_prefix">Secret</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="collapse_text">Still having trouble?</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="button_continue">Continue</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="button_cancel">Cancel</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
<LocalizedResources Id="api.selfasserted.totp.af">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="totpQrCodeControl" StringId="DisplayName">Jy kan die Microsoft Authenticator-toepassing aflaai of enige ander Authenticator-toepassing van jou keuse gebruik.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="title_text">Skandeer die QR-kode</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="link_text">Kan jy nie skandeer nie? Probeer hierdie</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="totpQrCodeControl" StringId="info_msg">Deur jou toepassing te gebruik, skandeer hierdie QR-kode en klik "Gaan voort"</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="otpCode" StringId="UserHelpText">Voer die 6-syfer-verifikasiekode in wat deur die die Authenticator-toepassing gegenereer is in die blokkie.</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="otpCode" StringId="DisplayName">Sleutel in jou kode</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="QrCodeVerifyInstruction" StringId="DisplayName">Voer die verifikasiekode vanaf jou verifikasie-toepassing in.</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="QrCodeScanInstruction" StringId="DisplayName">Sodra jy die Authenticator-toepassing afgelaai het, kan jy enige van die metodes hieronder gebruik om voort te gaan met inskrywing.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorAppIconControl" StringId="title_text">Laai die Microsoft Authenticator af deur die aflaaiskakels vir iOS en Android te gebruik of gebruik enige ander Authenticator-toepassing van jou keuse.</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="title_text">Voer die rekeningbesonderhede handmatig in</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="account_name">Rekeningnaam:</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="display_prefix">Geheim</LocalizedString>
<LocalizedString ElementType="DisplayControl" ElementId="authenticatorInfoControl" StringId="collapse_text">Het u steeds probleme?</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="button_continue">Gaan voort</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="button_cancel">Kanselleer</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
This should give you the following output then
NOTE Some of the error message you will have to test and also figure out how to translate, the codes for these can be found here, but I did find one or 2 that does not work as I expect, and still trying to get it all to translate proper. Wish there was better documentation on this

Localizing the API response in Custom Police Azure ADB2C

I have implemented localization in Azure ADB2C custom policy.
<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-.]+$"/>
</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>
Everything is working as expected but when the login button is clicked, an API call is made and the response is always in English. Also the query string parameter to indicate the language is not sent in the API call. Any help is greatly appreciated.
You need to first find what is the string ID which is showing this error.
We support these IDs for localization which you might have customized in your policies.
Then, once you know which ID is being used for your error message, you can add a LocalizedString element like below (For example, I am assuming the ElementType is ErrorMessage and StringID is DefaultMessage):
<LocalizedString ElementType="ErrorMessage" StringId="DefaultMessage">#Invalid username or password.</LocalizedString>
You can find out different examples of the same here: https://learn.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-localization

Cant customize the Verification code message

I’m helping a partner to customize their B2C policy to show a custom message for e-mail verification code. We tried to customize the following parameter on the TrustFrameworkExtension (Attached) but it had no effect:
<LocalizedString ElementType="UxElement"
StringId="ver_info_msg">Verification code has been sent to your inbox.
Please copy it to the input box below.</LocalizedString>\\
What we need to change is the display message for verification code, as shown on the image below:
Could anyone provide some guidance? I tried it different ways and I don´t know If we´re doing something wrong or if it´s a default message that can´t be customized. It´s impacting the partner go-live.
thanks for guidance! the message we were trying to customize has a different StringID. The correct StringID is verification_control_code_sent
Once we fixed it we resolved the issue:
<!--Local account sign-up page Portuguese-->
<LocalizedResources Id="api.localaccountsignup.pt">
<LocalizedStrings>
<LocalizedString ElementType="UxElement" StringId="verification_control_code_sent">Um código de segurança foi enviado para seu e-mail. Mantenha esta janela aberta.</LocalizedString>
The document shows:
The following are the IDs for a content definition with an ID of
api.localaccountsignup or any content definition that starts with
api.selfasserted, such as api.selfasserted.profileupdate and
api.localaccountpasswordreset.
So you need to make the change in the appropriate “api.xxx” action.
The sample extends Id api.localaccountsignup to api.localaccountsignup.en. And change the value of LocalizedString.
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
<SupportedLanguage>en</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.localaccountsignup.en">
<LocalizedStrings>
<LocalizedString ElementType="UxElement" StringId="ver_fail_no_retry">Attempt limit exceeded - please check your email for the correct code</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
Then you need to change value of ver_info_msg in JSON defaults for built-in policies. For more details, see here.
Navigate to Azure AD B2C -> User flows -> Languages(make sure Enable language customization) -> Configured

Resources