XAF应用开发教程 汉化与多国语言支持

Posted xyyhcn

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了XAF应用开发教程 汉化与多国语言支持相关的知识,希望对你有一定的参考价值。

https://www.cnblogs.com/foreachlife/p/5067380.html

使用了XAF开发时,汉化是一个比较常的问题。

要实现汉化很简单:

1.在这里下载汉化资源文件。这里演示的版本是15.1.X的

2.文件下载后将:文件解压到目录    <你的项目>BIN 下面。 解压后如下所示:

 

 技术图片

这一步的功能是:汉化多数控件中的使用的文字资源。这是官方提供的方法,也有些字符串是没有被汉化的。因为DEV支持的语言也不少,也制做了许多国家的语言包。但CN的资源包还没有做完全汉化。

注意:上例中是在web中,在Win中,同样需要将上面的文件解压过去。

3.XAF中内容的汉化,因为XAF是基于控件开发的,所以控件汉化也算是完成了一部分XAF的汉化。另外不在控件中的,就需要在XAFML中进行汉化了。

In this topic, you will learn how to localize a typical XAF application. We recommend that you review the Application Model Basics andLocalization Basics topics before proceeding. You can localize an XAF application in two ways.

  • Directly in the Model Editor by translating each localizable value.
  • Using the Localization Tool, which can be invoked from the Model Editor Toolbar. This tool gathers all the localizable values in one grid, and provides the import/export functionality as well as the ability to use the Microsoft Translator service.

These two approaches are described below. We recommend using the Localization Tool, because it makes the localization process quicker and more convenient.

 

技术图片 Add the New Language Aspect and Localizable Resources to the Application Model

 

 

These are the initial steps that should be performed independent of the chosen localization approach.

  • Localization of the XAF modules and DevExpress controls used in your XAF application is required. If the localized resources are available for the target language, you can use them. Otherwise, you should export the culture-specific resources to the Application Model, to enable the capability to localize them together with your custom text. Follow the recommendations described in theLocalize Standard XAF Modules and DevExpress Controls Used in an Application topic.
  • Localizable resources of Windows Forms Templates are not available in the Application Model by default. To export them, modify the collection exposed by the Windows Forms module‘s ModuleBase.ResourcesExportedToModel property or application‘sXafApplication.ResourcesExportedToModel property. You can use the Module or Application Designer for this purpose, respectively. You should add the "MainForm Template", "DetailViewForm Template", "NestedFrame Template", "LookupControl Template" and "PopupForm Template" items.
    Note

    Template resources include strings such as "File", "View", "Home" and "Tools", used in the application‘s main menus as well as the ribbon. If you see that the menu items in the standard form, or page and group captions in the ribbon form, are not translated, ensure that you have added and translated the template resources.

  • If there are "hardcoded" strings visible in the application UI, it is recommended that you make them localizable. Refer to the How to: Localize Custom String Constants topic for details.
  • Invoke the Model Editor for the module project. Add a new language via the Languages Manager, as described in the Localization Basics topic. Repeat this step for the platform-specific modules. Note that a Visual Studio restart is required to see localized text provided with satellite assemblies in the Model Editor.

 

 

技术图片 Use the Localization Tool

 

 

We recommend that you begin the translation from the platform-agnostic module, and then proceed to the platform-specific modules. Follow the steps below to localize each of your XAF application modules with the Localization Tool.

  • Click the Localization button in the XAF Model Editor Toolbar. The expressApp Framework Localization window will be invoked.

    技术图片

    This window provides the grid editor with all localizable property names, paths, descriptions and values. The toolbar with the set of commands is also provided. The grid columns and actions available in this window are described in the Localization Tool topic.

  • In the Localization window toolbar, select the target language via the Translation Language drop-down.

    技术图片
    Note

    If you have successfully installed satellite assemblies for the target language, you will see that text supplied with the standard XAF modules have already been translated.

  • Apply the Untranslated non-calculated filter via the Filters action.

    技术图片

    This filter selects the properties that have non-empty default language values with Is Translated unchecked and Is Calculatedchecked. For instance, the OwnMembers node’s Caption properties will be displayed and the Columns node’s Caption properties will be hidden.

  • Translate all the values in the Translated Value column. Pressing the ENTER key moves focus to the next row. If there are several properties with the same Default Language value, the Multiple Values Translation dialog will be invoked. Click Yes, and all these values will be translated at once, and the next value to be translated will be focused.

    技术图片
    Note

     

    • You can use the Translate... button to automate the translation. Select one, several or all rows, and click Translate... or press CTRL+T. In the invoked dialog, select the original language (English by default), click Translate and the Microsoft Translator service will translate for you. Of course, an Internet connection is required for this feature. Note that automatic translation is not perfect, and requires review.

    • If you are not fluent in the target language, you can hire a professional translator. Export the selected rows to a CSV file via the Export |Selected records command, and pass this file to the translator. The translator will edit the values in the Translated Value column using a spreadsheet or a plaintext editor of his/her choice. The Description column content will help him/her see the context. The translated values can be loaded back from the CSV file via the Import Action. If non-latin characters are used in the CSV file, the file encoding should be UTF-8.

  • When you have finished the translation, click Save or press CTRL+S to save changes to the Application Model. The translated properties will be hidden due to the Untranslated... filter, and the Is Translated checkbox is checked after saving.

    技术图片
  • Next, apply the Calculated filter to review the calculated values.

    技术图片
  • After closing the Localization window, you can see the localized values in the Model Editor. Save the changes in the Model Editor.

