Azure Active Directory B2C 中的语言自定义Language customization in Azure Active Directory B2C

用户流可以使用 Azure Active Directory B2C (Azure AD B2C) 中的语言自定义来适应不同的语言,从而满足客户需求。Language customization in Azure Active Directory B2C (Azure AD B2C) allows your user flow to accommodate different languages to suit your customer needs. Microsoft 提供 36 种语言的翻译,但你也可以为任何语言提供自己的翻译。Microsoft provides the translations for 36 languages, but you can also provide your own translations for any language. 即使体验是针对一种语言提供的,也可以自定义页面上的任何文本。Even if your experience is provided for only a single language, you can customize any text on the pages.

语言自定义的工作原理How language customization works

通过语言自定义可选择用户流可用于的语言。You use language customization to select which languages your user flow is available in. 启用该功能后,可以从应用程序提供查询字符串参数 ui_localesAfter the feature is enabled, you can provide the query string parameter, ui_locales, from your application. 调用 Azure AD B2C 时,我们会根据指定的区域设置翻译页面。When you call into Azure AD B2C, your page is translated to the locale that you have indicated. 使用此配置类型可以完全控制用户流中的语言,并忽略客户浏览器的语言设置。This type of configuration gives you complete control over the languages in your user flow and ignores the language settings of the customer's browser.

可能不需要对客户看到的语言拥有这种控制度。You might not need that level of control over what languages your customer sees. 如果未提供 ui_locales 参数,客户的体验由其浏览器设置确定。If you don't provide a ui_locales parameter, the customer's experience is dictated by their browser's settings. 仍可以控制要将用户流翻译成哪种语言,只需将该语言添加为支持的语言即可。You can still control which languages your user flow is translated to by adding it as a supported language. 如果客户浏览器设置为显示你不希望支持的语言,则将改为显示你在受支持区域性中选为默认的语言。If a customer's browser is set to show a language that you don't want to support, then the language that you selected as a default in supported cultures is shown instead.

  • ui-locales 指定的语言:启用语言自定义后,用户流将翻译成此处指定的语言。ui-locales specified language: After you enable language customization, your user flow is translated to the language that's specified here.
  • 浏览器请求的语言:如果未指定 ui_locales 参数,用户流将翻译成浏览器请求的语言(如果该语言受支持)。Browser-requested language: If no ui_locales parameter was specified, your user flow is translated to the browser-requested language, if the language is supported.
  • 策略默认语言:如果浏览器未指定语言,或者指定了不支持的语言,用户流将翻译成用户流默认语言。Policy default language: If the browser doesn't specify a language, or it specifies one that is not supported, the user flow is translated to the user flow default language.

备注

如果使用自定义用户属性,需要提供自己的翻译。If you're using custom user attributes, you need to provide your own translations. 有关详细信息,请参阅自定义字符串For more information, see Customize your strings.

支持 ui_locales 请求的语言Support requested languages for ui_locales

在语言自定义正式版发布之前创建的策略将需要先启用此功能。Policies that were created before the general availability of language customization need to enable this feature first. 之后创建的策略和用户流默认情况下已启用语言自定义。Policies and user flows that were created after have language customization enabled by default.

在用户流中启用语言自定义后,可以通过添加 ui_locales 参数来控制用户流的语言。When you enable language customization on a user flow, you can control the language of the user flow by adding the ui_locales parameter.

  1. 在 Azure AD B2C 租户中,选择“用户流” 。In your Azure AD B2C tenant, select User flows.
  2. 单击想要启用翻译的用户流。Click the user flow that you want to enable for translations.
  3. 选择“语言” 。Select Languages.
  4. 选择“启用语言自定义”。 Select Enable language customization.

选择要在用户流中启用的语言Select which languages in your user flow are enabled

为用户流启用一组语言,以便在无 ui_locales 参数的浏览器提出请求时翻译成这些语言。Enable a set of languages for your user flow to be translated to when requested by the browser without the ui_locales parameter.

  1. 确保已根据前面的说明为用户流启用语言自定义。Ensure that your user flow has language customization enabled from previous instructions.
  2. 在用户流的“语言”页面,选择想要支持的语言 。On the Languages page for the user flow, select a language that you want to support.
  3. 在属性窗格中,将“已启用”更改为“是”。 In the properties pane, change Enabled to Yes.
  4. 选择属性窗格顶部的“保存” 。Select Save at the top of the properties pane.

