学习023-02 Localize Standard XAF Modules and DevExpress Controls Used in an Application(本地化应用程序中使用的标准X

Localize Standard XAF Modules and DevExpress Controls Used in an Application(本地化应用程序中使用的标准XAF模块和DevExpress控件)

The standard XAF modules and DevExpress controls supply most of the English texts an XAF application’s interface uses. The DevExpress .NET Localization Service provides the ready-to-use translations of these texts into different languages - ASP.NET Web Forms resources (required for an ASP.NET Web Forms application) and satellite assemblies (required for WinForms and ASP.NET Web Forms platforms). This topic describes how to use these translations in your application and how to manually localize standard XAF Modules and DevExpress controls when there are no ready-to-use translations for your language.
标准XAF模块和DevExpress控件提供了XAF应用程序界面所使用的大部分英文文本。DevExpress .NET本地化服务提供了这些文本的现成翻译,支持多种语言——包括ASP.NET Web Forms资源(ASP.NET Web Forms应用程序所需)和附属程序集(WinForms和ASP.NET Web Forms平台所需)。本主题介绍如何在应用程序中使用这些翻译,以及当没有现成的目标语言翻译时,如何手动本地化标准XAF模块和DevExpress控件。

Satellite Assemblies for DevExpress Controls and XAF Modules(DevExpress控件和XAF模块的附属程序集)

*You can install pre-built satellite assemblies in the Global Assembly Cache (GAC) to avoid translating texts supplied with DevExpress controls and XAF Modules. *
您可以将预构建的附属程序集安装到全局程序集缓存(GAC)中,从而无需翻译DevExpress控件和XAF模块提供的文本。

The .NET Product Installer includes assemblies for de, es, and ja languages. You can install them at your discretion. Use the DevExpress Localization Service to download satellite assemblies for other languages. Refer to the following topics for more information on how to register localization resources:
.NET产品安装程序包含de(德语)、es(西班牙语)和ja(日语)语言的程序集。您可以根据需要安装它们。对于其他语言,请使用DevExpress本地化服务下载附属程序集。有关如何注册本地化资源的更多信息,请参考以下主题:

  • In the GAC
    在全局程序集缓存(GAC)中

  • *From Localization Service and Product Installer *
    来自本地化服务和产品安装程序

Add the new language aspect as described in the Localization Basics topic, and restart Visual Studio to display localized values in the Model Editor.
按照“本地化基础”主题中的说明添加新的语言方面,然后重启Visual Studio,以便在模型编辑器中显示本地化值。

Ensure that the Languages key from the configuration file’s appSettings section contains all the languages your application supports:
确保配置文件appSettings部分的Languages键包含应用程序支持的所有语言:

*.config 
<configuration>
  <appSettings>
    <!-- ... -->
    <add key="Languages" value="en;de;fr" />
    <!-- ... -->
  </appSettings>
  <!-- ... -->
<configuration>
appsettings.json
// For .NET apps
{
    //
    "DevExpress": {
        "ExpressApp": {
            "Languages": "en;de;fr"
              // ...
        }
    }
}  

For .NET Framework applications, you can handle the XafApplication.CustomizeLanguagesList event as an alternative to the configuration setting above.
对于.NET Framework应用程序,您可以处理XafApplication.CustomizeLanguagesList事件,作为上述配置设置的替代方案。

Note
You should deploy satellite assemblies with an XAF application. Refer to the corresponding Deployment Tutorial’s topic for more information.

您应该随XAF应用程序一起部署附属程序集。有关更多信息,请参考相应的部署教程主题。

Localization Using the Localization Service(使用本地化服务进行本地化)

The Localization Service allows you to download and modify satellite assemblies. Set the .NET Platform to XAF to translate only XAF-specific values. Follow the steps from the Localization Service topic to localize XAF Modules. Note the following restrictions:
本地化服务允许您下载和修改附属程序集。将.NET平台设置为XAF,以便仅翻译XAF特定的值。按照“本地化服务”主题中的步骤本地化XAF模块。请注意以下限制:

  • *This service does not allow modifying default language text values. *
    此服务不允许修改默认语言的文本值。

  • *You can translate values for XPO classes from the Business Class Library only. *
    您只能翻译业务类库中XPO类的值。

  • *Because the XAF Application Model has a tree-like structure, the Name column displays property names in a different format that contains a path to the property and property name. For example, the Application | Views | Person_DetailView node’s Tooltip property has the “Application\Views\Person_DetailView\Tooltip” name in this table. *
    由于XAF应用模型具有树状结构,“名称”列以不同的格式显示属性名,其中包含属性的路径和属性名。例如,Application | Views | Person_DetailView节点的Tooltip属性在该表中显示为“Application\Views\Person_DetailView\Tooltip”。

  • *Check Show Calculated Values to show items that do not require translation: calculated values, items without a value in a default language, Domain Components from the Business Class Library, and values that contain property names (for example, ObjectCaptionFormat, DisplayFormat). *
    勾选“显示计算值”以显示不需要翻译的项:计算值、默认语言中没有值的项、业务类库中的领域组件,以及包含属性名的值(例如ObjectCaptionFormat、DisplayFormat)。

  • *Calculated values are translated automatically based on the non-calculated values’ translation. Input “non-calculated” in the search panel to show only the non-calculated values. *
    计算值会根据非计算值的翻译自动进行翻译。在搜索面板中输入“non-calculated”以仅显示非计算值。

在这里插入图片描述

  • *An item is only translated if it has a text value; otherwise, you can add a value for the target language or leave it blank. *
    只有当项具有文本值时才会被翻译;否则,您可以为目标语言添加一个值或留空。

  • Values containing properties’ names (ObjectCaptionFormat, DisplayFormat, etc.) should not be localized. ObjectFormatter processes these values and replaces properties’ names with the corresponding values.
    包含属性名的值(如ObjectCaptionFormat、DisplayFormat等)不应被本地化。ObjectFormatter会处理这些值,并将属性名替换为相应的值。

Note

  • *If you received FormatException or MemberNotFoundException, ensure that you have not replaced a property name with a localized value. *
    如果收到FormatException或MemberNotFoundException,请确保您没有用本地化值替换属性名。
  • *Strings from the DevExpress.Persistent.BaseImpl.EFCore assembly are not available in the Localization Service. To localize these strings, use the Localization Tool. *
    本地化服务中不提供DevExpress.Persistent.BaseImpl.EFCore程序集中的字符串。要本地化这些字符串,请使用本地化工具。

Manual Localization(手动本地化)

If the technique described in the section above does not apply to you, follow the instructions from the following topic: How to: Localize XAF Application Items Using XAF Tools.
如果上述部分描述的方法不适用,请按照以下主题中的说明操作:如何:使用XAF工具本地化XAF应用程序项。

Culture-specific resources should be exported to the Application Model when you localize DevExpress Controls.
本地化DevExpress控件时,应将特定于区域性的资源导出到应用模型。

  • *Invoke the Application Designer. *
    调用应用程序设计器。

  • In the Properties window, click the XafApplication.ResourcesExportedToModel property’s ellipsis button. In the invoked dialog, check the resources you want to localize. Click OK to submit the selection.
    在“属性”窗口中,单击XafApplication.ResourcesExportedToModel属性的省略号按钮。在弹出的对话框中,勾选您要本地化的资源。单击“确定”提交选择。

在这里插入图片描述

  • Invoke the Model Editor for the current application project and localize the Localization node’s child nodes.
    为当前应用程序项目调用模型编辑器,并本地化Localization节点的子节点。

在这里插入图片描述

You can also use the module’s ModuleBase.ResourcesExportedToModel property to add localizable resources in the Module Designer. The resources added in a module cannot be removed from the localizable resources list in another module or application. For example, if you added the resources in the base Module, these resources are used in a platform-specific Modules, but you cannot delete these resources from the platform-specific Module.
您也可以在模块设计器中使用模块的ModuleBase.ResourcesExportedToModel属性添加可本地化资源。在一个模块中添加的资源不能从另一个模块或应用程序的可本地化资源列表中删除。例如,如果您在基础模块中添加了资源,这些资源会在特定平台的模块中使用,但您不能从特定平台的模块中删除这些资源。

Note
Certain components added to a Model require a reference. For instance, after adding the XtraGrid Control to the Model, you get the following error: “The type ‘DevExpress.XtraGrid.Localization.GridResLocalizer’ is defined in an assembly that is not referenced. You should add a reference to assembly 'DevExpress.XtraGrid.v24.1…“. Add a reference to the required assembly to resolve this issue.

添加到模型中的某些组件需要引用。例如,将XtraGrid控件添加到模型后,可能会出现以下错误:“类型’DevExpress.XtraGrid.Localization.GridResLocalizer’定义在未被引用的程序集中。您应添加对’DevExpress.XtraGrid.v24.1…'程序集的引用”。添加对所需程序集的引用以解决此问题。

Reuse Your Translations(重用您的翻译)

You can use one of the following approaches to reuse translations in different XAF applications:
您可以使用以下方法之一在不同的XAF应用程序中重用翻译:

  • *Localize all standard XAF module captions using the Model Editor invoked for the application project and share the resulting XAFML files with translations; *
    使用为应用程序项目调用的模型编辑器本地化所有标准XAF模块标题,并共享包含翻译的XAFML文件;

  • *Create a new XAF module and localize all standard XAF module captions using the Model Editor invoked for its Model.DesignedDiffs.xafml file as described in the How to: Localize XAF Application Items Using XAF Tools topic. You can now use the Module or Application Designers to reuse this module in other applications. *
    创建一个新的XAF模块,并按照“如何:使用XAF工具本地化XAF应用程序项”主题中的说明,使用为其Model.DesignedDiffs.xafml文件调用的模型编辑器本地化所有标准XAF模块标题。现在,您可以使用模块设计器或应用程序设计器在其他应用程序中重用此模块。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤姆•猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值