如何解决在Custom Police Azure ADB2C中本地化API响应
我已经在Azure ADB2C自定义策略中实现了本地化。
<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>
一切正常,但是单击登录按钮时,将进行API调用,并且响应始终为英语。同样,用于指示语言未在API调用中发送的查询字符串参数。任何帮助将不胜感激。
解决方法
您需要首先找到显示此错误的字符串ID。
我们支持these用于本地化的ID,您可能已在策略中对其进行了自定义。
然后,一旦知道错误消息使用了哪个ID,就可以添加如下所示的LocalizedString
元素(例如,假设ElementType
为ErrorMessage
, StringID
是DefaultMessage
):
<LocalizedString ElementType="ErrorMessage" StringId="DefaultMessage">#Invalid username or password.</LocalizedString>
您可以在此处找到相同的不同示例:https://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-localization
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。