备注

如果未提供 ui_locales 参数,则仅当客户的浏览器语言已启用时,才将页面翻译成此语言If a ui_locales parameter is not provided, the page is translated to the customer's browser language only if it is enabled.

自定义字符串Customize your strings

使用语言自定义可以自定义用户流中的任何字符串。Language customization enables you to customize any string in your user flow.

  1. 确保已根据前面的说明为用户流启用语言自定义。Ensure that your user flow has language customization enabled from the previous instructions.
  2. 在用户流的“语言”页面,选择想要自定义的语言 。On the Languages page for the user flow, select the language that you want to customize.
  3. 在“页面级别资源文件”下,选择想要编辑的页面 。Under Page-level-resources files, select the page that you want to edit.
  4. 选择“下载默认值”(如果以前已编辑这种语言,则选择“下载重写”)。 Select Download defaults (or Download overrides if you have previously edited this language).

执行这些步骤可以创建用于开始编辑字符串的 JSON 文件。These steps give you a JSON file that you can use to start editing your strings.

更改页面上的任何字符串Change any string on the page

  1. 在 JSON 编辑器中打开根据前面的说明下载的 JSON 文件。Open the JSON file downloaded from previous instructions in a JSON editor.
  2. 找到想要更改的元素。Find the element that you want to change. 可以查找所需字符串的 StringId,或者查找想要更改的 Value 属性。You can find StringId for the string you're looking for, or look for the Value attribute that you want to change.
  3. 使用想要显示的内容更新 Value 属性。Update the Value attribute with what you want displayed.
  4. 对于每个要更改的字符串,将 Override 更改为 trueFor every string that you want to change, change Override to true.
  5. 保存文件并上传更改。Save the file and upload your changes. (可在下载 JSON 文件的同一位置找到上传控件。)(You can find the upload control in the same place as where you downloaded the JSON file.)

重要

如果需要重写字符串,请确保将 Override 值设置为 trueIf you need to override a string, make sure to set the Override value to true. 如果未更改该值,将忽略该条目。If the value isn't changed, the entry is ignored.

更改扩展属性Change extension attributes

若要更改自定义用户属性的字符串或者想要在 JSON 中添加一个字符串,该字符串需采用以下格式:If you want to change the string for a custom user attribute, or you want to add one to the JSON, it's in the following format:

