B2C:对源自 REST 的消息进行本地化 API

B2C: Localization for messages originating from REST API

我目前正在实施 this example 以在用户注册期间使用休息 API。

基本思路是API抛出409冲突错误中断注册

// Can I return a special "StringId" or something here for localization?
return new ConflictObjectResult(new B2CResponseModel($"A verification email sent to you. Please open your mail box and click on the link. If you didn't receive the email, please click on the 'Send verification email' button.", HttpStatusCode.Conflict));

我想向用户显示一条本地化为他们当前语言的消息。我更愿意在自定义策略中进行本地化,但我也接受 API 中的解决方案(需要为此获取用户语言)。

有没有办法进行本地化?喜欢通过 API 返回 StringId 并在策略中使用它吗?

我也在考虑不从 API 返回错误以显示 message in a new screen instead (like )。然而,这方面的本地化选项也让我望而却步。

希望这类似于

查看 Jas Suri 的回答。将本地化参数传递给 API 和 return 本地化消息,或者可以 return 错误代码并基于该显示使用策略本身的翻译消息。

万一有人正在寻找一种方法将用户的语言环境发送到 REST API:

https://docs.microsoft.com/nb-no/azure/active-directory-b2c/claim-resolver-overview

        <TechnicalProfile Id="REST-API-SendVerificationEmail">
          <DisplayName>Sign-Up send link</DisplayName>
          <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.RestfulProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
          <Metadata>
            <Item Key="ServiceUrl">https://xxxx</Item>
            <Item Key="AuthenticationType">None</Item>
            <Item Key="SendClaimsIn">Body</Item>
          </Metadata>
          <InputClaims>
            <InputClaim ClaimTypeReferenceId="email" />
            <InputClaim ClaimTypeReferenceId="userLanguage" DefaultValue="{Culture:LanguageName}" />
            <InputClaim ClaimTypeReferenceId="policyId" PartnerClaimType="policy" DefaultValue="{Policy:PolicyId}" />
            <InputClaim ClaimTypeReferenceId="scope" DefaultValue="{OIDC:scope}" />
            <InputClaim ClaimTypeReferenceId="clientId" DefaultValue="{OIDC:ClientId}" />
          </InputClaims>
          <UseTechnicalProfileForSessionManagement ReferenceId="SM-Noop" />
        </TechnicalProfile>