学习009-09-05 Obtain Localization Strings from a Web API Controller Endpoint(从 Web API 控制器端点获取本地化字符串 )

Obtain Localization Strings from a Web API Controller Endpoint(从 Web API 控制器端点获取本地化字符串 )

This topic demonstrates how to obtain localized UI strings through HTTP requests to a Web API service. You can use the localized UI strings in your custom application that uses the XAF Web API as a backend.
本主题演示如何通过对Web API服务的HTTP请求获取本地化UI字符串。您可以在使用XAF Web API作为后端的自定义应用程序中使用本地化UI字符串。

Refer to the following article for instructions on how to localize UI strings for an XAF application: Localization.
有关如何本地化XAF应用程序的UI字符串的说明,请参阅以下文章:本地化。

Note
This option of our Web API Service ships as part of the DevExpress Universal Subscription.
我们的Web API服务的此选项作为DevExpress通用订阅的一部分提供。

Localization Controller(本地化控制器)

Localization Controller API(本地化控制器API)

Use the localization controller API to obtain translations for the following strings:
使用本地化控制器API获取以下字符串的翻译:

  • Class captions(类字幕)

Web API Endpoint: Localization/ClassCaption?classFullName=…
Method called in the controller: CaptionHelper.GetClassCaption

  • Member captions(会员字幕)

Web API Endpoint: Localization/MemberCaption?typeFullName=…&memberName=…
Method called in the controller: CaptionHelper.GetMemberCaption(Type, String)

The typeFullName string parameter is equal to typeof(objectType).FullName.
typeFullName字符串参数等于typeof(object tType)。全名。

  • Action captions(动作字幕)

Web API Endpoint: Localization/ActionCaption?actionName=…
Method called in the controller: CaptionHelper.GetActionCaption

  • Custom strings(自定义字符串)

Web API Endpoint: Localization/LocalizedText?groupPath=…&itemName=…
Method called in the controller: CaptionHelper.GetLocalizedText

You can control the language for localization through the Accept-Language request header. This header accepts language identifiers such as en, de, ja, and others. For additional details, refer to Globalization and localization in ASP.NET Core - QueryStringRequestCultureProvider.
您可以通过Accept-Language请求标头控制本地化的语言。此标头接受语言标识符,例如en、de、ja等。有关其他详细信息,请参阅ASP.NETCore-QueryStringRequestCultureProvider中的全球化和本地化。

Note
The localization controller does not require authorization. You need to take the following data access specifics into account:
本地化控制器不需要授权。您需要考虑以下数据访问细节:

  • You can access the localization controller without JWT tokens that are required for Web API endpoints.
    您可以在没有Web API端点所需的JWT令牌的情况下访问本地化控制器。

  • The localization controller provides access to a shared model layer, without considering user changes.
    本地化控制器提供对共享模型层的访问,而无需考虑用户更改。

  • You cannot use the localization controller to access secure data.
    您不能使用本地化控制器访问安全数据。

Without authorization, the controller has significantly better performance, which means it can process many more requests per second than other Web API endpoints.
未经授权,控制器的性能明显更好,这意味着它每秒可以处理比其他Web API端点更多的请求。

Example(示例)

This example demonstrates how to obtain a localized string. The code in this example sends a request to the Localization/LocalizedText endpoint with the groupPath and itemName parameters.
此示例演示如何获取本地化字符串。此示例中的代码使用groupPath和itemName参数向Localize/LocalizedText端点发送请求。

C# 
// This code requests a German version of 

你可能感兴趣的:(XAF,学习,前端,XAF,.net)