B2C自定义策略本地化:必填元素缺失等问题技术问询
解决Azure AD B2C自定义策略德语本地化的两个问题
问题1:缺失必填项错误的占位符{0}未填充
解决方案:
- 先确保目标ClaimType的DisplayName已完成德语本地化,以验证码为例:
<!-- 基础策略中的ClaimType定义 --> <ClaimType Id="verificationCode"> <DisplayName>Verification code</DisplayName> <DataType>string</DataType> <UserInputType>TextBox</UserInputType> </ClaimType> <!-- 德语本地化文件中的对应配置 --> <LocalizedString ElementType="ClaimType" ElementId="verificationCode" StringId="DisplayName">Bestätigungscode</LocalizedString> - 检查本地化资源与内容定义的关联是否正确,确保用户旅程使用的
api.selfasserted内容定义引用了德语本地化文件:<ContentDefinition Id="api.selfasserted"> <LocalizedResourcesReferences MergeBehavior="Prepend"> <LocalizedResourcesReference Id="api.selfasserted.de" /> </LocalizedResourcesReferences> </ContentDefinition> - 如果占位符仍不生效,直接为该ClaimType设置专属的缺失错误消息,绕过占位符:
<LocalizedString ElementType="ErrorMessage" StringId="UserMessageIfClaimMissing_verificationCode">Fehlendes erforderliches Element: Bestätigungscode</LocalizedString>
问题2:required_field_descriptive占位符显示字段类型而非DisplayName
解决方案:
selfasserted:2.1.19版本中required_field_descriptive的占位符默认绑定字段类型,要实现字段专属的必填提示,需为每个ClaimType单独配置本地化字符串:
- 针对邮箱和验证码字段,分别添加以下本地化配置:
<!-- 邮箱字段必填提示 --> <LocalizedString ElementType="UxElement" StringId="required_field_email">E-Mail-Adresse ist erforderlich.</LocalizedString> <!-- 验证码字段必填提示 --> <LocalizedString ElementType="UxElement" StringId="required_field_verificationCode">Verification code ist erforderlich.</LocalizedString> - 格式为
required_field_{ClaimType Id},替换{ClaimType Id}为你实际使用的ClaimType标识即可,这样每个字段会显示对应的自定义德语提示文本。
内容的提问来源于stack exchange,提问作者Jonasgj
相关产品推荐
相关产品推荐