A typical XAF application has platform-specific versions of the authentication, security strategy and modules. For instance, Windows Forms and ASP.NET applications can have SchedulerWindowsFormsModule and SchedulerAspNetModule modules included respectively. These modules extend the Application Model with localizable properties that are not available at the module level. You can have platform-specific Controllers provide strings that need to be localized (action captions, tooltips, exceptions, etc.). So, you should repeat these steps for each platform-specific module.

 

 

技术图片 Localize an XAF Application Directly in the Model Editor

 

 

Localizing an XAF application directly in the Model Editor is an alternate approach.

    • Select the target language via the XAF Model Editor Toolbar.
    • Set the localized values to the properties of the Application root node.
    • Expand the ActionDesign | Actions node. Set the localized values to the Caption properties of all its child nodes. The ShortCaptionand the Tooltip properties will be localized automatically, as they expose values from the Caption properties by default. Localize theConfirmationMessage properties if required.
Note

If you do not use the Active Directory authentication, take special note of the Log On window (web page) UI elements‘ localization. The Log On andCancel buttons are Actions. These Actions have Logon and DialogCancel IDs, and are localizable under the ActionDesign | Actions node.

    • Expand the ActionDesign | DisableReasons node. Set localized values to the Caption properties of its child nodes.
    • Expand the BOModel node. Set localized values to the Caption properties of its child nodes. You can skip nodes of classes that are not represented in the application UI (e.g., the XPBaseObject node). Note that the localization of ObjectCaptionFormat properties may also be required. The Caption properties of CreatableItemsNavigationItems and Views child nodes will be localized automatically as they expose values from class captions by default.
    • Expand the Localization node. Set localized values to the Value properties of its child nodes. Take special note of the Exceptions |UserVisibleExceptions child node. You can skip the Exceptions | SystemExceptions node, as it contains exceptions addressed to developers and administrators, and is invisible to end-users in normal application operation.
    • Expand the NavigationItems node. Check to see if there are any child nodes with captions not localized automatically. The Defaultnode caption should be localized.
    • If the ValidationModule module is used in the application, expand the Validation node. Set localized values to the child node properties denoted by the globe glyph (技术图片).
    • A typical XAF application has platform-specific versions of the authentication, security strategy and modules. For instance, Windows Forms and ASP.NET applications can have SchedulerWindowsFormsModule and SchedulerAspNetModule modules included, respectively. These modules extend the Application Model with localizable properties that are not available at the module level. You can have platform-specific Controllers that provide strings that need to be localized (action captions, tooltips, exceptions, etc.), so repeat these steps for each platform-specific module.
    • If you do not use the Active Directory authentication type, localization of the Log On window (web page) requires special attention. This window (web page) content is represented by the AuthenticationStandardLogonParameters Detail View, so navigate to theViews | AuthenticationStandardLogonParameters_DetailView node and set the localized value to its Caption property. Expand the Items child node and localize the Text property of the LogonText node. Localize the UserName and Passwords node captions.
Note

This step should be performed separately for Windows Forms and ASP.NET applications. Use the Model Editor invoked for each application project to localize the Log On window (web page) UI elements. However, the "Log On" and "Cancel" Actions captions can be localized in the module project Model. See the step 5 note for details. The message displayed when the logon fails is also localized in the module project Model under theLocalization | Exceptions | UserVisibleExceptions | Security node.

  • There are additional Localization child nodes in the Model Editor, invoked for the application project (Windows Forms or ASP.NET). For instance, in the Windows Forms application Model, you should set localized values to ConfirmationsDialogButtons andFrameTemplates child nodes.

 

 

技术图片 Miscellaneous Localizations that Cannot be Performed at Design Time

 

 

  • The splash screen form displayed on the Windows Forms application startup contains the "Loading" text label. This default text is hardcoded in XAF sources, as the Application Model is not yet initialized when the splash is displayed (see Windows Forms Application Creation and Initialization). You can set a different text using the ISplash.SetDisplayText method.
    C#
    VB
     
    static void Main() {
        // ... 
        MySolutionWindowsFormsApplication winApplication = 
            new MySolutionWindowsFormsApplication();
        // ... 
        try {
            winApplication.SplashScreen.SetDisplayText("Custom Text");
            winApplication.Setup();
            winApplication.Start();
            // ... 
    

     

 

以上是关于XAF应用开发教程 汉化与多国语言支持的主要内容,如果未能解决你的问题,请参考以下文章

IntelliJ IDEA 2017.1汉化版(附注册码+安装教程)

XAF应用开发教程 创建项目

如何在wxPython程序里支持多国语言

如何在wxPython程序里支持多国语言

XAF应用开发教程业务对象模型之引用类型与关联关系

XAF应用开发教程业务对象模型之简单类型属性