azure-ad-b2c custom policy how to localize Error messages - azure

Hello iam looking for solution to localize error message to below message but seems it is not overriding
1. Added localization to below content definition tried MergeBehavior="Prepend",MergeBehavior="Append" and MergeBehavior="ReplaceAll"
<ContentDefinition Id="api.signuporsignin">
<LoadUri>~/tenant/templates/AzureBlue/unified.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:unifiedssp:1.2.0</DataUri>
<Metadata>
<Item Key="DisplayName">Signin and Signup</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.signuporsignin.en" />
</LocalizedResourcesReferences>
</ContentDefinition>
2.Overriding localization using resources api.signuporsignin.en
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
<SupportedLanguage>en</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.signuporsignin.en">
<LocalizedStrings>
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfInvalidPassword">We didn't recognize this username and password combination.</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
Can anyone suggest me any way to localize error messages in azure b2c custom policy(signupsignin)

Related

Azure B2C custom policy - api.localaccountsignup - only some fields are automatically translated

I have used the B2C starterpack as the basis of my new policy.
Almost everything works after some epic battles but the translation seems to be somehow only partially done.
I dont believe that Microsoft really left out just those couple of strings so there must be some error on my side..
I have also tried to do the translation by hand - but i cannot find the Ids to translate for
Email Address
New Password
Confirm New Password
These strings are not mentioned at all in
https://learn.microsoft.com/en-us/azure/active-directory-b2c/localization-string-ids
How is it possible that the buttons for Continue and Cancel are translated, but those fields are not ?
After all this comes directly from B2C in the <div id='api'> tag, so its kind of strange that i need to do the translations manually for those base fields.
<ClaimsProvider>
<DisplayName>Local Account</DisplayName>
<TechnicalProfiles>
<TechnicalProfile Id="LocalAccountSignUpWithLogonEmail">
<DisplayName>Email signup</DisplayName>
<Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
<Metadata>
<Item Key="IpAddressClaimReferenceId">IpAddress</Item>
<Item Key="ContentDefinitionReferenceId">api.localaccountsignup</Item>
<!-- <Item Key="language.button_continue">Create</Item> Had to disable this to get the translation -->
</Metadata>
<ContentDefinition Id="api.localaccountsignup">
<LoadUri>https://my_blob_on.core.windows.net/b2c/custom-ui.html</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:1.2.0</DataUri>
<!-- <DataUri>urn:com:microsoft:aad:b2c:elements:selfasserted:1.1.0</DataUri> - No Changes with this -->
<Metadata>
<Item Key="DisplayName">Local account sign up page</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en"
LocalizedResourcesReferenceId="api.localaccountsignup.en" />
<LocalizedResourcesReference Language="de"
LocalizedResourcesReferenceId="api.localaccountsignup.de" />
</LocalizedResourcesReferences></ContentDefinition>
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="Prepend">
<SupportedLanguage>en</SupportedLanguage>
<SupportedLanguage>de</SupportedLanguage>
<SupportedLanguage>it</SupportedLanguage>
</SupportedLanguages>
<!-- adding my DIY translations as B2C doesnt provide them ?! -->
<LocalizedResources Id="api.localaccountsignup.en">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="givenName" StringId="DisplayName">Given Name</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="surname" StringId="DisplayName">Surname</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
<LocalizedResources Id="api.localaccountsignup.de">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="givenName" StringId="DisplayName">Vorname</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="surname" StringId="DisplayName">Nachname</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>
Not sure if the are supposed to be built in, but we have them set up ourselves as well.
This is how you can set you remaining values:
<LocalizedString ElementType="ClaimType"
ElementId="email"
StringId="DisplayName">E-Mail-Adresse</LocalizedString>
<LocalizedString ElementType="ClaimType"
ElementId="newPassword"
StringId="DisplayName">Neues Kennwort</LocalizedString>
<LocalizedString ElementType="ClaimType"
ElementId="reenterPassword"
StringId="DisplayName">Kennwort wiederholen</LocalizedString>
You probably don't need these, but just in case:
<LocalizedString ElementType="UxElement" StringId="button_continue">Weiter</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="button_cancel">Abbrechen</LocalizedString>
As a guideline, you can also look for those claims in the TrustFrameworkBase file and by inspecting the fields in your browser using the developer tools. I find this helps me most of the time to find the correct values.
Starting from the Content Definitions 2.0.0, B2C doesn't automatically translate your claims. https://learn.microsoft.com/en-us/azure/active-directory-b2c/page-layout#self-asserted-page-selfasserted
If you want to automatically translate your claims you need to manually translate them using some
<BuildingBlocks>
<ContentDefinitions>
<ContentDefinition Id="api.localaccountpasswordreset">
<LocalizedResourcesReferences MergeBehavior="ReplaceAll">
<LocalizedResourcesReference Language="bg" LocalizedResourcesReferenceId="api.localaccountpasswordreset.bg" />
...
</ContentDefinition>
</ContentDefinitions>
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
<SupportedLanguage>bg</SupportedLanguage>
...
</SupportedLanguages>
<LocalizedResources Id="api.localaccountpasswordreset.bg">
<LocalizedCollections />
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="DisplayName">BG: Text</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="UserHelpText">BG: Text</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="signInName" StringId="PatternHelpText">BG: Text</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
...
</Localization>
</BuildingBlocks>
</TrustFrameworkPolicy>
Here you can see the same policy with the parameter &ui_locales=bg first using a content definition 1.0.0 (left) and then using a content definition 2.1.4 (right)

Custom policy showing error labels on page load

