语言自定义-自定义策略-Azure B2C

时间:2018-10-22 14:09:02

标签: azure-ad-b2c

正在尝试配置语言自定义以使用自定义策略进行注册,但没有成功。任何指导表示赞赏和感谢。

 I made the following configuration to achieve language customization.
  1. 在信任框架扩展策略中,我通过以下XML更改启用了本地化。

        <SupportedLanguages DefaultLanguage="en" >
          <SupportedLanguage>en</SupportedLanguage>
          <SupportedLanguage>fr</SupportedLanguage>
          <SupportedLanguage>ta</SupportedLanguage>
        </SupportedLanguages>
    
  2. 为声明类型“ extension_CompanyName”创建的本地化资源。

      <LocalizedResources Id="api.idpselections.signup.fr">
          <LocalizedStrings>
    
            <LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="DisplayName"> Some French word</LocalizedString>
            <LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="UserHelpText">Some french text</LocalizedString>
          </LocalizedStrings>
        </LocalizedResources>
    
  3. 使用注册屏幕映射了第2步中创建的本地化资源。

     <ContentDefinition Id="api.idpselections.signup" >
          <LoadUri>~/tenant/default/idpSelector.cshtml</LoadUri>
          <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
          <DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.0.0</DataUri>
          <Metadata>
            <Item Key="DisplayName">Idp selection page</Item>
            <Item Key="language.intro">Sign up</Item>
          </Metadata>
            <LocalizedResourcesReferences MergeBehavior="Prepend">
            <LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="api.idpselections.signup.en" />
            <LocalizedResourcesReference Language="fr" LocalizedResourcesReferenceId="api.idpselections.signup.fr" />
          </LocalizedResourcesReferences>
     </ContentDefinition>
    

最后,在我的SPA应用程序中,当路由到注册策略时,我已经添加了新的查询参数'ui_locales ='fr'。但是,不幸的是,“ extension_CompanyName”未显示本地化文本。

纠正我哪里出错了。

1 个答案:

答案 0 :(得分:0)

重命名本地化的资源ID解决了我的问题。不确定它是如何工作的。

 <ContentDefinitions>
    <ContentDefinition Id="api.idpselections.signup" >
    <LoadUri>~/tenant/default/idpSelector.cshtml</LoadUri>
    <RecoveryUri>~/common/default_page_error.html</RecoveryUri>
    <DataUri>urn:com:microsoft:aad:b2c:elements:idpselection:1.0.0</DataUri>
    <Metadata>
      <Item Key="DisplayName">Idp selection page</Item>
      <Item Key="language.intro">Sign up</Item>
    </Metadata>
    <LocalizedResourcesReferences MergeBehavior="Prepend">
      <LocalizedResourcesReference Language="en" LocalizedResourcesReferenceId="en" />
      <LocalizedResourcesReference Language="fr" LocalizedResourcesReferenceId="fr" />
    </LocalizedResourcesReferences>
  </ContentDefinition>

  <LocalizedResources Id="fr">
          <LocalizedStrings>
          <LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="DisplayName">Nom de la compagnie</LocalizedString>
          <LocalizedString ElementType="ClaimType" ElementId="extension_CompanyName" StringId="UserHelpText">Nom de la compagnie</LocalizedString>
          <LocalizedString ElementType="ClaimsProvider" StringId="SignUpWithLogonEmailExchange">Local Account Sign-Up</LocalizedString>
          </LocalizedStrings>
  </LocalizedResources>