0

I have custom claims in my sign-up page register_header and password_header and I want to localize them to Japanese.

Here is my custom policy:

Claims

<ClaimType Id="register_heading">
    <DataType>string</DataType>
    <AdminHelpText>A claim responsible for holding response messages to send to the relying party</AdminHelpText>
    <UserHelpText>A claim responsible for holding response messages to send to the relying party</UserHelpText>
    <UserInputType>Paragraph</UserInputType>
</ClaimType>
<ClaimType Id="password_header">
    <DataType>string</DataType>
    <AdminHelpText>A claim responsible for holding response messages to send to the relying party</AdminHelpText>
    <UserHelpText>A claim responsible for holding response messages to send to the relying party</UserHelpText>
    <UserInputType>Paragraph</UserInputType>
</ClaimType>

Technical Profile

<TechnicalProfile Id="LocalAccountSignUpWithreadOnlyEmail">
<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">Continue</Item>
    <Item Key="setting.showCancelButton">false</Item>
    <!-- Sample: Remove sign-up email verification -->
    <Item Key="EnforceEmailVerification">False</Item>
</Metadata>
<InputClaims>
    <InputClaim ClaimTypeReferenceId="email" />
    <InputClaim ClaimTypeReferenceId="readOnlyEmail" />
    <InputClaim ClaimTypeReferenceId="givenName" />
    <InputClaim ClaimTypeReferenceId="surName" />

    <!-- claims needed for localization -->
    <InputClaim ClaimTypeReferenceId="register_header" DefaultValue="Register account" />
    <InputClaim ClaimTypeReferenceId="password_header" DefaultValue="Register password" />
</InputClaims>
<OutputClaims>
    <OutputClaim ClaimTypeReferenceId="objectId" />
    <!-- Sample: Display the readOnlyEmail claim type (instead of email claim type)-->
    <OutputClaim ClaimTypeReferenceId="readOnlyEmail" Required="true" />
    <OutputClaim ClaimTypeReferenceId="newPassword" Required="true" />
    <OutputClaim ClaimTypeReferenceId="reenterPassword" Required="true" />
    <OutputClaim ClaimTypeReferenceId="executed-SelfAsserted-Input" DefaultValue="true" />
    <OutputClaim ClaimTypeReferenceId="authenticationSource" />
    <OutputClaim ClaimTypeReferenceId="newUser" />
    <!-- Optional claims, to be collected from the user -->
    <OutputClaim ClaimTypeReferenceId="givenName" Required="true" />
    <OutputClaim ClaimTypeReferenceId="surName" Required="true" />
    <OutputClaim ClaimTypeReferenceId="TnC" Required="true" />
    <!-- claims for localization -->
    <OutputClaim ClaimTypeReferenceId="register_header" />
    <OutputClaim ClaimTypeReferenceId="password_header" />
</OutputClaims>
<ValidationTechnicalProfiles>
    <ValidationTechnicalProfile ReferenceId="AAD-UserWriteUsingLogonEmail" />
</ValidationTechnicalProfiles>
<!-- Sample: Disable session management for sign-up page -->
<UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />

Content Definition

<ContentDefinition Id="api.localaccountsignup">
<LoadUri>Insert URL here</LoadUri>
<RecoveryUri>~/common/default_page_error.html</RecoveryUri>
<DataUri>urn:com:microsoft:aad:b2c:elements:contract:selfasserted:1.2.0</DataUri>
<LocalizedResourcesReferences MergeBehavior="ReplaceAll">
    <LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.localaccountsignup.en" />
    <LocalizedResourcesReference Language="ja" LocalizedResourcesReferenceId="api.localaccountsignup.ja" />
</LocalizedResourcesReferences>

Localized Resources

<LocalizedResources Id="api.localaccountsignup.ja">
<LocalizedStrings>
    <LocalizedString ElementType="ClaimType" ElementId="register_header" StringId="DisplayName">アカウントを登録</LocalizedString>
    <LocalizedString ElementType="ClaimType" ElementId="password_header" StringId="DisplayName">パスワードを登録</LocalizedString>
</LocalizedStrings>

My problem is the Japanese translation are returned as <label> in the HTML. enter image description here enter image description here

But their English counterpart is returned as <p> with the id attribute enter image description here enter image description here

I want to use the id but it is only available to the English translation. Is there a way for the custom policy to change the text in <p> to Japanese and keep the id instead of creating a <label> element? If possible I don't want to use Javascript.

waanderer
  • 157
  • 1
  • 1
  • 11

1 Answers1

0

• I would suggest you to please try configuring the localization string ids in the custom policy regarding the two custom claims that you want to be translated in Japanese. Since you have already done the same as posted in your localization strings claims, I would suggest you to please modify your custom policy to also include the details below in it: -

       <Localization Enabled="true">
        <SupportedLanguages DefaultLanguage="en" MergeBehavior="ReplaceAll">
            <SupportedLanguage>en</SupportedLanguage>
            <SupportedLanguage>jp</SupportedLanguage>
        </SupportedLanguages>
        <LocalizedResources Id="api.localaccountsignup.en">
            <LocalizedCollections>
                <LocalizedCollection ElementType="ClaimType" ElementId="register_header" TargetCollection="Restriction">
                    <Item Text="StringId" Value="DisplayName" />
                </LocalizedCollection>
         <LocalizedCollection ElementType="ClaimType" ElementId="password_header" TargetCollection="Restriction">
    <Item Text=”StringId” Value=”DisplayName”>
    </LocalizedCollection>
            </LocalizedCollections>
        </LocalizedResources>
        <LocalizedResources Id="api.localaccountsignup.jp">
            <LocalizedCollections>
                <LocalizedCollection ElementType="ClaimType" ElementId="<register_header in japanese" TargetCollection="Restriction">
                    <Item Text="StringId" Value="DisplayName" />
                </LocalizedCollection>
         <LocalizedCollection ElementType="ClaimType" ElementId="password_header in japanese" TargetCollection="Restriction">
    <Item Text=”StringId” Value=”DisplayName”>
    </LocalizedCollection>
            </LocalizedCollections>
        </LocalizedResources>
    </Localization>

Might be when you edit your custom policy to include the display results as above, then you might be able to resolve the issue as desired. Also, do refer to the link below for more details about editing the custom policy as above.

Localised message for RestAPI error response in B2C custom policy

Kartik Bhiwapurkar
  • 4,550
  • 2
  • 4
  • 9