I saw a question similar here. I'm facing the same issue with my policy too.
<ContentDefinition Id="api.localaccountsignup">
<LoadUri>https://mysite.azurewebsites.net/b2c/signup</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:selfasserted:1.1.0</DataUri>
<Metadata>
<Item Key="DisplayName">Local account sign up page</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="signup_en" />
</LocalizedResourcesReferences>
</ContentDefinition>
Validation errors are showing on the page load itself. As the solution of the question says hide that using CSS, but is there any other solution to fix this from B2C without using style.?

Customising the message/error text in Azure AD B2C custom policies

I want to Customizing the message/error text in Azure AD B2C custom policie,Not getting a proper way to do this.has anyone done this in their B2C custom Policies
I want to customize the Verification is necessary. Please click Send button. test which is under "ver_intro_msg" id ,
I added following to Building Block.
Let me know where it goes wrong
<ContentDefinition Id="api.localaccountsignup">
<Metadata>
<Item Key="DisplayName">Local account sign up page</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.localaccountsignup.en" />
</LocalizedResourcesReferences>
</ContentDefinition>
</ContentDefinitions>
<Localization Enabled="true">
<SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
<SupportedLanguage>en</SupportedLanguage>
</SupportedLanguages>
<LocalizedResources Id="api.localaccountsignup.en">
<LocalizedStrings>
<LocalizedString ElementType="UxElement" StringId="ver_intro_msg">Wellcome to Buckman Compliance Portal</LocalizedString>
<LocalizedString ElementType="UxElement" StringId="ver_info_msg">Cheak Your Regisered Mail For OTP</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
</Localization>

Language customizatio- Custom Policy - Azure B2C

Am trying to configure language customization for sign up using custom policies, but with no success. Any guidance appreciated and thanks in advance.
I made the following configuration to achieve language customization.
In trust framework extension policy, I have enabled localization with following XML changes.
<SupportedLanguages DefaultLanguage="en" >
<SupportedLanguage>en</SupportedLanguage>
<SupportedLanguage>fr</SupportedLanguage>
<SupportedLanguage>ta</SupportedLanguage>
</SupportedLanguages>
Created Localization resource for claim type 'extension_CompanyName'.
<LocalizedResources Id="api.idpselections.signup.fr">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="DisplayName"> Some French word</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="UserHelpText">Some french text</LocalizedString>
</LocalizedStrings>
</LocalizedResources>
Mapped the localized resource created in step 2 with sign up screen.
<ContentDefinition Id="api.idpselections.signup" >
<LoadUri>~/tenant/default/idpSelector.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.0.0</DataUri>
<Metadata>
<Item Key="DisplayName">Idp selection page</Item>
<Item Key="language.intro">Sign up</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.idpselections.signup.en" />
<LocalizedResourcesReference Language="fr" LocalizedResourcesReferenceId="api.idpselections.signup.fr" />
</LocalizedResourcesReferences>
</ContentDefinition>
Finally, in my SPA app while routing to sign up policy I have appened the new query parameter 'ui_locales = 'fr'. But, unfortunately, 'extension_CompanyName' is not showing localized text.
Correct me where I went wrong.
Renaming localized resources id fixed my problem. Not sure how it worked.
<ContentDefinitions>
<ContentDefinition Id="api.idpselections.signup" >
<LoadUri>~/tenant/default/idpSelector.cshtml</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.0.0</DataUri>
<Metadata>
<Item Key="DisplayName">Idp selection page</Item>
<Item Key="language.intro">Sign up</Item>
</Metadata>
<LocalizedResourcesReferences MergeBehavior="Prepend">
<LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="en" />
<LocalizedResourcesReference Language="fr" LocalizedResourcesReferenceId="fr" />
</LocalizedResourcesReferences>
</ContentDefinition>
<LocalizedResources Id="fr">
<LocalizedStrings>
<LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="DisplayName">Nom de la compagnie</LocalizedString>
<LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="UserHelpText">Nom de la compagnie</LocalizedString>
<LocalizedString ElementType="ClaimsProvider" StringId="SignUpWithLogonEmailExchange">Local Account Sign-Up</LocalizedString>
</LocalizedStrings>
</LocalizedResources>

Override ContentDefinition at RelyingParty Azure AD B2C Custom Policy

Can I override the <ContentDefinition><LoadUri> in a RP policy?
RP Policy.xml
<BasePolicy>
<TenantId>mytenant.onmicrosoft.com</TenantId>
<PolicyId>B2C_1A_TFExts</PolicyId>
</BasePolicy>
<BuildingBlocks>
<ContentDefinitions>
<ContentDefinition Id="api.idpselections-ext-local">
<LoadUri>~/tenant/default/idpSelector.cshtml</LoadUri>
</ContentDefinition>
</ContentDefinitions>
</BuildingBlocks>
TFExts.xml
<BuildingBlocks>
<ContentDefinitions>
<ContentDefinition Id="api.idpselections-ext-local">
<LoadUri>https://localhost:44377/</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.0.0</DataUri>
<Metadata>
<Item Key="DisplayName">Idp selection page</Item>
<Item Key="language.intro">Sign in</Item>
</Metadata>
</ContentDefinition>
</ContentDefinitions>
</BuildingBlocks>
I was overwriting the wrong ContentDefinition Id. So yes, I can override a <ContentDefinition><LoadUri> in a relying party policy.
<BuildingBlocks>
<ContentDefinitions>
<ContentDefinition Id="api.selfasserted-ext-local">
<LoadUri>https://localhost:44377/</LoadUri>
</ContentDefinition>
</ContentDefinitions>
</BuildingBlocks>

Resources