0

我已经在 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 调用中发送。任何帮助是极大的赞赏。

在此处输入图像描述

4

1 回答 1

1

您需要首先找到显示此错误的字符串 ID。

我们支持您在策略中自定义的这些ID 进行本地化。

然后,一旦您知道错误消息使用了哪个 ID,就可以添加LocalizedString如下元素(例如,我假设ElementTypeisErrorMessageStringIDis DefaultMessage):

<LocalizedString ElementType="ErrorMessage" StringId="DefaultMessage">#Invalid username or password.</LocalizedString>

您可以在此处找到相同的不同示例:https ://docs.microsoft.com/en-us/azure/active-directory-b2c/custom-policy-localization

于 2020-09-09T13:52:59.913 回答