{
  "LocalizedStrings": [
    {
      "ElementType": "ClaimType",
      "ElementId": "extension_<ExtensionAttribute>",
      "StringId": "DisplayName",
      "Override": true,
      "Value": "<ExtensionAttributeValue>"
    }
    [...]
}

<ExtensionAttribute> 替换为自定义用户属性的名称。Replace <ExtensionAttribute> with the name of your custom user attribute.

<ExtensionAttributeValue> 替换为要显示的新字符串。Replace <ExtensionAttributeValue> with the new string to be displayed.

使用 LocalizedCollections 提供值列表Provide a list of values by using LocalizedCollections

若要为响应提供一组值列表,需要创建 LocalizedCollections 属性。If you want to provide a set list of values for responses, you need to create a LocalizedCollections attribute. LocalizedCollectionsNameValue 对的数组。LocalizedCollections is an array of Name and Value pairs. 项目的顺序将是它们显示的顺序。The order for the items will be the order they are displayed. 若要添加 LocalizedCollections,请使用以下格式:To add LocalizedCollections, use the following format:

{
  "LocalizedStrings": [...],
  "LocalizedCollections": [{
      "ElementType":"ClaimType",
      "ElementId":"<UserAttribute>",
      "TargetCollection":"Restriction",
      "Override": true,
      "Items":[
           {
                "Name":"<Response1>",
                "Value":"<Value1>"
           },
           {
                "Name":"<Response2>",
                "Value":"<Value2>"
           }
     ]
  }]
}
  • ElementId 是此 LocalizedCollections 属性响应的用户属性。ElementId is the user attribute that this LocalizedCollections attribute is a response to.
  • Name 是向用户显示的值。Name is the value that's shown to the user.
  • Value 是选择此选项时要在声明中返回的内容。Value is what is returned in the claim when this option is selected.

上传更改Upload your changes

  1. 完成对 JSON 文件的更改后,返回到 B2C 租户。After you complete the changes to your JSON file, go back to your B2C tenant.
  2. 选择“用户流”,单击想要启用翻译的用户流 。Select User flows and click the user flow that you want to enable for translations.
  3. 选择“语言” 。Select Languages.
  4. 选择要翻译成的语言。Select the language that you want to translate to.
  5. 选择想要提供翻译的页面。Select the page where you want to provide translations.
  6. 选择文件夹图标,选择要上传的 JSON 文件。Select the folder icon, and select the JSON file to upload.

更改将自动保存到用户流。The changes are saved to your user flow automatically.

使用语言自定义来自定义页面 UICustomize the page UI by using language customization

可通过两种方法本地化 HTML 内容。There are two ways to localize your HTML content. 一种方法是启用语言自定义One way is to turn on language customization. 启用此功能可让 Azure AD B2C 将 OpenID Connect 参数 ui-locales 转发到终结点。Enabling this feature allows Azure AD B2C to forward the OpenID Connect parameter, ui-locales, to your endpoint. 内容服务器可使用此参数提供特定语言的自定义 HTML 页面。Your content server can use this parameter to provide customized HTML pages that are language-specific.

或者,可以基于所用的区域设置从不同位置拉取内容。Alternatively, you can pull content from different places based on the locale that's used. 在已启用 CORS 的终结点中,可以设置文件夹结构以托管特定语言的内容。In your CORS-enabled endpoint, you can set up a folder structure to host content for specific languages. 如果使用通配符值 {Culture:RFC5646},则会调用正确的语言。You'll call the right one if you use the wildcard value {Culture:RFC5646}. 例如,假设自定义页 URI 如下:For example, assume that this is your custom page URI:

https://wingtiptoysb2c.blob.core.chinacloudapi.cn/{Culture:RFC5646}/wingtip/unified.html

可以在 fr 中加载页面。You can load the page in fr. 当页面拉取 HTML 和 CSS 内容时,将从以下项拉取:When the page pulls HTML and CSS content, it's pulling from:

https://wingtiptoysb2c.blob.core.chinacloudapi.cn/fr/wingtip/unified.html

添加自定义语言Add custom languages

还可以添加 Microsoft 目前未为其提供翻译的语言。You can also add languages that Microsoft currently does not provide translations for. 需要为用户流中的所有字符串提供翻译。You'll need to provide the translations for all the strings in the user flow. 语言和区域设置代码仅限于 ISO 639-1 标准中的代码。Language and locale codes are limited to those in the ISO 639-1 standard.

  1. 在 Azure AD B2C 租户中,选择“用户流” 。In your Azure AD B2C tenant, select User flows.
  2. 单击想要添加自定义语言的用户流,然后单击“语言” 。Click the user flow where you want to add custom languages, and then click Languages.
  3. 从页面顶部选择“添加自定义语言” 。Select Add custom language from the top of the page.
  4. 在打开的上下文窗格中,通过输入有效的区域设置代码确定要为其提供翻译的语言。In the context pane that opens, identify which language you're providing translations for by entering a valid locale code.
  5. 对于每个页,可以下载一组英语重写,并处理翻译。For each page, you can download a set of overrides for English and work on the translations.
  6. 完成 JSON 文件后,可为每个页面上传这些文件。After you're done with the JSON files, you can upload them for each page.
  7. 选择“启用”,用户流即可为用户显示此语言 。Select Enable, and your user flow can now show this language for your users.
  8. 保存语言。Save the language.

重要

在保存之前,你需要启用自定义语言或上传替代语言。You need to either enable the custom languages or upload overrides for it before you can save.

其他信息Additional information

页面 UI 自定义标签保留为重写Page UI customization labels as overrides

启用语言自定义时,会在英语 (en) 的 JSON 文件中保留以前使用页面 UI 自定义的标签编辑。When you enable language customization, your previous edits for labels using page UI customization are persisted in a JSON file for English (en). 可以通过在语言自定义中上传语言资源来继续更改标签和其他字符串。You can continue to change your labels and other strings by uploading language resources in language customization.

最新的翻译Up-to-date translations

Microsoft 致力于提供最新的翻译以供使用。Microsoft is committed to providing the most up-to-date translations for your use. Microsoft 会持续改进翻译,使其符合需要。Microsoft continuously improves translations and keeps them in compliance for you. Microsoft 将识别全局术语中的 bug 和更改,并在用户流中进行无缝更新。Microsoft will identify bugs and changes in global terminology and make updates that will work seamlessly in your user flow.

对从右向左书写的语言的支持Support for right-to-left languages

Microsoft 目前不支持从右向左书写的语言。Microsoft currently doesn't provide support for right-to-left languages. 你可以通过使用自定义区域设置并使用 CSS 更改字符串的显示方式来实现此目的。You can accomplish this by using custom locales and using CSS to change the way the strings are displayed. 如果需要此功能,请在 Azure 反馈中为此功能投票。If you need this feature, please vote for it on Azure Feedback.

社交标识提供者翻译Social identity provider translations

Microsoft 为社交登录名提供 ui_locales OIDC 参数。Microsoft provides the ui_locales OIDC parameter to social logins. 但某些社交标识提供者并不遵循此参数。But some social identity providers don't honor them.

浏览器行为Browser behavior

Chrome 和 Firefox 都会请求其设置的语言。Chrome and Firefox both request for their set language. 如果支持该语言,将先显示该语言,再显示默认语言。If it's a supported language, it's displayed before the default. Microsoft Edge 目前不会请求语言,而是直接使用默认语言。Microsoft Edge currently does not request a language and goes straight to the default language.

支持的语言Supported languages

Azure AD B2C 包括对以下语言的支持。Azure AD B2C includes support for the following languages. 用户流语言由 Azure AD B2C 提供。User flow languages are provided by Azure AD B2C. 多重身份验证 (MFA) 通知语言由 Azure MFA 提供。The multi-factor authentication (MFA) notification languages are provided by Azure MFA.

语言Language 语言代码Language code 用户流User flows MFA 通知MFA notifications
阿拉伯语Arabic arar 否 是
保加利亚语Bulgarian bgbg 否 是
BanglaBangla bnbn 是 否
加泰罗尼亚语Catalan caca 否 是
捷克语Czech cscs 是 是
丹麦语Danish dada 是 是
德语German dede 是 是
希腊语Greek elel 是 是
英语English enen 是 是
西班牙语Spanish eses 是 是
爱沙尼亚语Estonian etet 否 是
巴斯克语Basque eueu 否 是
芬兰语Finnish fifi 是 是
法语French frfr 是 是
加利西亚语Galician glgl 否 是
古吉拉特语Gujarati gugu 是 否
希伯来语Hebrew hehe 否 是
HindiHindi hihi 是 是
克罗地亚语Croatian hrhr 是 是
匈牙利语Hungarian huhu 是 是
印度尼西亚语Indonesian idid 否 是
意大利语Italian itit 是 是
日语Japanese jaja 是 是
哈萨克语Kazakh kkkk 否 是
卡纳达语Kannada knkn 是 否
朝鲜语Korean koko 是 是
立陶宛语Lithuanian ltlt 否 是
拉脱维亚语Latvian lvlv 否 是
马拉雅拉姆语Malayalam mlml 是 否
马拉地语Marathi mrmr 是 否
马来语Malay msms 是 是
挪威博克马尔语Norwegian Bokmal nbnb 是 否
荷兰语Dutch nlnl 是 是
挪威语Norwegian no 否 是
旁遮普语Punjabi papa 是 否
波兰语Polish plpl 是 是
葡萄牙语 - 巴西Portuguese - Brazil pt-brpt-br 是 是
葡萄牙语 - 葡萄牙Portuguese - Portugal pt-ptpt-pt 是 是
罗马尼亚语Romanian roro 是 是
俄语Russian ruru 是 是
斯洛伐克语Slovak sksk 是 是
斯洛文尼亚语Slovenian slsl 否 是
塞尔维亚语 - 西里尔文Serbian - Cyrillic sr-cryl-cssr-cryl-cs 否 是
塞尔维亚语 - 拉丁语Serbian - Latin sr-latn-cssr-latn-cs 否 是
瑞典语Swedish svsv 是 是
泰米尔语Tamil tata 是 否
泰卢固语Telugu tete 是 否
泰语Thai thth 是 是
土耳其语Turkish trtr 是 是
乌克兰语Ukrainian ukuk 否 是
越南语Vietnamese vivi 否 是
简体中文Chinese - Simplified zh-hanszh-hans 是 是
繁体中文Chinese - Traditional zh-hantzh-hant 是 是